As described in ticket - that resource shouldn't be created in onap namespace because if it's not properly deleted it has impact on the security tests results.
Note: That change doesn't require any additional work in lab preparation - the namespace is going to be created by MSB K8S plugin.
Issue-ID: TEST-356
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I0acf6262e3c8c9fbe9113d96e62960ce36ece04c
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",
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"
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
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
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."""
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."""
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()
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
"""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:
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)
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:
Use settings values:
- K8S_CONFIG,
- - K8S_NAMESPACE.
+ - K8S_ONAP_NAMESPACE.
"""
super().execute()
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:
try:
self.k8s_client.patch_namespaced_service(
self.service_name,
- settings.K8S_NAMESPACE,
+ settings.K8S_ONAP_NAMESPACE,
[
{
"op": "remove",
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())
"""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())
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"]:
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")