aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps
diff options
context:
space:
mode:
Diffstat (limited to 'src/onaptests/steps')
-rw-r--r--src/onaptests/steps/base.py4
-rw-r--r--src/onaptests/steps/instantiate/msb_k8s.py38
-rw-r--r--src/onaptests/steps/onboard/cds.py46
-rw-r--r--src/onaptests/steps/onboard/msb_k8s.py16
-rw-r--r--src/onaptests/steps/simulator/cds_mockserver.py62
-rw-r--r--src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py4
6 files changed, 21 insertions, 149 deletions
diff --git a/src/onaptests/steps/base.py b/src/onaptests/steps/base.py
index 744fc7b..6d43fbc 100644
--- a/src/onaptests/steps/base.py
+++ b/src/onaptests/steps/base.py
@@ -126,8 +126,8 @@ class BaseStep(ABC):
if self._cleanup:
if self._cleanup_report:
yield self._cleanup_report
- for step in self._steps:
- yield from step.cleanup_reports
+ for step in self._steps:
+ yield from step.cleanup_reports
@property
def name(self) -> str:
diff --git a/src/onaptests/steps/instantiate/msb_k8s.py b/src/onaptests/steps/instantiate/msb_k8s.py
index ba1b732..e6186f5 100644
--- a/src/onaptests/steps/instantiate/msb_k8s.py
+++ b/src/onaptests/steps/instantiate/msb_k8s.py
@@ -1,6 +1,4 @@
"""MSB k8s instantiation module."""
-import time
-
from onapsdk.configuration import settings
from onapsdk.msb.k8s import Instance
@@ -8,35 +6,6 @@ from onaptests.steps.base import BaseStep
from onaptests.steps.onboard.msb_k8s import CreateProfileStep
-class InstancesCleanup(BaseStep):
- """Delete old instances which were not cleaned up properly."""
-
- @property
- def description(self) -> str:
- """Step description."""
- return ("Delete old instances which were created using same MSB_K8S_RESOURCE_NAME_PREFIX"
- " and were not cleaned up.")
-
- @property
- def component(self) -> str:
- """Component name."""
- return "K8S plugin"
-
- @BaseStep.store_state
- def execute(self) -> None:
- """Create instance using MSB K8S plugin."""
- super().execute()
- self._logger.debug("Delete all instances which are created using definition with same prefix ")
- any_deleted: bool = False
- for instance in Instance.get_all():
- if instance.request.profile_name.startswith(settings.MSB_K8S_RESOURCE_NAME_PREFIX):
- self._logger.debug("Delete %s instance", instance.instance_id)
- instance.delete()
- any_deleted = True
- if any_deleted:
- time.sleep(settings.MSB_K8S_CLEANUP_WAIT_TIME) # Give it some time to delete k8s resources (pods, services, deployments...)
-
-
class CreateInstanceStep(BaseStep):
"""Create MSB k8s instance step."""
@@ -47,7 +16,6 @@ class CreateInstanceStep(BaseStep):
- CreateProfileStep.
"""
super().__init__(cleanup=cleanup)
- self.add_step(InstancesCleanup())
self.add_step(CreateProfileStep(cleanup=cleanup))
self.instance: Instance = None
@@ -66,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.MSB_K8S_PROFILE_NAME,
- rb_name=settings.MSB_K8S_RB_NAME,
- rb_version=settings.MSB_K8S_RB_VERSION)
+ profile_name=settings.PNF_PROFILE_NAME,
+ rb_name=settings.PNF_RB_NAME,
+ rb_version=settings.PNF_RB_VERSION)
@BaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
diff --git a/src/onaptests/steps/onboard/cds.py b/src/onaptests/steps/onboard/cds.py
index 7f91d56..cbd69ce 100644
--- a/src/onaptests/steps/onboard/cds.py
+++ b/src/onaptests/steps/onboard/cds.py
@@ -8,7 +8,6 @@ from typing import Any, Dict
from kubernetes import client, config
from kubernetes.client.exceptions import ApiException
from onapsdk.cds import Blueprint, DataDictionarySet
-from onapsdk.cds.blueprint import Workflow
from onapsdk.cds.blueprint_processor import Blueprintprocessor
from onapsdk.configuration import settings
import urllib3
@@ -54,7 +53,7 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
try:
service_data: Dict[str, Any] = self.k8s_client.read_namespaced_service(
self.service_name,
- settings.K8S_ONAP_NAMESPACE
+ settings.K8S_NAMESPACE
)
return service_data.spec.type == "NodePort"
except ApiException:
@@ -67,7 +66,7 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
Use settings values:
- K8S_CONFIG,
- - K8S_ONAP_NAMESPACE.
+ - K8S_NAMESPACE.
"""
super().execute()
@@ -75,7 +74,7 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
try:
self.k8s_client.patch_namespaced_service(
self.service_name,
- settings.K8S_ONAP_NAMESPACE,
+ settings.K8S_NAMESPACE,
{"spec": {"ports": [{"port": 8080, "nodePort": 30449}], "type": "NodePort"}}
)
except ApiException:
@@ -97,7 +96,7 @@ class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep):
try:
self.k8s_client.patch_namespaced_service(
self.service_name,
- settings.K8S_ONAP_NAMESPACE,
+ settings.K8S_NAMESPACE,
[
{
"op": "remove",
@@ -223,45 +222,12 @@ class CbaPublishStep(CDSBaseStep):
@BaseStep.store_state
def execute(self) -> None:
- """Publish CBA file.
+ """Enrich CBA file.
Use settings values:
- - CDS_CBA_ENRICHED.
+ - CDS_DD_FILE.
"""
super().execute()
blueprint: Blueprint = Blueprint.load_from_file(settings.CDS_CBA_ENRICHED)
blueprint.publish()
-
-
-class CbaProcessStep(CDSBaseStep):
- """Process CBA step."""
-
- def __init__(self, cleanup=False) -> None:
- """Initialize CBA process step."""
- super().__init__(cleanup=cleanup)
- self.add_step(CbaPublishStep(cleanup=cleanup))
-
- @property
- def description(self) -> str:
- """Step description."""
- return "Process CBA file."
-
- @BaseStep.store_state
- def execute(self) -> None:
- """Process CBA file.
-
- Check if output is equal to expected
-
- Use settings values:
- - CDS_CBA_ENRICHED,
- - CDS_WORKFLOW_NAME,
- - CDS_WORKFLOW_INPUT
-
- """
- super().execute()
- blueprint: Blueprint = Blueprint.load_from_file(settings.CDS_CBA_ENRICHED)
- workflow: Workflow = blueprint.get_workflow_by_name(settings.CDS_WORKFLOW_NAME)
- output: Dict[str, Any] = workflow.execute(settings.CDS_WORKFLOW_INPUT)
- if not output == settings.CDS_WORKFLOW_EXPECTED_OUTPUT:
- raise OnapTestException("Response is not equal to the expected one")
diff --git a/src/onaptests/steps/onboard/msb_k8s.py b/src/onaptests/steps/onboard/msb_k8s.py
index 503a886..cad471b 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.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)
+ 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)
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.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,
+ 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,
kubernetes_version=settings.K8S_VERSION)
self.profile.upload_artifact(profile_file.read())
diff --git a/src/onaptests/steps/simulator/cds_mockserver.py b/src/onaptests/steps/simulator/cds_mockserver.py
deleted file mode 100644
index 6933fa0..0000000
--- a/src/onaptests/steps/simulator/cds_mockserver.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# http://www.apache.org/licenses/LICENSE-2.0
-"""CDS mockserver registration module."""
-
-import time
-
-import requests
-from onapsdk.configuration import settings
-
-from onaptests.steps.base import BaseStep
-from onaptests.steps.instantiate.msb_k8s import CreateInstanceStep
-from onaptests.utils.exceptions import OnapTestException
-
-
-class CdsMockserverCnfConfigureStep(BaseStep):
- """Configure cds mockserver expectations."""
-
- def __init__(self, cleanup: bool = False) -> None:
- """Initialize step.
-
- Substeps:
- - CreateInstanceStep.
- """
- super().__init__(cleanup=cleanup)
- self.add_step(CreateInstanceStep(cleanup=cleanup))
-
- @property
- def description(self) -> str:
- """Step description."""
- return "Configure cds-mockserver."
-
- @property
- def component(self) -> str:
- """Component name."""
- return "Environment"
-
- @BaseStep.store_state
- def execute(self) -> None:
- """Create mockserver expectations.
-
- Use settings values:
- - CDS_MOCKSERVER_EXPECTATIONS.
- """
- super().execute()
- time.sleep(60) # Wait for mockserver
- for expectation in settings.CDS_MOCKSERVER_EXPECTATIONS:
- try:
- response = requests.put(
- "http://portal.api.simpledemo.onap.org:30726/mockserver/expectation",
- json={
- "httpRequest" : {
- "method": expectation["method"],
- "path": expectation["path"]
- },
- "httpResponse" : {
- "body": expectation["response"]
- }
- }
- )
- response.raise_for_status()
- except (requests.ConnectionError, requests.HTTPError) as http_error:
- self._logger.debug(f"Can't register cds-mockserver expectation: {str(http_error)}")
- raise OnapTestException("CDS mockserver not configured")
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 1960659..caeb20b 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_ADDITIONAL_RESOURCES_NAMESPACE,
+ namespace=settings.K8S_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_ONAP_NAMESPACE).items:
+ for service in k8s_client.list_namespaced_service(namespace=settings.K8S_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")