aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps
diff options
context:
space:
mode:
authormorganrol <morgan.richomme@orange.com>2021-03-13 19:59:25 +0100
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2021-03-18 15:53:37 +0000
commit21e709c2619d78eae77fa4c63f0f48127aac8a25 (patch)
treeb1d9e44f2ff7c49008e2973a24b5cb7b6425b3b6 /src/onaptests/steps
parentb56dfed12c31a2c2ed1623064435897c8b137875 (diff)
[SDC] Certify only when needed
1) checkin and onboard only if the tests is not already distributed if the service is distributed, we assume that it is a replay of the test and we do not need to re-onboard the service done during the first steps. It shall be then possible to replay - basic_network - basic_vm - basic_cnf - basic_pnf - basic_clamp 2) include a replay of certify in case of resource not found Issue-ID: TEST-315 Signed-off-by: morganrol <morgan.richomme@orange.com> Change-Id: I04289311429c55d0e79220b0985c6a2f53d24bf1
Diffstat (limited to 'src/onaptests/steps')
-rw-r--r--src/onaptests/steps/onboard/service.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/onaptests/steps/onboard/service.py b/src/onaptests/steps/onboard/service.py
index bc99169..b591f8d 100644
--- a/src/onaptests/steps/onboard/service.py
+++ b/src/onaptests/steps/onboard/service.py
@@ -1,7 +1,9 @@
+import time
from typing import Any, Dict
from yaml import load
from onapsdk.configuration import settings
+from onapsdk.exceptions import APIError, ResourceNotFound
from onapsdk.sdc.component import Component
from onapsdk.sdc.pnf import Pnf
from onapsdk.sdc.properties import ComponentProperty
@@ -63,8 +65,18 @@ class ServiceOnboardStep(BaseStep):
if settings.PNF_NAME != "":
pnf: Pnf = Pnf(name=settings.PNF_NAME)
service.add_resource(pnf)
- service.checkin()
- service.onboard()
+ # If the service is already distributed, do not try to checkin/onboard (replay of tests)
+ # checkin is done if needed
+ # If service is replayed, no need to try to re-onboard the model
+ if not service.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(5)
+ service.checkin()
+ service.onboard()
class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
@@ -137,8 +149,18 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
service.create()
self.declare_resources(service)
self.assign_properties(service)
- service.checkin()
- service.onboard()
+ # If the service is already distributed, do not try to checkin/onboard (replay of tests)
+ # checkin is done if needed
+ # If service is replayed, no need to try to re-onboard the model
+ if not service.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(5)
+ service.checkin()
+ service.onboard()
def declare_resources(self, service: Service) -> None:
"""Declare resources.