aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2021-04-27 12:26:25 +0000
committerGerrit Code Review <gerrit@onap.org>2021-04-27 12:26:25 +0000
commit83e0a5a4fa8a7dedc1af3c3c0c5cb1706a5f2646 (patch)
tree0952963652bddbe3875fe8f94bf2e870ee658d03 /src/onaptests/steps
parent0a9bc9eba1ada15ec1a2934f3baa465804f20e76 (diff)
parentf901c5e96022a41db4bf2f4437b39999e46f5b97 (diff)
Merge "Wait for pnf simulator"
Diffstat (limited to 'src/onaptests/steps')
-rw-r--r--src/onaptests/steps/onboard/pnf.py13
-rw-r--r--src/onaptests/steps/onboard/vsp.py9
-rw-r--r--src/onaptests/steps/simulator/pnf_simulator_cnf/pnf_register.py86
3 files changed, 48 insertions, 60 deletions
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")