From 440df5e3af8446ddaf1e7ab9ed5abbbe439f9a06 Mon Sep 17 00:00:00 2001 From: Michal Jagiello Date: Wed, 31 Jan 2024 08:30:41 +0100 Subject: Refactor tests to use SDC v2 onapsdk module Refactored SDC allows to archive and delete SDC resources Remove unmaintained test basic_clamp Issue-ID: TEST-404 Signed-off-by: Michal Jagiello Change-Id: I11e4be6f4567098b20733879e393c689766a9c6e --- .../configuration/basic_onboard_settings.py | 38 +++++----------------- 1 file changed, 8 insertions(+), 30 deletions(-) (limited to 'src/onaptests/configuration/basic_onboard_settings.py') diff --git a/src/onaptests/configuration/basic_onboard_settings.py b/src/onaptests/configuration/basic_onboard_settings.py index e16bf31..73bc0e4 100644 --- a/src/onaptests/configuration/basic_onboard_settings.py +++ b/src/onaptests/configuration/basic_onboard_settings.py @@ -1,8 +1,5 @@ -import random -import string -from jinja2 import Environment, PackageLoader from yaml import SafeLoader, load import onaptests.utils.exceptions as onap_test_exceptions @@ -11,29 +8,6 @@ from onaptests.utils.resources import get_resource_location from .settings import * # noqa -# We need to create a service file with a random service name, -# to be sure that we force onboarding -def generate_service_config_yaml_file(): - """ generate the service file with a random service name - from a jinja template""" - - env = Environment( - loader=PackageLoader('onaptests', 'templates/vnf-services'), - ) - template = env.get_template('basic_onboard-service.yaml.j2') - - # get a random string to randomize the vnf name - # Random string with the combination of lower and upper case - letters = string.ascii_letters - result_str = ''.join(random.choice(letters) for i in range(6)) - service_name = 'basic_onboard_' + result_str - - rendered_template = template.render(service_name=service_name) - - with open(SERVICE_YAML_TEMPLATE, 'w+', encoding="utf-8") as file_to_write: - file_to_write.write(rendered_template) - - # The ONAP part SERVICE_DETAILS = "Basic onboard service to only onboard a service in SDC" @@ -45,8 +19,15 @@ SERVICE_DETAILS = "Basic onboard service to only onboard a service in SDC" # if a yaml file is define, retrieve info from this yaml files # if not declare the parameters in the settings +MODEL_YAML_TEMPLATE = None +CLEANUP_FLAG = True +SDC_CLEANUP = True + SERVICE_YAML_TEMPLATE = get_resource_location("templates/vnf-services/basic-onboard-service.yaml") -generate_service_config_yaml_file() +generate_service_config_yaml_file(service_name="basic_onboard", # noqa + service_template="basic_onboard-service.yaml.j2", + service_config=SERVICE_YAML_TEMPLATE, + generate_random_names=SDC_CLEANUP) try: # Try to retrieve the SERVICE NAME from the yaml file @@ -59,6 +40,3 @@ except (FileNotFoundError, ValueError) as exc: # CLEANUP_FLAG = True # CLEANUP_ACTIVITY_TIMER = 10 # nb of seconds before cleanup in case cleanup option is set VENDOR_NAME = "basic_onboard_vendor" - -MODEL_YAML_TEMPLATE = None -CLEANUP_FLAG = True -- cgit 1.2.3-korg