diff options
-rw-r--r-- | requirements.txt | 2 | ||||
-rw-r--r-- | src/onaptests/scenario/basic_network.py | 5 | ||||
-rw-r--r-- | src/onaptests/scenario/basic_vm.py | 3 | ||||
-rw-r--r-- | src/onaptests/steps/base.py | 5 | ||||
-rw-r--r-- | src/onaptests/steps/cloud/cloud_region_create.py | 3 | ||||
-rw-r--r-- | src/onaptests/steps/cloud/complex_create.py | 13 | ||||
-rw-r--r-- | src/onaptests/steps/cloud/customer_create.py | 6 | ||||
-rw-r--r-- | src/onaptests/steps/cloud/k8s_connectivity_info_create.py | 3 | ||||
-rw-r--r-- | src/onaptests/steps/cloud/register_cloud.py | 15 | ||||
-rw-r--r-- | src/onaptests/steps/instantiate/k8s_profile_create.py | 5 | ||||
-rw-r--r-- | src/onaptests/steps/instantiate/service_ala_carte.py | 5 | ||||
-rw-r--r-- | src/onaptests/steps/instantiate/service_macro.py | 3 |
12 files changed, 43 insertions, 25 deletions
diff --git a/requirements.txt b/requirements.txt index ead56f4..fec6816 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ xtesting openstacksdk -onapsdk>=7.1.0 +onapsdk==7.4.0 jinja2 kubernetes docker
\ No newline at end of file diff --git a/src/onaptests/scenario/basic_network.py b/src/onaptests/scenario/basic_network.py index 8aafd32..7a0b9f7 100644 --- a/src/onaptests/scenario/basic_network.py +++ b/src/onaptests/scenario/basic_network.py @@ -5,6 +5,7 @@ import time from xtesting.core import testcase from onapsdk.configuration import settings +from onapsdk.exceptions import SDKException import onaptests.utils.exceptions as onap_test_exceptions from onaptests.steps.instantiate.vl_ala_carte import YamlTemplateVlAlaCarteInstantiateStep @@ -40,8 +41,8 @@ class BasicNetwork(testcase.TestCase): time.sleep(settings.CLEANUP_ACTIVITY_TIMER) try: self.test.cleanup() - except ValueError as error: - self.__logger.info("service deleted as expected {0}".format(error)) + except SDKException as error: + self.__logger.info("service deletion error {0}".format(error)) self.result = 100 else: self.__logger.info("No cleanup requested. Test completed.") diff --git a/src/onaptests/scenario/basic_vm.py b/src/onaptests/scenario/basic_vm.py index cbf9b7c..8972a8c 100644 --- a/src/onaptests/scenario/basic_vm.py +++ b/src/onaptests/scenario/basic_vm.py @@ -5,6 +5,7 @@ import time from xtesting.core import testcase from onapsdk.configuration import settings +from onapsdk.exceptions import SDKException import onaptests.utils.exceptions as onap_test_exceptions from onaptests.steps.instantiate.vf_module_ala_carte import YamlTemplateVfModuleAlaCarteInstantiateStep @@ -46,6 +47,8 @@ class BasicVm(testcase.TestCase): except onap_test_exceptions.OnapTestException as exc: self.result = 0 self.__logger.error(exc.error_message) + except SDKException as error: + self.__logger.info("service error {0}".format(error)) finally: self.stop_time = time.time() diff --git a/src/onaptests/steps/base.py b/src/onaptests/steps/base.py index aa2be6a..97924bd 100644 --- a/src/onaptests/steps/base.py +++ b/src/onaptests/steps/base.py @@ -4,8 +4,9 @@ import time from abc import ABC, abstractmethod from typing import List -from onapsdk.configuration import settings from onapsdk.aai.business import Customer +from onapsdk.configuration import settings +from onapsdk.exceptions import SettingsError from .reports_collection import Report, ReportsCollection, ReportStepStatus @@ -26,7 +27,7 @@ class BaseStep(ABC): # Setup Proxy if SOCK_HTTP is defined in settings try: cls.set_proxy(settings.SOCK_HTTP) - except AttributeError: + except SettingsError: pass def __init__(self, cleanup: bool = False) -> None: diff --git a/src/onaptests/steps/cloud/cloud_region_create.py b/src/onaptests/steps/cloud/cloud_region_create.py index ba46466..21c846f 100644 --- a/src/onaptests/steps/cloud/cloud_region_create.py +++ b/src/onaptests/steps/cloud/cloud_region_create.py @@ -1,6 +1,7 @@ """A&AI cloud region creation module.""" from onapsdk.aai.cloud_infrastructure import CloudRegion from onapsdk.configuration import settings +from onapsdk.exceptions import ResourceNotFound from ..base import BaseStep @@ -38,7 +39,7 @@ class CloudRegionCreateStep(BaseStep): cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, cloud_region_id=settings.CLOUD_REGION_ID, ) - except ValueError: + except ResourceNotFound: CloudRegion.create( cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, cloud_region_id=settings.CLOUD_REGION_ID, diff --git a/src/onaptests/steps/cloud/complex_create.py b/src/onaptests/steps/cloud/complex_create.py index 1bb7e51..60565f4 100644 --- a/src/onaptests/steps/cloud/complex_create.py +++ b/src/onaptests/steps/cloud/complex_create.py @@ -1,5 +1,6 @@ from onapsdk.aai.cloud_infrastructure import Complex from onapsdk.configuration import settings +from onapsdk.exceptions import APIError from ..base import BaseStep @@ -27,8 +28,10 @@ class ComplexCreateStep(BaseStep): """ super().execute() - Complex.create( - physical_location_id=settings.COMPLEX_PHYSICAL_LOCATION_ID, - data_center_code=settings.COMPLEX_DATA_CENTER_CODE, - name=settings.COMPLEX_PHYSICAL_LOCATION_ID - ) + try: + Complex.create( + physical_location_id=settings.COMPLEX_PHYSICAL_LOCATION_ID, + data_center_code=settings.COMPLEX_DATA_CENTER_CODE, + name=settings.COMPLEX_PHYSICAL_LOCATION_ID) + except APIError: + self._logger.warn("Try to update the complex failed.") diff --git a/src/onaptests/steps/cloud/customer_create.py b/src/onaptests/steps/cloud/customer_create.py index 6c78d55..1cc0879 100644 --- a/src/onaptests/steps/cloud/customer_create.py +++ b/src/onaptests/steps/cloud/customer_create.py @@ -1,5 +1,6 @@ from onapsdk.aai.business import Customer from onapsdk.configuration import settings +from onapsdk.exceptions import APIError from ..base import BaseStep @@ -25,4 +26,7 @@ class CustomerCreateStep(BaseStep): - GLOBAL_CUSTOMER_ID. """ super().execute() - Customer.create(settings.GLOBAL_CUSTOMER_ID, settings.GLOBAL_CUSTOMER_ID, "INFRA") + try: + Customer.create(settings.GLOBAL_CUSTOMER_ID, settings.GLOBAL_CUSTOMER_ID, "INFRA") + except APIError: + self._logger.warn("Try to update the Customer failed.") diff --git a/src/onaptests/steps/cloud/k8s_connectivity_info_create.py b/src/onaptests/steps/cloud/k8s_connectivity_info_create.py index de0e683..2855be7 100644 --- a/src/onaptests/steps/cloud/k8s_connectivity_info_create.py +++ b/src/onaptests/steps/cloud/k8s_connectivity_info_create.py @@ -1,5 +1,6 @@ """Connectivity info creation module.""" from onapsdk.configuration import settings +from onapsdk.exceptions import APIError from onapsdk.msb.k8s import ConnectivityInfo from ..base import BaseStep @@ -31,7 +32,7 @@ class K8SConnectivityInfoStep(BaseStep): try: self._logger.info("Check if k8s connectivity information exists") ConnectivityInfo.get_connectivity_info_by_region_id(settings.CLOUD_REGION_ID) - except ValueError: + except APIError: self._logger.info("Create the k8s connectivity information") ConnectivityInfo.create(settings.CLOUD_REGION_ID, settings.CLOUD_REGION_CLOUD_OWNER, diff --git a/src/onaptests/steps/cloud/register_cloud.py b/src/onaptests/steps/cloud/register_cloud.py index 72da4f7..58c3e35 100644 --- a/src/onaptests/steps/cloud/register_cloud.py +++ b/src/onaptests/steps/cloud/register_cloud.py @@ -4,6 +4,7 @@ from uuid import uuid4 from onapsdk.aai.cloud_infrastructure import CloudRegion from onapsdk.configuration import settings +from onapsdk.exceptions import ResourceNotFound from ..base import BaseStep from onaptests.steps.cloud.cloud_region_create import CloudRegionCreateStep @@ -45,11 +46,11 @@ class RegisterCloudRegionStep(BaseStep): - TENANT_NAME. """ super().execute() - cloud_region: CloudRegion = CloudRegion.get_by_id( - cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, - cloud_region_id=settings.CLOUD_REGION_ID, - ) - if not list(cloud_region.esr_system_infos): + try: + cloud_region: CloudRegion = CloudRegion.get_by_id( + cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER, + cloud_region_id=settings.CLOUD_REGION_ID) + except ResourceNotFound: cloud_region.add_esr_system_info( esr_system_info_id=str(uuid4()), user_name=settings.VIM_USERNAME, @@ -78,7 +79,7 @@ class RegisterCloudRegionStep(BaseStep): # if it does not exist, create it try: cloud_region.get_tenant(settings.TENANT_ID) - except ValueError: + except ResourceNotFound: self._logger.warning("Impossible to retrieve the Specificed Tenant") self._logger.debug("If no multicloud selected, add the tenant") cloud_region.add_tenant( @@ -90,7 +91,7 @@ class RegisterCloudRegionStep(BaseStep): try: cloud_region.get_availability_zone_by_name( settings.AVAILABILITY_ZONE_NAME) - except ValueError: + except ResourceNotFound: cloud_region.add_availability_zone( settings.AVAILABILITY_ZONE_NAME, settings.AVAILABILITY_ZONE_TYPE) diff --git a/src/onaptests/steps/instantiate/k8s_profile_create.py b/src/onaptests/steps/instantiate/k8s_profile_create.py index a875f11..c2692c8 100644 --- a/src/onaptests/steps/instantiate/k8s_profile_create.py +++ b/src/onaptests/steps/instantiate/k8s_profile_create.py @@ -4,6 +4,7 @@ from yaml import load from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription from onapsdk.configuration import settings +from onapsdk.exceptions import APIError, ResourceNotFound from onapsdk.msb.k8s import Definition from onapsdk.so.instantiation import VnfParameter @@ -142,7 +143,7 @@ class K8SProfileStep(BaseStep): ######## Check profile for Definition ################################### try: rbdef.get_profile_by_name(k8s_profile_name) - except ValueError: + except ResourceNotFound: ######## Create profile for Definition ################################### profile = rbdef.create_profile(k8s_profile_name, k8s_profile_namespace, @@ -174,7 +175,7 @@ class K8SProfileStep(BaseStep): try: profile = rbdef.get_profile_by_name(k8s_profile_name) profile.delete() - except ValueError: + except APIError: self._logger.error("K8s profile deletion %s failed", k8s_profile_name) raise onap_test_exceptions.ProfileCleanupException super().cleanup() diff --git a/src/onaptests/steps/instantiate/service_ala_carte.py b/src/onaptests/steps/instantiate/service_ala_carte.py index d5e5096..6000e73 100644 --- a/src/onaptests/steps/instantiate/service_ala_carte.py +++ b/src/onaptests/steps/instantiate/service_ala_carte.py @@ -6,6 +6,7 @@ from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription from onapsdk.aai.business.owning_entity import OwningEntity as AaiOwningEntity from onapsdk.configuration import settings +from onapsdk.exceptions import ResourceNotFound from onapsdk.sdc.service import Service from onapsdk.so.instantiation import ServiceInstantiation from onapsdk.vid import Project @@ -66,7 +67,7 @@ class ServiceAlaCarteInstantiateStep(BaseStep): try: owning_entity = AaiOwningEntity.get_by_owning_entity_name( settings.OWNING_ENTITY) - except ValueError: + except ResourceNotFound: self._logger.info("Owning entity not found, create it") owning_entity = AaiOwningEntity.create(settings.OWNING_ENTITY) vid_project = Project.create(settings.PROJECT) @@ -187,7 +188,7 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep): try: owning_entity = AaiOwningEntity.get_by_owning_entity_name( settings.OWNING_ENTITY) - except ValueError: + except ResourceNotFound: self._logger.info("Owning entity not found, create it") owning_entity = AaiOwningEntity.create(settings.OWNING_ENTITY) vid_project = Project.create(settings.PROJECT) diff --git a/src/onaptests/steps/instantiate/service_macro.py b/src/onaptests/steps/instantiate/service_macro.py index 36f0130..04c3931 100644 --- a/src/onaptests/steps/instantiate/service_macro.py +++ b/src/onaptests/steps/instantiate/service_macro.py @@ -9,6 +9,7 @@ from onapsdk.aai.business.owning_entity import OwningEntity from onapsdk.aai.cloud_infrastructure.cloud_region import CloudRegion from onapsdk.aai.cloud_infrastructure.tenant import Tenant from onapsdk.configuration import settings +from onapsdk.exceptions import ResourceNotFound from onapsdk.sdc.service import Service from onapsdk.so.instantiation import ServiceInstantiation from onapsdk.vid import LineOfBusiness, Platform, Project @@ -137,7 +138,7 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep): try: owning_entity = OwningEntity.get_by_owning_entity_name( settings.OWNING_ENTITY) - except ValueError: + except ResourceNotFound: self._logger.info("Owning entity not found, create it") owning_entity = OwningEntity.create(settings.OWNING_ENTITY) vid_project: Project = Project(settings.PROJECT) |