diff options
Diffstat (limited to 'src/onaptests')
-rw-r--r-- | src/onaptests/configuration/pnf_macro_settings.py | 5 | ||||
-rw-r--r-- | src/onaptests/steps/onboard/pnf.py | 13 | ||||
-rw-r--r-- | src/onaptests/steps/onboard/vsp.py | 9 | ||||
-rw-r--r-- | src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py | 86 | ||||
-rwxr-xr-x | src/onaptests/templates/artifacts/pNF.csar | bin | 0 -> 22327 bytes | |||
-rw-r--r-- | src/onaptests/templates/vnf-services/pnf-service.yaml | 7 |
6 files changed, 54 insertions, 66 deletions
diff --git a/src/onaptests/configuration/pnf_macro_settings.py b/src/onaptests/configuration/pnf_macro_settings.py index e05b6c9..033e772 100644 --- a/src/onaptests/configuration/pnf_macro_settings.py +++ b/src/onaptests/configuration/pnf_macro_settings.py @@ -5,6 +5,7 @@ from .settings import * # pylint: disable=W0614 ONLY_INSTANTIATE = False CLEANUP_FLAG = True +USE_MULTICLOUD = False VENDOR_NAME = "pnf_macro_vendor" SERVICE_NAME = "test_pnf_macro" @@ -43,3 +44,7 @@ K8S_VERSION = "1.0" K8S_CONFIG = str(Path(Path(__file__).parent.parent, "templates/artifacts/config")) SERVICE_INSTANCE_NAME = "TestPNFMacroInstantiation" + +DCAE_VES_COLLECTOR_POD_NAME = "dcae-ves-collector" +PNF_WAIT_TIME = 60.0 +PNF_REGISTRATION_NUMBER_OF_TRIES = 5 diff --git a/src/onaptests/steps/onboard/pnf.py b/src/onaptests/steps/onboard/pnf.py index 547e0c0..6250d7e 100644 --- a/src/onaptests/steps/onboard/pnf.py +++ b/src/onaptests/steps/onboard/pnf.py @@ -3,8 +3,9 @@ from onapsdk.configuration import settings from onapsdk.sdc.pnf import Pnf from onapsdk.sdc.vendor import Vendor +from onapsdk.sdc.vsp import Vsp from ..base import BaseStep, YamlTemplateBaseStep -from .vendor import VendorOnboardStep +from .vsp import VspOnboardStep, YamlTemplateVspOnboardStep class PnfOnboardStep(BaseStep): @@ -21,7 +22,7 @@ class PnfOnboardStep(BaseStep): """ super().__init__(cleanup=cleanup) - self.add_step(VendorOnboardStep(cleanup=cleanup)) + self.add_step(VspOnboardStep(cleanup=cleanup)) @property def description(self) -> str: @@ -73,7 +74,7 @@ class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep): """ super().__init__(cleanup=cleanup) - self.add_step(VendorOnboardStep(cleanup=cleanup)) + self.add_step(YamlTemplateVspOnboardStep(cleanup=cleanup)) @property def description(self) -> str: @@ -104,7 +105,11 @@ class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep): if "pnfs" in self.yaml_template: vendor: Vendor = Vendor(name=settings.VENDOR_NAME) for pnf in self.yaml_template["pnfs"]: - pnf_obj: Pnf = Pnf(name=pnf["pnf_name"], vendor=vendor) + if "heat_files_to_upload" in pnf: + vsp: Vsp = Vsp(name=f"{pnf['pnf_name']}_VSP") + else: + vsp = None + pnf_obj: Pnf = Pnf(name=pnf["pnf_name"], vendor=vendor, vsp=vsp) pnf_obj.create() pnf_obj.add_deployment_artifact( artifact_type=pnf["pnf_artifact_type"], diff --git a/src/onaptests/steps/onboard/vsp.py b/src/onaptests/steps/onboard/vsp.py index 18f73d8..6f8fbf6 100644 --- a/src/onaptests/steps/onboard/vsp.py +++ b/src/onaptests/steps/onboard/vsp.py @@ -96,3 +96,12 @@ class YamlTemplateVspOnboardStep(YamlTemplateBaseStep): vendor=vendor, package=package) vsp.onboard() + elif "pnfs" in self.yaml_template: + for pnf in self.yaml_template["pnfs"]: + if "heat_files_to_upload" in pnf: + with open( + sys.path[-1] + "/" + pnf["heat_files_to_upload"], "rb") as package: + vsp: Vsp = Vsp(name=f"{pnf['pnf_name']}_VSP", + vendor=vendor, + package=package) + vsp.onboard() 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 a73f668..c1d76b0 100644 --- a/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py +++ b/src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py @@ -10,7 +10,7 @@ from onapsdk.configuration import settings from onaptests.steps.base import BaseStep from onaptests.steps.instantiate.msb_k8s import CreateInstanceStep -from onaptests.utils.exceptions import EnvironmentPreparationException +from onaptests.utils.exceptions import EnvironmentPreparationException, OnapTestException class PnfSimulatorCnfRegisterStep(BaseStep): @@ -73,7 +73,7 @@ class PnfSimulatorCnfRegisterStep(BaseStep): config.load_kube_config(settings.K8S_CONFIG) k8s_client: "CoreV1API" = client.CoreV1Api() for service in k8s_client.list_namespaced_service(namespace=settings.K8S_NAMESPACE).items: - if service.metadata.name == "xdcae-ves-collector": + 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") @@ -83,62 +83,36 @@ class PnfSimulatorCnfRegisterStep(BaseStep): super().execute() if not self.is_pnf_pod_running(): EnvironmentPreparationException("PNF simulator is not running") - time.sleep(30.0) # Let's still wait for PNF simulator to make sure it's initialized + time.sleep(settings.PNF_WAIT_TIME) # Let's still wait for PNF simulator to make sure it's initialized ves_ip, ves_port = self.get_ves_ip_and_port() - response = requests.post( - "http://portal.api.simpledemo.onap.org:30999/simulator/event", - json={ - "vesServerUrl": f"https://{ves_ip}:{ves_port}/eventListener/v7", - "event": { - "event": { - "commonEventHeader": { - "domain": "pnfRegistration", - "eventId": "ORAN_SIM_400600927_2020-04-02T17:20:22.2Z", - "eventName": "pnfRegistration", - "eventType": "EventType5G", - "sequence": 0, - "priority": "Low", - "reportingEntityId": "", - "reportingEntityName": "ORAN_SIM_400600927", - "sourceId": "", - "sourceName": settings.SERVICE_INSTANCE_NAME, - "startEpochMicrosec": 94262132085746, - "lastEpochMicrosec": 94262132085746, - "nfNamingCode": "sdn controller", - "nfVendorName": "sdn", - "timeZoneOffset": "+00:00", - "version": "4.0.1", - "vesEventListenerVersion": "7.0.1" + registration_number: int = 0 + registered_successfully: bool = False + while registration_number < settings.PNF_REGISTRATION_NUMBER_OF_TRIES and not registered_successfully: + try: + response = requests.post( + "http://portal.api.simpledemo.onap.org:30999/simulator/start", + json={ + "simulatorParams": { + "repeatCount": 9999, + "repeatInterval": 30, + "vesServerUrl": f"https://{ves_ip}:{ves_port}/eventListener/v7" }, - "pnfRegistrationFields": { - "pnfRegistrationFieldsVersion": "2.0", - "lastServiceDate": "2019-08-16", - "macAddress": "D7:64:C8:CC:E9:32", - "manufactureDate": "2019-08-16", - "modelNumber": "Simulated Device", - "oamV4IpAddress": "172.30.1.6", - "oamV6IpAddress": "0:0:0:0:0:ffff:a0a:011", - "serialNumber": "Simulated Device", - "softwareVersion": "2.3.5", - "unitFamily": "Simulated Device", - "unitType": "ntsim_oran", - "vendorName": "Melacon", - "additionalFields": { - "oamPort": "830", - "protocol": "SSH", - "username": "netconf", - "password": "netconf", - "reconnectOnChangedSchema": "false", - "sleep-factor": "1.5", - "tcpOnly": "false", - "connectionTimeout": "20000", - "maxConnectionAttempts": "100", - "betweenAttemptsTimeout": "2000", - "keepaliveDelay": "120" + "templateName": "registration.json", + "patch": { + "event": { + "commonEventHeader": { + "sourceName": settings.SERVICE_INSTANCE_NAME + } } } } - } - } - ) - response.raise_for_status() + ) + response.raise_for_status() + registered_successfully = True + self._logger.info(f"PNF registered with {settings.SERVICE_INSTANCE_NAME} source name") + except requests.HTTPError as http_error: + self._logger.debug(f"Can't connect with PNF simulator: {str(http_error)}") + registration_number = registration_number + 1 + time.sleep(settings.PNF_WAIT_TIME) + if not registered_successfully: + raise OnapTestException("PNF not registered successfully") diff --git a/src/onaptests/templates/artifacts/pNF.csar b/src/onaptests/templates/artifacts/pNF.csar Binary files differnew file mode 100755 index 0000000..7693506 --- /dev/null +++ b/src/onaptests/templates/artifacts/pNF.csar diff --git a/src/onaptests/templates/vnf-services/pnf-service.yaml b/src/onaptests/templates/vnf-services/pnf-service.yaml index 0676ce4..2dcdfbb 100644 --- a/src/onaptests/templates/vnf-services/pnf-service.yaml +++ b/src/onaptests/templates/vnf-services/pnf-service.yaml @@ -6,13 +6,8 @@ test_pnf_macro: instantiation_type: "Macro" pnfs: - pnf_name: "test-pnf" + heat_files_to_upload: onaptests/templates/artifacts/pNF.csar pnf_artifact_type: "CONTROLLER_BLUEPRINT_ARCHIVE" pnf_artifact_name: "CBA_enriched.zip" pnf_artifact_label: "cbapnf" pnf_artifact_file_path: "/tmp/PNF_DEMO_enriched.zip" - properties: - controller_actor: "CDS" - skip_post_instantiation_configuration: False - sdnc_artifact_name: "test" - sdnc_model_version: "1.0.0" - sdnc_model_name: "CBA_PNF_SIM" |