Commit 18b22c76 authored by Nikos Psaromanolakis's avatar Nikos Psaromanolakis
Browse files

fix: add poll to terminate and update requests

parent 87783280
Loading
Loading
Loading
Loading
Loading
−2
Changes for src/test/resources/hypo/orchestrator-setup.feature: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ Scenario: Setup - registry, org, peering, specs

  # 3) Start peering

  * karate.log(peered_org)
  * karate.log(orgId)
  * def startPer = call read('classpath:hypo/peering.feature@startPeering') { auth_token: '#(auth_token)', peered_org: '#(peered_org)', orgId: '#(orgId)' }

  # 4) Add peering spec
+8 −7
Changes for src/test/resources/hypo/orchestratorPrivate.feature: 8 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -114,21 +114,22 @@ Scenario: Run full sequence once
  # Get the updated payload
  * def updatedPayload = invSer.updatedPayload
  * call read('service.feature@updateServiceHelmPackage') { auth_token: '#(auth_token)', serviceId: '#(serviceId)', updatedPayload: '#(updatedPayload)' }
  * eval java.lang.Thread.sleep(30000)
  * def invSerUp = call read('service.feature@getServiceInventoryState') { auth_token: '#(auth_token)', serviceId: '#(serviceId)', requiredStatus:'ACTIVE'}

  * eval java.lang.Thread.sleep(15000)
  * def invSerUp = call read('service.feature@getServiceInventoryStatePoll') { auth_token: '#(auth_token)', serviceId: '#(serviceId)', requiredStatus:'ACTIVE'}

  * eval java.lang.Thread.sleep(40000)
  # 16) Terminate the end-user service
  * call read('service.feature@terminateService') { auth_token: '#(auth_token)', serviceId: '#(serviceId)' }
  * eval java.lang.Thread.sleep(30000)
  * def invSerTer = call read('service.feature@getServiceInventoryState') { auth_token: '#(auth_token)', serviceId: '#(serviceId)', requiredStatus:'TERMINATED'}
  * eval java.lang.Thread.sleep(15000)
  * def invSerTer = call read('service.feature@getServiceInventoryStatePoll') { auth_token: '#(auth_token)', serviceId: '#(serviceId)', requiredStatus:'TERMINATED'}
  * def terminatedEndUserService = true
  
  # 17) Terminate the resource service
  * eval java.lang.Thread.sleep(20000)
  * call read('service.feature@terminateService') { auth_token: '#(auth_token)', serviceId: '#(serviceK8sId)' }
  
  * eval java.lang.Thread.sleep(90000)
  * def invSerUp = call read('service.feature@getServiceInventoryState') { auth_token: '#(auth_token)', serviceId: '#(serviceK8sId)', requiredStatus:'TERMINATED'}
  * eval java.lang.Thread.sleep(15000)
  * def invSerUp = call read('service.feature@getServiceInventoryStatePoll') { auth_token: '#(auth_token)', serviceId: '#(serviceK8sId)', requiredStatus:'TERMINATED'}
  * def terminatedK8sService = true

  # Cleanup service orders (afterScenario handles the rest)
+32 −2
Changes for src/test/resources/hypo/service.feature: 32 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -233,8 +233,6 @@ Scenario: Get Service Inventory and Extract Kubernetes Metadata
  * karate.log('FoundNamespace :', serviceNamespace)




@getServiceInventoryState
Scenario: Get Service Inventory Status 
  * karate.log('--- STEP: GET SERVICE INVENTORY (UPDATE OR TERMINATE) ---')
@@ -247,7 +245,39 @@ Scenario: Get Service Inventory Status
  * match response.state == requiredStatus
  * karate.log('Service Status:', response.state)

@getServiceInventoryStatePoll
Scenario: Poll Service Inventory Status
  * karate.log('--- POLLING SERVICE INVENTORY STATUS ---')
  * karate.log('For Service ID:', serviceId, '| Looking for state:', requiredStatus)
  
  * def maxRetries = 9
  * def pollInterval = 20000
  
  * def doPoll = 
    """
    function() {
      for (var i = 0; i < maxRetries; i++) {
          try {
              karate.call('classpath:hypo/service.feature@getServiceInventoryState', { 
                  token: token,
                  serviceId: serviceId,
                  requiredStatus: requiredStatus
              });
              karate.log('Status reached at attempt #' + (i + 1));
              return true;
          } catch (e) {
              karate.log('Attempt #' + (i + 1) + ' - state not ready yet, retrying...');
              
              if (i < maxRetries - 1) {
                  java.lang.Thread.sleep(pollInterval);
              }
          }
      }
      karate.fail('Service did not reach ' + requiredStatus + ' within 3+ minutes.');
    }
    """
  
  * doPoll()

@getServiceInventoryResource
Scenario: Get Service Inventory