[INTEGRATION] Add one more conditional statement during service onboarding 89/129389/1 jakarta
authorMichal Jagiello <michal.jagiello@t-mobile.pl>
Wed, 20 Apr 2022 11:32:38 +0000 (11:32 +0000)
committerMichal Jagiello <michal.jagiello@t-mobile.pl>
Tue, 7 Jun 2022 08:40:27 +0000 (08:40 +0000)
Sometimes if we restart tests service can be on the "unexpected" state - for example Checked In
Then we shouldn't try to check it in again because it raises an exception
Check if service is not already checked in and if it's move forward

Issue-ID: SDC-3949
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I95dfd21f2dc92021b89db9e62abbb0005c06f907
(cherry picked from commit 0a22650bbcc263fcb42193468197f3ec290e195e)

src/onaptests/steps/onboard/service.py

index f95cc14..fa21d2c 100644 (file)
@@ -72,8 +72,14 @@ class ServiceOnboardStep(BaseStep):
         # If service is replayed, no need to try to re-onboard the model
         # Double check because of: https://gitlab.com/Orange-OpenSource/lfn/onap/python-onapsdk/-/issues/176
         if not service.distributed and service.status != onapsdk_const.DISTRIBUTED:
-            time.sleep(10)
-            service.checkin()
+            if service.status == onapsdk_const.DRAFT:
+                try:
+                    service.checkin()
+                except (APIError, ResourceNotFound):
+                    # Retry as checkin may be a bit long
+                    # Temp workaround to avoid internal race in SDC
+                    time.sleep(10)
+                    service.checkin()
             service.onboard()
 
 
@@ -173,13 +179,14 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
             # If service is replayed, no need to try to re-onboard the model
         # Double check because of: https://gitlab.com/Orange-OpenSource/lfn/onap/python-onapsdk/-/issues/176
         if not service.distributed and service.status != onapsdk_const.DISTRIBUTED:
-            try:
-                service.checkin()
-            except (APIError, ResourceNotFound):
-                # Retry as checkin may be a bit long
-                # Temp workaround to avoid internal race in SDC
-                time.sleep(10)
-                service.checkin()
+            if service.status == onapsdk_const.DRAFT:
+                try:
+                    service.checkin()
+                except (APIError, ResourceNotFound):
+                    # Retry as checkin may be a bit long
+                    # Temp workaround to avoid internal race in SDC
+                    time.sleep(10)
+                    service.checkin()
             service.onboard()
 
     def declare_resources(self, service: Service) -> None: