aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2021-12-20 07:25:45 +0000
committerGerrit Code Review <gerrit@onap.org>2021-12-20 07:25:45 +0000
commit2bd16f8898e6fd74e64b1500eb5fbc4448517d1a (patch)
tree6511af60374903774c8e0c2ed581bbcabce89e5b /src
parentfdb23f5d0a2ac49ac35578be855f2b937741136f (diff)
parent54803e59a08d09bbb34cb686740f41b1e7bc3684 (diff)
Merge "[TEST] Do not create simulators in "onap" namespace"
Diffstat (limited to 'src')
-rw-r--r--src/onaptests/configuration/cds_resource_resolution_settings.py15
-rw-r--r--src/onaptests/configuration/pnf_macro_settings.py11
-rw-r--r--src/onaptests/configuration/settings.py3
-rw-r--r--src/onaptests/scenario/basic_vm_macro.py6
-rw-r--r--src/onaptests/scenario/cds_blueprint_enrichment.py8
-rw-r--r--src/onaptests/scenario/pnf_macro.py6
-rw-r--r--src/onaptests/steps/instantiate/msb_k8s.py6
-rw-r--r--src/onaptests/steps/instantiate/vl_ala_carte.py2
-rw-r--r--src/onaptests/steps/onboard/cds.py8
-rw-r--r--src/onaptests/steps/onboard/msb_k8s.py16
-rw-r--r--src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py4
11 files changed, 45 insertions, 40 deletions
diff --git a/src/onaptests/configuration/cds_resource_resolution_settings.py b/src/onaptests/configuration/cds_resource_resolution_settings.py
index bb3b85b..16e23a6 100644
--- a/src/onaptests/configuration/cds_resource_resolution_settings.py
+++ b/src/onaptests/configuration/cds_resource_resolution_settings.py
@@ -12,15 +12,16 @@ CLOUD_REGION_VERSION = "1.0"
CLOUD_OWNER_DEFINED_TYPE = "N/A"
COMPLEX_PHYSICAL_LOCATION_ID = "sdktests"
-PNF_DEFINITION_ATRIFACT_FILE_PATH = Path(Path(__file__).parent.parent,
- "templates/artifacts/cds-resource-resolution/cds-mock-server.tar.gz")
-PNF_RB_NAME = f"cds-ms-rb-{str(uuid4())}"
-PNF_RB_VERSION = "v1"
-PNF_PROFILE_ARTIFACT_FILE_PATH = Path(Path(__file__).parent.parent,
- "templates/artifacts/profile.tar.gz")
-PNF_PROFILE_NAME = f"cds-ms-prof-{str(uuid4())}"
+MSB_K8S_DEFINITION_ATRIFACT_FILE_PATH = Path(Path(__file__).parent.parent,
+ "templates/artifacts/cds-resource-resolution/cds-mock-server.tar.gz")
+MSB_K8S_RB_NAME = f"cds-ms-rb-{str(uuid4())}"
+MSB_K8S_RB_VERSION = "v1"
+MSB_K8S_PROFILE_ARTIFACT_FILE_PATH = Path(Path(__file__).parent.parent,
+ "templates/artifacts/profile.tar.gz")
+MSB_K8S_PROFILE_NAME = f"cds-ms-prof-{str(uuid4())}"
K8S_VERSION = "1.0"
K8S_CONFIG = str(Path(Path(__file__).parent.parent, "templates/artifacts/config"))
+K8S_ADDITIONAL_RESOURCES_NAMESPACE = "onap-tests"
CDS_MOCKSERVER_EXPECTATIONS = [
{
"method": "GET",
diff --git a/src/onaptests/configuration/pnf_macro_settings.py b/src/onaptests/configuration/pnf_macro_settings.py
index 515fce1..eaca93a 100644
--- a/src/onaptests/configuration/pnf_macro_settings.py
+++ b/src/onaptests/configuration/pnf_macro_settings.py
@@ -33,15 +33,16 @@ PLATFORM = "pnf_macro_platform"
INSTANTIATION_TIMEOUT = 600
-PNF_DEFINITION_ATRIFACT_FILE_PATH = Path(Path(__file__).parent.parent,
+MSB_K8S_DEFINITION_ATRIFACT_FILE_PATH = Path(Path(__file__).parent.parent,
"templates/artifacts/pnf-simulator.tar.gz")
-PNF_RB_NAME = f"pnf-cnf-rb-{str(uuid4())}"
-PNF_RB_VERSION = "v1"
-PNF_PROFILE_ARTIFACT_FILE_PATH = Path(Path(__file__).parent.parent,
+MSB_K8S_RB_NAME = f"pnf-cnf-rb-{str(uuid4())}"
+MSB_K8S_RB_VERSION = "v1"
+MSB_K8S_PROFILE_ARTIFACT_FILE_PATH = Path(Path(__file__).parent.parent,
"templates/artifacts/profile.tar.gz")
-PNF_PROFILE_NAME = f"pnf-cnf-profile-{str(uuid4())}"
+MSB_K8S_PROFILE_NAME = f"pnf-cnf-profile-{str(uuid4())}"
K8S_VERSION = "1.0"
K8S_CONFIG = str(Path(Path(__file__).parent.parent, "templates/artifacts/config"))
+K8S_ADDITIONAL_RESOURCES_NAMESPACE = "onap-tests"
SERVICE_INSTANCE_NAME = "TestPNFMacroInstantiation"
diff --git a/src/onaptests/configuration/settings.py b/src/onaptests/configuration/settings.py
index 491e5e0..e6f894d 100644
--- a/src/onaptests/configuration/settings.py
+++ b/src/onaptests/configuration/settings.py
@@ -43,7 +43,8 @@ REPORTING_FILE_PATH = "/tmp/reporting.html"
K8S_REGION_TYPE = "k8s"
TILLER_HOST = "localhost"
K8S_CONFIG = None # None means it will use default config (~/.kube/config)
-K8S_NAMESPACE = "onap" # Kubernetes namespace
+K8S_ONAP_NAMESPACE = "onap" # ONAP Kubernetes namespace
+K8S_ADDITIONAL_RESOURCES_NAMESPACE = K8S_ONAP_NAMESPACE # Resources created on tests namespace
#SOCK_HTTP = "socks5h://127.0.0.1:8091"
ORCHESTRATION_REQUEST_TIMEOUT = 60.0 * 15 # 15 minutes in seconds
diff --git a/src/onaptests/scenario/basic_vm_macro.py b/src/onaptests/scenario/basic_vm_macro.py
index 67dded9..8bbf0b7 100644
--- a/src/onaptests/scenario/basic_vm_macro.py
+++ b/src/onaptests/scenario/basic_vm_macro.py
@@ -25,10 +25,10 @@ class BasicVmMacroStep(YamlTemplateBaseStep):
super().__init__(cleanup=cleanup)
self._yaml_template: dict = None
self.add_step(CbaPublishStep(
- cleanup=settings.CLEANUP_FLAG
+ cleanup=cleanup
))
self.add_step(YamlTemplateServiceMacroInstantiateStep(
- cleanup=settings.CLEANUP_FLAG
+ cleanup=cleanup
))
@property
@@ -101,7 +101,7 @@ class BasicVmMacroStep(YamlTemplateBaseStep):
class BasicVmMacro(testcase.TestCase):
"""Instantiate a basic vm macro."""
- __logger = logging.getLogger(__name__)
+ __logger = logging.getLogger()
def __init__(self, **kwargs):
"""Init Basic Macro use case."""
diff --git a/src/onaptests/scenario/cds_blueprint_enrichment.py b/src/onaptests/scenario/cds_blueprint_enrichment.py
index 3354ee1..c442780 100644
--- a/src/onaptests/scenario/cds_blueprint_enrichment.py
+++ b/src/onaptests/scenario/cds_blueprint_enrichment.py
@@ -15,7 +15,7 @@ from onaptests.utils.exceptions import OnapTestException
class CDSBlueprintEnrichment(testcase.TestCase):
"""Enrich simple blueprint using CDS blueprintprocessor."""
- __logger = logging.getLogger(__name__)
+ __logger = logging.getLogger()
def __init__(self, **kwargs):
"""Init CDS blueprint enrichment use case."""
@@ -34,13 +34,15 @@ class CDSBlueprintEnrichment(testcase.TestCase):
self.start_time = time.time()
try:
self.test.execute()
+ if settings.CLEANUP_FLAG:
+ self.test.cleanup()
self.result = 100
except OnapTestException as exc:
self.result = 0
- self.__logger.error(exc.error_message)
+ self.__logger.exception(exc.error_message)
except SDKException:
self.result = 0
- self.__logger.error("SDK Exception")
+ self.__logger.exception("SDK Exception")
finally:
self.stop_time = time.time()
diff --git a/src/onaptests/scenario/pnf_macro.py b/src/onaptests/scenario/pnf_macro.py
index 73a2adf..7b7c219 100644
--- a/src/onaptests/scenario/pnf_macro.py
+++ b/src/onaptests/scenario/pnf_macro.py
@@ -26,13 +26,13 @@ class PnfMacroScenarioStep(YamlTemplateBaseStep):
super().__init__(cleanup=cleanup)
self._yaml_template: dict = None
self.add_step(PnfSimulatorCnfRegisterStep(
- cleanup=settings.CLEANUP_FLAG
+ cleanup=cleanup
))
self.add_step(CbaEnrichStep(
- cleanup=settings.CLEANUP_FLAG
+ cleanup=cleanup
))
self.add_step(YamlTemplateServiceMacroInstantiateStep(
- cleanup=settings.CLEANUP_FLAG
+ cleanup=cleanup
))
@property
diff --git a/src/onaptests/steps/instantiate/msb_k8s.py b/src/onaptests/steps/instantiate/msb_k8s.py
index e6186f5..8f9ff2f 100644
--- a/src/onaptests/steps/instantiate/msb_k8s.py
+++ b/src/onaptests/steps/instantiate/msb_k8s.py
@@ -34,9 +34,9 @@ class CreateInstanceStep(BaseStep):
"""Create instance using MSB K8S plugin."""
super().execute()
self.instance = Instance.create(cloud_region_id=settings.CLOUD_REGION_ID,
- profile_name=settings.PNF_PROFILE_NAME,
- rb_name=settings.PNF_RB_NAME,
- rb_version=settings.PNF_RB_VERSION)
+ profile_name=settings.MSB_K8S_PROFILE_NAME,
+ rb_name=settings.MSB_K8S_RB_NAME,
+ rb_version=settings.MSB_K8S_RB_VERSION)
@BaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
diff --git a/src/onaptests/steps/instantiate/vl_ala_carte.py b/src/onaptests/steps/instantiate/vl_ala_carte.py
index 158e437..3f81228 100644
--- a/src/onaptests/steps/instantiate/vl_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vl_ala_carte.py
@@ -157,7 +157,7 @@ class YamlTemplateVlAlaCarteInstantiateStep(YamlTemplateBaseStep):
Raises:
Exception: VL cleaning failed
"""
- if settings.CLEANUP_FLAG:
+ if self._cleanup:
for net_instance in self._service_instance.network_instances:
self._logger.info("Start network deletion %s",net_instance.name)
net_deletion = net_instance.delete(a_la_carte=True)
diff --git a/src/onaptests/steps/onboard/cds.py b/src/onaptests/steps/onboard/cds.py
index 9239c43..7f91d56 100644
--- a/src/onaptests/steps/onboard/cds.py
+++ b/src/onaptests/steps/onboard/cds.py
@@ -54,7 +54,7 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
try:
service_data: Dict[str, Any] = self.k8s_client.read_namespaced_service(
self.service_name,
- settings.K8S_NAMESPACE
+ settings.K8S_ONAP_NAMESPACE
)
return service_data.spec.type == "NodePort"
except ApiException:
@@ -67,7 +67,7 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
Use settings values:
- K8S_CONFIG,
- - K8S_NAMESPACE.
+ - K8S_ONAP_NAMESPACE.
"""
super().execute()
@@ -75,7 +75,7 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
try:
self.k8s_client.patch_namespaced_service(
self.service_name,
- settings.K8S_NAMESPACE,
+ settings.K8S_ONAP_NAMESPACE,
{"spec": {"ports": [{"port": 8080, "nodePort": 30449}], "type": "NodePort"}}
)
except ApiException:
@@ -97,7 +97,7 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
try:
self.k8s_client.patch_namespaced_service(
self.service_name,
- settings.K8S_NAMESPACE,
+ settings.K8S_ONAP_NAMESPACE,
[
{
"op": "remove",
diff --git a/src/onaptests/steps/onboard/msb_k8s.py b/src/onaptests/steps/onboard/msb_k8s.py
index cad471b..503a886 100644
--- a/src/onaptests/steps/onboard/msb_k8s.py
+++ b/src/onaptests/steps/onboard/msb_k8s.py
@@ -36,9 +36,9 @@ class CreateDefinitionStep(BaseStep):
def execute(self) -> None:
"""Create definition."""
super().execute()
- with open(settings.PNF_DEFINITION_ATRIFACT_FILE_PATH, "rb") as definition_file:
- self.definition = Definition.create(rb_name=settings.PNF_RB_NAME,
- rb_version=settings.PNF_RB_VERSION)
+ with open(settings.MSB_K8S_DEFINITION_ATRIFACT_FILE_PATH, "rb") as definition_file:
+ self.definition = Definition.create(rb_name=settings.MSB_K8S_RB_NAME,
+ rb_version=settings.MSB_K8S_RB_VERSION)
self.definition.upload_artifact(definition_file.read())
@@ -70,10 +70,10 @@ class CreateProfileStep(BaseStep):
"""Create profile."""
super().execute()
definition: Definition = Definition.get_definition_by_name_version(\
- rb_name=settings.PNF_RB_NAME,
- rb_version=settings.PNF_RB_VERSION)
- with open(settings.PNF_PROFILE_ARTIFACT_FILE_PATH, "rb") as profile_file:
- self.profile = definition.create_profile(profile_name=settings.PNF_PROFILE_NAME,
- namespace=settings.K8S_NAMESPACE,
+ rb_name=settings.MSB_K8S_RB_NAME,
+ rb_version=settings.MSB_K8S_RB_VERSION)
+ with open(settings.MSB_K8S_PROFILE_ARTIFACT_FILE_PATH, "rb") as profile_file:
+ self.profile = definition.create_profile(profile_name=settings.MSB_K8S_PROFILE_NAME,
+ namespace=settings.K8S_ADDITIONAL_RESOURCES_NAMESPACE,
kubernetes_version=settings.K8S_VERSION)
self.profile.upload_artifact(profile_file.read())
diff --git a/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py b/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py
index caeb20b..1960659 100644
--- a/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py
+++ b/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py
@@ -51,7 +51,7 @@ class PnfSimulatorCnfRegisterStep(BaseStep):
k8s_watch: "Watch" = watch.Watch()
try:
for event in k8s_watch.stream(k8s_client.list_namespaced_pod,
- namespace=settings.K8S_NAMESPACE,
+ namespace=settings.K8S_ADDITIONAL_RESOURCES_NAMESPACE,
timeout_seconds=timeout_seconds):
if event["object"].metadata.name == "pnf-macro-test-simulator":
if not event["object"].status.phase in ["Pending", "Running"]:
@@ -76,7 +76,7 @@ class PnfSimulatorCnfRegisterStep(BaseStep):
config.load_kube_config(settings.K8S_CONFIG)
k8s_client: "CoreV1API" = client.CoreV1Api()
try:
- for service in k8s_client.list_namespaced_service(namespace=settings.K8S_NAMESPACE).items:
+ for service in k8s_client.list_namespaced_service(namespace=settings.K8S_ONAP_NAMESPACE).items:
if service.metadata.name == settings.DCAE_VES_COLLECTOR_POD_NAME:
return service.spec.cluster_ip, service.spec.ports[0].port
raise EnvironmentPreparationException("Couldn't get VES ip and port")