aboutsummaryrefslogtreecommitdiffstats
path: root/integration_tests
diff options
context:
space:
mode:
Diffstat (limited to 'integration_tests')
-rw-r--r--integration_tests/__init__.py21
-rw-r--r--integration_tests/docker-compose.yml53
-rw-r--r--integration_tests/local_urls.py23
-rw-r--r--integration_tests/tca_clampnode.yaml171
-rw-r--r--integration_tests/test_01_vendor.py42
-rw-r--r--integration_tests/test_02_vsp.py63
-rw-r--r--integration_tests/test_03_vf.py90
-rw-r--r--integration_tests/test_04_service.py122
-rw-r--r--integration_tests/test_05_cloud_infrastructure.py88
-rw-r--r--integration_tests/test_06_customer.py85
-rw-r--r--integration_tests/test_07_instantiation.py427
-rw-r--r--integration_tests/test_08_cds.py65
-rw-r--r--integration_tests/test_09_clamp.py78
-rw-r--r--integration_tests/test_10_msb_k8s.py125
-rw-r--r--integration_tests/test_11_ves.py109
-rw-r--r--integration_tests/test_12_dmaap.py31
-rw-r--r--integration_tests/test_files/test_dd.json48
-rw-r--r--integration_tests/test_files/test_vLB_CBA_Python.zipbin0 -> 25559 bytes
-rw-r--r--integration_tests/ubuntu16.zipbin0 -> 1641 bytes
-rw-r--r--integration_tests/urls.py23
20 files changed, 1664 insertions, 0 deletions
diff --git a/integration_tests/__init__.py b/integration_tests/__init__.py
new file mode 100644
index 0000000..d985dca
--- /dev/null
+++ b/integration_tests/__init__.py
@@ -0,0 +1,21 @@
+"""Main test module."""
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import logging
+
+logging.basicConfig(
+ level=logging.DEBUG,
+ format='%(asctime)s - %(name)-23s - %(levelname)-8s - %(message)s')
+logging.captureWarnings(True)
diff --git a/integration_tests/docker-compose.yml b/integration_tests/docker-compose.yml
new file mode 100644
index 0000000..6e92625
--- /dev/null
+++ b/integration_tests/docker-compose.yml
@@ -0,0 +1,53 @@
+version: "3.4"
+services:
+ sdc.api.fe.simpledemo.onap.org:
+ image: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-sdc:develop
+ networks:
+ sdk_integration:
+ ipv4_address: 172.20.0.2
+ aai.api.sparky.simpledemo.onap.org:
+ image: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-aai
+ networks:
+ sdk_integration:
+ ipv4_address: 172.20.0.3
+ so.api.simpledemo.onap.org:
+ image: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-so
+ networks:
+ sdk_integration:
+ ipv4_address: 172.20.0.4
+ sdnc.api.simpledemo.onap.org:
+ image: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-sdnc
+ networks:
+ sdk_integration:
+ ipv4_address: 172.20.0.5
+ clamp.api.simpledemo.onap.org:
+ image: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-clamp:develop
+ networks:
+ sdk_integration:
+ ipv4_address: 172.20.0.6
+ cds.api.simpledemo.onap.org:
+ image: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-cds
+ networks:
+ sdk_integration:
+ ipv4_address: 172.20.0.7
+ msb.k8s.api.simpledemo.onap.org:
+ image: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-msb-k8s
+ networks:
+ sdk_integration:
+ ipv4_address: 172.20.0.8
+ ves.api.simpledemo.onap.org:
+ image: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-dcae/mock-ves
+ networks:
+ sdk_integration:
+ ipv4_address: 172.20.0.9
+ dmaap.api.simpledemo.onap.org:
+ image: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-dmaap
+ networks:
+ sdk_integration:
+ ipv4_address: 172.20.0.10
+
+networks:
+ sdk_integration:
+ ipam:
+ config:
+ - subnet: 172.20.0.0/24 \ No newline at end of file
diff --git a/integration_tests/local_urls.py b/integration_tests/local_urls.py
new file mode 100644
index 0000000..9b73a67
--- /dev/null
+++ b/integration_tests/local_urls.py
@@ -0,0 +1,23 @@
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+SDC_BE_URL = "http://172.20.0.2:30206"
+SDC_FE_URL = "http://172.20.0.2:30206"
+AAI_URL = "http://172.20.0.3:5000"
+SO_URL = "http://172.20.0.4:5001"
+SDNC_URL = "http://172.20.0.5:5002"
+CLAMP_URL = "http://172.20.0.6:30258"
+CDS_URL = "http://172.20.0.7:8080"
+MSB_URL = "http://172.20.0.8:5003"
+VES_URL = "http://172.20.0.9:30417"
+DMAAP_URL = "http://172.20.0.10:3904"
diff --git a/integration_tests/tca_clampnode.yaml b/integration_tests/tca_clampnode.yaml
new file mode 100644
index 0000000..bd682b0
--- /dev/null
+++ b/integration_tests/tca_clampnode.yaml
@@ -0,0 +1,171 @@
+#
+# ============LICENSE_START====================================================
+# =============================================================================
+# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END======================================================
+
+tosca_definitions_version: cloudify_dsl_1_3
+
+description: >
+ This blueprint deploys/manages the TCA module as a Docker container
+
+imports:
+ - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml
+ - "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml"
+ - "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/clamppolicyplugin/1.1.0/clamppolicyplugin_types.yaml"
+inputs:
+ aaiEnrichmentHost:
+ type: string
+ default: "aai.onap.svc.cluster.local"
+ aaiEnrichmentPort:
+ type: string
+ default: "8443"
+ enableAAIEnrichment:
+ type: string
+ default: "true"
+ dmaap_host:
+ type: string
+ default: "message-router.onap.svc.cluster.local"
+ dmaap_port:
+ type: string
+ default: "3904"
+ enableRedisCaching:
+ type: string
+ default: "false"
+ redisHosts:
+ type: string
+ default: "dcae-redis.onap.svc.cluster.local:6379"
+ tag_version:
+ type: string
+ default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.2.2"
+ consul_host:
+ type: string
+ default: "consul-server.onap"
+ consul_port:
+ type: string
+ default: "8500"
+ cbs_host:
+ type: string
+ default: "config-binding-service"
+ cbs_port:
+ type: string
+ default: "10000"
+ policy_id:
+ type: string
+ default: "onap.restart.tca"
+ external_port:
+ type: string
+ description: Kubernetes node port on which CDAPgui is exposed
+ default: "32012"
+ policy_model_id:
+ type: string
+ default: "onap.policies.monitoring.cdap.tca.hi.lo.app"
+node_templates:
+ tca_k8s:
+ type: dcae.nodes.ContainerizedServiceComponent
+ relationships:
+ - target: tca.policy
+ type: cloudify.relationships.depends_on
+ properties:
+ service_component_type: 'dcaegen2-analytics-tca'
+ application_config: {}
+ docker_config: {}
+ image:
+ get_input: tag_version
+ log_info:
+ log_directory: "/opt/app/TCAnalytics/logs"
+ application_config:
+ app_config:
+ appDescription: DCAE Analytics Threshold Crossing Alert Application
+ appName: dcae-tca
+ tcaAlertsAbatementTableName: TCAAlertsAbatementTable
+ tcaAlertsAbatementTableTTLSeconds: '1728000'
+ tcaSubscriberOutputStreamName: TCASubscriberOutputStream
+ tcaVESAlertsTableName: TCAVESAlertsTable
+ tcaVESAlertsTableTTLSeconds: '1728000'
+ tcaVESMessageStatusTableName: TCAVESMessageStatusTable
+ tcaVESMessageStatusTableTTLSeconds: '86400'
+ thresholdCalculatorFlowletInstances: '2'
+ app_preferences:
+ aaiEnrichmentHost:
+ get_input: aaiEnrichmentHost
+ aaiEnrichmentIgnoreSSLCertificateErrors: 'true'
+ aaiEnrichmentPortNumber: '8443'
+ aaiEnrichmentProtocol: https
+ aaiEnrichmentUserName: dcae@dcae.onap.org
+ aaiEnrichmentUserPassword: demo123456!
+ aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query
+ aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf
+ enableAAIEnrichment:
+ get_input: enableAAIEnrichment
+ enableRedisCaching:
+ get_input: enableRedisCaching
+ redisHosts:
+ get_input: redisHosts
+ enableAlertCEFFormat: 'false'
+ publisherContentType: application/json
+ publisherHostName:
+ get_input: dmaap_host
+ publisherHostPort:
+ get_input: dmaap_port
+ publisherMaxBatchSize: '1'
+ publisherMaxRecoveryQueueSize: '100000'
+ publisherPollingInterval: '20000'
+ publisherProtocol: http
+ publisherTopicName: unauthenticated.DCAE_CL_OUTPUT
+ subscriberConsumerGroup: OpenDCAE-clamp
+ subscriberConsumerId: c12
+ subscriberContentType: application/json
+ subscriberHostName:
+ get_input: dmaap_host
+ subscriberHostPort:
+ get_input: dmaap_port
+ subscriberMessageLimit: '-1'
+ subscriberPollingInterval: '30000'
+ subscriberProtocol: http
+ subscriberTimeoutMS: '-1'
+ subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT
+ #tca.policy: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VM","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"LESS_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"},{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":700,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"vLoadBalancer","controlLoopSchemaType":"VM","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"Measurement_vGMUX","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"GREATER","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]}]}'
+ tca.policy: ''
+ service_component_type: dcaegen2-analytics_tca
+ interfaces:
+ cloudify.interfaces.lifecycle:
+ start:
+ inputs:
+ envs:
+ DMAAPHOST:
+ { get_input: dmaap_host }
+ DMAAPPORT: "3904"
+ DMAAPPUBTOPIC: "unauthenticated.DCAE_CL_OUTPUT"
+ DMAAPSUBTOPIC: "unauthenticated.VES_MEASUREMENT_OUTPUT"
+ AAIHOST:
+ { get_input: aaiEnrichmentHost }
+ AAIPORT: "8443"
+ CONSUL_HOST:
+ { get_input: consul_host }
+ CONSUL_PORT: "8500"
+ CBS_HOST:
+ { get_input: cbs_host }
+ CBS_PORT: "10000"
+ CONFIG_BINDING_SERVICE: "config_binding_service"
+ ports:
+ - concat: ["11011:", { get_input: external_port }]
+ tca.policy:
+ type: clamp.nodes.policy
+ properties:
+ policy_id:
+ get_input: policy_id
+ policy_model_id:
+ get_input: policy_model_id
diff --git a/integration_tests/test_01_vendor.py b/integration_tests/test_01_vendor.py
new file mode 100644
index 0000000..26ede03
--- /dev/null
+++ b/integration_tests/test_01_vendor.py
@@ -0,0 +1,42 @@
+"""Integration test Vendor module."""
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import pytest
+
+import requests
+
+from onapsdk.sdc import SDC
+from onapsdk.sdc.vendor import Vendor
+import onapsdk.constants as const
+
+
+@pytest.mark.integration
+def test_vendor_unknown():
+ """Integration tests for Vendor."""
+ response = requests.post("{}/reset".format(SDC.base_front_url))
+ response.raise_for_status()
+ vendor = Vendor(name="test")
+ vendor.create()
+ assert vendor.created()
+ vendor.submit()
+ assert vendor.status == const.CERTIFIED
+
+@pytest.mark.integration
+def test_vendor_onboard_unknown():
+ """Integration tests for Vendor."""
+ response = requests.post("{}/reset".format(SDC.base_front_url))
+ response.raise_for_status()
+ vendor = Vendor(name="test")
+ vendor.onboard()
+ assert vendor.status == const.CERTIFIED
diff --git a/integration_tests/test_02_vsp.py b/integration_tests/test_02_vsp.py
new file mode 100644
index 0000000..972e78e
--- /dev/null
+++ b/integration_tests/test_02_vsp.py
@@ -0,0 +1,63 @@
+"""Integration test Vendor module."""
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import os
+
+import pytest
+
+import requests
+
+from onapsdk.sdc import SDC
+from onapsdk.sdc.vendor import Vendor
+from onapsdk.sdc.vsp import Vsp
+import onapsdk.constants as const
+
+
+@pytest.mark.integration
+def test_vsp_unknown():
+ """Integration tests for Vsp."""
+ response = requests.post("{}/reset".format(Vendor.base_front_url))
+ response.raise_for_status()
+ vendor = Vendor(name="test")
+ vendor.onboard()
+ vsp = Vsp(name="test")
+ vsp.vendor = vendor
+ vsp.create()
+ assert vsp.identifier is not None
+ assert vsp.status == const.DRAFT
+ vsp.upload_package(open("{}/ubuntu16.zip".format(
+ os.path.dirname(os.path.abspath(__file__))), 'rb'))
+ assert vsp.status == const.UPLOADED
+ vsp.validate()
+ assert vsp.status == const.VALIDATED
+ vsp.commit()
+ assert vsp.status == const.COMMITED
+ vsp.submit()
+ assert vsp.status == const.CERTIFIED
+ vsp.create_csar()
+ assert vsp.csar_uuid is not None
+
+@pytest.mark.integration
+def test_vsp_onboard_unknown():
+ """Integration tests for Vsp."""
+ response = requests.post("{}/reset".format(Vendor.base_front_url))
+ response.raise_for_status()
+ vendor = Vendor(name="test")
+ vendor.onboard()
+ vsp = Vsp(name="test", package=open("{}/ubuntu16.zip".format(
+ os.path.dirname(os.path.abspath(__file__))), 'rb'))
+ vsp.vendor = vendor
+ vsp.onboard()
+ assert vsp.status == const.CERTIFIED
+ assert vsp.csar_uuid is not None
diff --git a/integration_tests/test_03_vf.py b/integration_tests/test_03_vf.py
new file mode 100644
index 0000000..7cad69b
--- /dev/null
+++ b/integration_tests/test_03_vf.py
@@ -0,0 +1,90 @@
+"""Integration test Vendor module."""
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import os
+
+import pytest
+
+import requests
+
+from onapsdk.sdc import SDC
+from onapsdk.sdc.properties import Property
+from onapsdk.sdc.vendor import Vendor
+from onapsdk.sdc.vsp import Vsp
+from onapsdk.sdc.vf import Vf
+import onapsdk.constants as const
+
+
+@pytest.mark.integration
+def test_vf_unknown():
+ """Integration tests for Vf."""
+ response = requests.post("{}/reset".format(Vendor.base_front_url))
+ response.raise_for_status()
+ vendor = Vendor(name="test")
+ vendor.onboard()
+ vsp = Vsp(name="test", package=open("{}/ubuntu16.zip".format(
+ os.path.dirname(os.path.abspath(__file__))), 'rb'))
+ vsp.vendor = vendor
+ vsp.onboard()
+ vf = Vf(name='test')
+ vf.vsp = vsp
+ vf.create()
+ assert vf.identifier is not None
+ assert vf.status == const.DRAFT
+ assert vf.version == "0.1"
+ vf.submit()
+ assert vsp.status == const.CERTIFIED
+ assert vf.version == "1.0"
+ vf.load()
+ assert vsp.status == const.CERTIFIED
+ assert vf.version == "1.0"
+
+@pytest.mark.integration
+def test_vf_onboard_unknown():
+ """Integration tests for Vf."""
+ response = requests.post("{}/reset".format(Vendor.base_front_url))
+ response.raise_for_status()
+ vendor = Vendor(name="test")
+ vendor.onboard()
+ vsp = Vsp(name="test", package=open("{}/ubuntu16.zip".format(
+ os.path.dirname(os.path.abspath(__file__))), 'rb'))
+ vsp.vendor = vendor
+ vsp.onboard()
+ vf = Vf(name='test')
+ vf.vsp = vsp
+ vf.onboard()
+ assert vsp.status == const.CERTIFIED
+ assert vf.version == "1.0"
+
+@pytest.mark.integration
+def test_vf_properties():
+ """Integration test to check properties assignment for Vf."""
+ response = requests.post("{}/reset".format(Vendor.base_front_url))
+ response.raise_for_status()
+ vendor = Vendor(name="test")
+ vendor.onboard()
+ vsp = Vsp(name="test", package=open("{}/ubuntu16.zip".format(
+ os.path.dirname(os.path.abspath(__file__))), 'rb'))
+ vsp.vendor = vendor
+ vsp.onboard()
+ prop = Property(name="test1", property_type="string", value="123")
+ vf = Vf(name="test", vsp=vsp, properties=[
+ prop,
+ Property(name="test2", property_type="integer")],
+ inputs=[prop])
+ vf.onboard()
+ vf_properties = list(vf.properties)
+ vf_inputs = list(vf.inputs)
+ assert len(vf_properties) == 2
+ assert len(vf_inputs) == 1
diff --git a/integration_tests/test_04_service.py b/integration_tests/test_04_service.py
new file mode 100644
index 0000000..80370b0
--- /dev/null
+++ b/integration_tests/test_04_service.py
@@ -0,0 +1,122 @@
+"""Integration test Vendor module."""
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import os
+
+import pytest
+
+import requests
+
+from onapsdk.sdc import SDC
+from onapsdk.sdc.properties import Property
+from onapsdk.sdc.vendor import Vendor
+from onapsdk.sdc.vsp import Vsp
+from onapsdk.sdc.vf import Vf
+from onapsdk.sdc.service import Service
+import onapsdk.constants as const
+
+
+@pytest.mark.integration
+def test_service_unknown():
+ """Integration tests for Service."""
+ response = requests.post("{}/reset".format(SDC.base_front_url))
+ response.raise_for_status()
+ vendor = Vendor(name="test")
+ vendor.onboard()
+ vsp = Vsp(name="test", package=open("{}/ubuntu16.zip".format(
+ os.path.dirname(os.path.abspath(__file__))), 'rb'))
+ vsp.vendor = vendor
+ vsp.onboard()
+ vf = Vf(name='test', vsp=vsp)
+ vf.onboard()
+ svc = Service(name='test')
+ assert svc.identifier is None
+ assert svc.status is None
+ svc.create()
+ assert svc.identifier is not None
+ assert svc.status == const.DRAFT
+ svc.add_resource(vf)
+ svc.checkin()
+ assert svc.status == const.CHECKED_IN
+ svc.certify()
+ assert svc.status == const.CERTIFIED
+ svc.distribute()
+ assert svc.status == const.DISTRIBUTED
+ assert svc.distributed
+
+@pytest.mark.integration
+def test_service_onboard_unknown():
+ """Integration tests for Service."""
+ response = requests.post("{}/reset".format(SDC.base_front_url))
+ response.raise_for_status()
+ vendor = Vendor(name="test")
+ vendor.onboard()
+ vsp = Vsp(name="test", package=open("{}/ubuntu16.zip".format(
+ os.path.dirname(os.path.abspath(__file__))), 'rb'))
+ vsp.vendor = vendor
+ vsp.onboard()
+ vf = Vf(name='test', vsp=vsp)
+ vf.onboard()
+ svc = Service(name='test', resources=[vf])
+ svc.onboard()
+ assert svc.distributed
+
+@pytest.mark.integration
+def test_service_upload_tca_artifact():
+ """Integration tests for Service."""
+ response = requests.post("{}/reset".format(SDC.base_front_url))
+ response.raise_for_status()
+ vendor = Vendor(name="test")
+ vendor.onboard()
+ vsp = Vsp(name="test", package=open("{}/ubuntu16.zip".format(
+ os.path.dirname(os.path.abspath(__file__))), 'rb'))
+ vsp.vendor = vendor
+ vsp.onboard()
+ vf = Vf(name='test', vsp=vsp)
+ vf.onboard()
+ svc = Service(name='test')
+ svc.create()
+ svc.add_resource(vf)
+ assert svc.status == const.DRAFT
+ payload_file = open("{}/tca_clampnode.yaml".format(os.path.dirname(os.path.abspath(__file__))), 'rb')
+ data = payload_file.read()
+ svc.add_artifact_to_vf(vnf_name="test",
+ artifact_type="DCAE_INVENTORY_BLUEPRINT",
+ artifact_name="tca_clampnode.yaml",
+ artifact=data)
+ payload_file.close()
+
+@pytest.mark.integration
+def test_service_properties():
+ """Integration test to check properties assignment for Service."""
+ response = requests.post("{}/reset".format(SDC.base_front_url))
+ response.raise_for_status()
+ vendor = Vendor(name="test")
+ vendor.onboard()
+ vsp = Vsp(name="test", package=open("{}/ubuntu16.zip".format(
+ os.path.dirname(os.path.abspath(__file__))), 'rb'))
+ vsp.vendor = vendor
+ vsp.onboard()
+ vf = Vf(name='test', vsp=vsp)
+ vf.onboard()
+ properties = [
+ Property(name="test1", property_type="string", value="123"),
+ Property(name="test2", property_type="integer")
+ ]
+ svc = Service(name='test', resources=[vf], properties=properties, inputs=[properties[1]])
+ svc.onboard()
+ service_properties = list(svc.properties)
+ service_inputs = list(svc.inputs)
+ assert len(service_properties) == 2
+ assert len(service_inputs) == 1
diff --git a/integration_tests/test_05_cloud_infrastructure.py b/integration_tests/test_05_cloud_infrastructure.py
new file mode 100644
index 0000000..27e3762
--- /dev/null
+++ b/integration_tests/test_05_cloud_infrastructure.py
@@ -0,0 +1,88 @@
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import pytest
+import requests
+
+from onapsdk.aai.cloud_infrastructure import CloudRegion, Complex
+from onapsdk.exceptions import ResourceNotFound
+
+
+@pytest.mark.integration
+def test_cloud_region_get_all():
+ requests.get(f"{CloudRegion.base_url}/reset")
+ cloud_regions = list(CloudRegion.get_all())
+ assert len(cloud_regions) == 0
+
+ with pytest.raises(ResourceNotFound):
+ CloudRegion.get_by_id("test_owner", "test_cloud_region")
+
+ cloud_region: CloudRegion = CloudRegion.create(
+ "test_owner", "test_cloud_region", orchestration_disabled=True, in_maint=False
+ )
+ cloud_regions = list(CloudRegion.get_all())
+ assert len(cloud_regions) == 1
+ cloud_region = cloud_regions[0]
+ assert cloud_region.cloud_owner == "test_owner"
+ assert cloud_region.cloud_region_id == "test_cloud_region"
+
+
+@pytest.mark.integration
+def test_complex_get_all():
+ requests.get(f"{Complex.base_url}/reset")
+ complexes = list(Complex.get_all())
+ assert len(complexes) == 0
+
+ cmplx: Complex = Complex.create(
+ name="test_complex",
+ physical_location_id="test_physical_location_id"
+ )
+ assert cmplx.name == "test_complex"
+ assert cmplx.physical_location_id == "test_physical_location_id"
+
+ complexes = list(Complex.get_all())
+ assert len(complexes) == 1
+
+ cmplx = complexes[0]
+ assert cmplx.name == "test_complex"
+ assert cmplx.physical_location_id == "test_physical_location_id"
+
+
+@pytest.mark.integration
+def test_link_cloud_region_to_complex():
+
+ requests.get(f"{Complex.base_url}/reset")
+
+ cmplx: Complex = Complex.create(
+ name="test_complex",
+ physical_location_id="test_physical_location_id"
+ )
+ cloud_region: CloudRegion = CloudRegion.create(
+ "test_owner", "test_cloud_region", orchestration_disabled=True, in_maint=False
+ )
+
+ assert len(list(cloud_region.relationships)) == 0
+ cloud_region.link_to_complex(cmplx)
+ assert len(list(cloud_region.relationships)) == 1
+
+
+@pytest.mark.integration
+def test_cloud_region_tenants():
+
+ cloud_region: CloudRegion = CloudRegion.create(
+ "test_owner", "test_cloud_region", orchestration_disabled=True, in_maint=False
+ )
+ assert len(list(cloud_region.tenants)) == 0
+ cloud_region.add_tenant(tenant_id="test_tenant_id", tenant_name="test_tenant_name", tenant_context="test_tenant_context")
+ assert len(list(cloud_region.tenants)) == 1
+ tenant = cloud_region.get_tenant(tenant_id="test_tenant_id")
diff --git a/integration_tests/test_06_customer.py b/integration_tests/test_06_customer.py
new file mode 100644
index 0000000..62ac3f0
--- /dev/null
+++ b/integration_tests/test_06_customer.py
@@ -0,0 +1,85 @@
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+from uuid import uuid4
+
+import pytest
+
+import requests
+from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant
+from onapsdk.aai.business import Customer, ServiceSubscription
+from onapsdk.exceptions import ParameterError
+from onapsdk.sdc.service import Service
+
+
+@pytest.mark.integration
+def test_create_customer():
+
+ requests.get(f"{Customer.base_url}/reset")
+
+ customers = list(Customer.get_all())
+ assert len(customers) == 0
+
+ customer = Customer.create(global_customer_id="test_global_customer_id",
+ subscriber_name="test_subscriber_name",
+ subscriber_type="test_subscriber_type")
+ assert customer.global_customer_id == "test_global_customer_id"
+ assert customer.subscriber_name == "test_subscriber_name"
+ assert customer.subscriber_type == "test_subscriber_type"
+
+ customers = list(Customer.get_all())
+ assert len(customers) == 1
+
+
+@pytest.mark.integration
+def test_subscribe_service():
+
+ requests.get(f"{Customer.base_url}/reset")
+
+ customer = Customer.create(global_customer_id="test_global_customer_id",
+ subscriber_name="test_subscriber_name",
+ subscriber_type="test_subscriber_type")
+ assert len(list(customer.service_subscriptions)) == 0
+
+ customer.subscribe_service("service_type")
+ assert len(list(customer.service_subscriptions)) == 1
+ assert customer.get_service_subscription_by_service_type("service_type")
+
+
+@pytest.mark.integration
+def test_link_service_subscription_to_cloud_region_and_tenant():
+
+ requests.get(f"{Customer.base_url}/reset")
+
+ customer = Customer.create(global_customer_id="test_global_customer_id",
+ subscriber_name="test_subscriber_name",
+ subscriber_type="test_subscriber_type")
+ customer.subscribe_service("service_type")
+ service_subscription = customer.get_service_subscription_by_service_type("service_type")
+
+ assert len(list(service_subscription.relationships)) == 0
+ with pytest.raises(ParameterError):
+ service_subscription.cloud_region
+ with pytest.raises(ParameterError):
+ service_subscription.tenant
+
+ cloud_region = CloudRegion.create(
+ "test_owner", "test_cloud_region", orchestration_disabled=True, in_maint=False
+ )
+ cloud_region.add_tenant(
+ tenant_id="test_tenant_name", tenant_name="test_tenant_name", tenant_context="test_tenant_context"
+ )
+ tenant = cloud_region.get_tenant(tenant_id="test_tenant_name")
+ service_subscription.link_to_cloud_region_and_tenant(cloud_region=cloud_region, tenant=tenant)
+ assert service_subscription.cloud_region
+ assert service_subscription.tenant
diff --git a/integration_tests/test_07_instantiation.py b/integration_tests/test_07_instantiation.py
new file mode 100644
index 0000000..c6cbc85
--- /dev/null
+++ b/integration_tests/test_07_instantiation.py
@@ -0,0 +1,427 @@
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import time
+from unittest.mock import MagicMock, PropertyMock, patch
+from uuid import uuid4
+
+import pytest
+import requests
+from onapsdk.exceptions import StatusError
+from onapsdk.aai.business import Customer, ServiceInstance
+from onapsdk.aai.cloud_infrastructure import CloudRegion
+from onapsdk.configuration import settings
+from onapsdk.sdc.service import Service, Vnf, VfModule
+from onapsdk.so.deletion import ServiceDeletionRequest, VfModuleDeletionRequest, VnfDeletionRequest
+from onapsdk.so.instantiation import (ServiceInstantiation, SoService,
+ VfModuleInstantiation, VnfInstantiation, InstantiationParameter,
+ VfmoduleParameters, VnfParameters)
+
+
+@pytest.mark.integration
+def test_a_la_carte_instantiation():
+ requests.get(f"{ServiceInstantiation.base_url}/reset")
+ requests.get(f"{Customer.base_url}/reset")
+ requests.post(f"{ServiceInstantiation.base_url}/set_aai_mock", json={"AAI_MOCK": settings.AAI_URL})
+
+ customer = Customer.create(global_customer_id="test_global_customer_id",
+ subscriber_name="test_subscriber_name",
+ subscriber_type="test_subscriber_type")
+ service = Service("test_service")
+ service.unique_uuid = str(uuid4())
+ service.identifier = str(uuid4())
+ service.name = str(uuid4())
+ customer.subscribe_service("service_type")
+ service_subscription = customer.get_service_subscription_by_service_type("service_type")
+ cloud_region = CloudRegion.create(
+ "test_owner", "test_cloud_region", orchestration_disabled=True, in_maint=False
+ )
+ cloud_region.add_tenant(
+ tenant_id="test_tenant_name", tenant_name="test_tenant_name", tenant_context="test_tenant_context"
+ )
+ tenant = cloud_region.get_tenant(tenant_id="test_tenant_name")
+ service_subscription.link_to_cloud_region_and_tenant(cloud_region=cloud_region, tenant=tenant)
+ owning_entity = "test_owning_entity"
+ project = "test_project"
+
+ # Service instantiation
+ service._distributed = True
+ assert len(list(service_subscription.service_instances)) == 0
+ service_instantiation_request = ServiceInstantiation.instantiate_ala_carte(
+ service,
+ cloud_region,
+ tenant,
+ customer,
+ owning_entity,
+ project,
+ service_subscription
+ )
+ assert service_instantiation_request.status == ServiceInstantiation.StatusEnum.IN_PROGRESS
+ time.sleep(2) # After 1 second mocked server changed request status to complete
+ assert service_instantiation_request.status == ServiceInstantiation.StatusEnum.COMPLETED
+ assert len(list(service_subscription.service_instances)) == 1
+
+ # Vnf instantiation
+ service_instance = next(service_subscription.service_instances)
+ assert len(list(service_instance.vnf_instances)) == 0
+ owning_entity = "test_owning_entity"
+ project = "test_project"
+ vnf = MagicMock()
+ line_of_business = "test_line_of_business"
+ platform = "test_platform"
+ with pytest.raises(StatusError):
+ service_instance.add_vnf(
+ vnf,
+ line_of_business,
+ platform
+ )
+ service_instance.orchestration_status = "Active"
+ service_instance._sdc_service = service
+ with patch.object(ServiceInstance, "sdc_service", return_value=service):
+ vnf_instantiation_request = service_instance.add_vnf(
+ vnf,
+ line_of_business,
+ platform
+ )
+ assert vnf_instantiation_request.status == VnfInstantiation.StatusEnum.IN_PROGRESS
+ time.sleep(2) # After 1 second mocked server changed request status to complete
+ assert vnf_instantiation_request.status == VnfInstantiation.StatusEnum.COMPLETED
+ assert len(list(service_instance.vnf_instances)) == 1
+ # VfModule instantiation
+ vnf_instance = next(service_instance.vnf_instances)
+ assert len(list(vnf_instance.vf_modules)) == 0
+ vnf.model_version_id = vnf_instance.model_version_id
+ vf_module = MagicMock()
+
+ with patch.object(ServiceInstance, "sdc_service", return_value=service) as service_mock:
+ service_mock.vnfs = [vnf]
+ vf_module_instantiation_request = vnf_instance.add_vf_module(
+ vf_module
+ )
+ assert vf_module_instantiation_request.status == VfModuleInstantiation.StatusEnum.IN_PROGRESS
+ time.sleep(2) # After 1 second mocked server changed request status to complete
+ assert vf_module_instantiation_request.status == VfModuleInstantiation.StatusEnum.COMPLETED
+ assert len(list(vnf_instance.vf_modules)) == 1
+
+ # Cleanup
+ vf_module_instance = next(vnf_instance.vf_modules)
+ vf_module_deletion_request = vf_module_instance.delete()
+ assert vf_module_deletion_request.status == VfModuleDeletionRequest.StatusEnum.IN_PROGRESS
+ time.sleep(2) # After 1 second mocked server changed request status to complete
+ assert vf_module_deletion_request.status == VfModuleDeletionRequest.StatusEnum.COMPLETED
+ assert len(list(vnf_instance.vf_modules)) == 0
+
+ vnf_deletion_request = vnf_instance.delete()
+ assert vnf_deletion_request.status == VnfDeletionRequest.StatusEnum.IN_PROGRESS
+ time.sleep(2) # After 1 second mocked server changed request status to complete
+ assert vnf_deletion_request.status == VnfDeletionRequest.StatusEnum.COMPLETED
+ assert len(list(service_instance.vnf_instances)) == 0
+
+ with patch.object(ServiceInstance, "sdc_service", return_value=service) as service_mock:
+ service_deletion_request = service_instance.delete()
+ assert service_deletion_request.status == ServiceDeletionRequest.StatusEnum.IN_PROGRESS
+ time.sleep(2) # After 1 second mocked server changed request status to complete
+ assert service_deletion_request.status == ServiceDeletionRequest.StatusEnum.COMPLETED
+ assert len(list(service_subscription.service_instances)) == 0
+
+
+@pytest.mark.integration
+def test_a_la_carte_vl_instantiation():
+ requests.get(f"{ServiceInstantiation.base_url}/reset")
+ requests.get(f"{Customer.base_url}/reset")
+ requests.post(f"{ServiceInstantiation.base_url}/set_aai_mock", json={"AAI_MOCK": settings.AAI_URL})
+
+ customer = Customer.create(global_customer_id="test_global_customer_id",
+ subscriber_name="test_subscriber_name",
+ subscriber_type="test_subscriber_type")
+ service = Service("test_service")
+ service.unique_uuid = str(uuid4())
+ service.identifier = str(uuid4())
+ service.name = str(uuid4())
+ customer.subscribe_service("service_type")
+ service_subscription = customer.get_service_subscription_by_service_type("service_type")
+ cloud_region = CloudRegion.create(
+ "test_owner", "test_cloud_region", orchestration_disabled=True, in_maint=False
+ )
+ cloud_region.add_tenant(
+ tenant_id="test_tenant_name", tenant_name="test_tenant_name", tenant_context="test_tenant_context"
+ )
+ tenant = cloud_region.get_tenant(tenant_id="test_tenant_name")
+ service_subscription.link_to_cloud_region_and_tenant(cloud_region=cloud_region, tenant=tenant)
+ owning_entity = "test_owning_entity"
+ project = "test_project"
+
+ # Service instantiation
+ service._distributed = True
+ assert len(list(service_subscription.service_instances)) == 0
+ service_instantiation_request = ServiceInstantiation.instantiate_ala_carte(
+ service,
+ cloud_region,
+ tenant,
+ customer,
+ owning_entity,
+ project,
+ service_subscription
+ )
+ assert service_instantiation_request.status == ServiceInstantiation.StatusEnum.IN_PROGRESS
+ service_instantiation_request.wait_for_finish()
+ assert service_instantiation_request.status == ServiceInstantiation.StatusEnum.COMPLETED
+ assert len(list(service_subscription.service_instances)) == 1
+
+ # Network instantiation
+ service_instance = next(service_subscription.service_instances)
+ assert len(list(service_instance.network_instances)) == 0
+ owning_entity = "test_owning_entity"
+ project = "test_project"
+ network = MagicMock()
+ line_of_business = "test_line_of_business"
+ platform = "test_platform"
+ with pytest.raises(AttributeError):
+ service_instance.network(
+ network,
+ line_of_business,
+ platform
+ )
+ service_instance.orchestration_status = "Active"
+ with patch.object(ServiceInstance, "sdc_service", return_value=service):
+ network_instantiation_request = service_instance.add_network(
+ network,
+ line_of_business,
+ platform
+ )
+ assert network_instantiation_request.status == VnfInstantiation.StatusEnum.IN_PROGRESS
+ network_instantiation_request.wait_for_finish()
+ assert network_instantiation_request.status == VnfInstantiation.StatusEnum.COMPLETED
+ assert len(list(service_instance.network_instances)) == 1
+
+
+@patch.object(Service, "vnfs", new_callable=PropertyMock)
+@patch.object(Service, "components", new_callable=PropertyMock)
+@pytest.mark.integration
+def test_instantiate_macro(mock_service_components, mock_service_vnfs):
+ requests.get(f"{ServiceInstantiation.base_url}/reset")
+ requests.get(f"{Customer.base_url}/reset")
+ requests.post(f"{ServiceInstantiation.base_url}/set_aai_mock", json={"AAI_MOCK": settings.AAI_URL})
+
+ customer = Customer.create(global_customer_id="test_global_customer_id",
+ subscriber_name="test_subscriber_name",
+ subscriber_type="test_subscriber_type")
+ service = Service("test_service")
+ service._tosca_template = "n/a"
+
+ mock_service_vnfs.return_value = [
+ Vnf(
+ name="test_vnf",
+ node_template_type="vf",
+ model_name= "test_vnf_model",
+ model_version_id = str(uuid4()),
+ model_invariant_id=str(uuid4()),
+ model_version="1.0",
+ model_customization_id=str(uuid4()),
+ model_instance_name=str(uuid4()),
+ component=MagicMock(),
+ vf_modules=[
+ VfModule(
+ name="TestVnfModel..base..module-0",
+ group_type="vf-module",
+ model_name="TestVnfModel..base..module-0",
+ model_version_id=str(uuid4()),
+ model_invariant_uuid=str(uuid4()),
+ model_version="1",
+ model_customization_id=str(uuid4()),
+ properties=None
+ )
+ ]
+ )
+ ]
+ service.unique_uuid = str(uuid4())
+ service.identifier = str(uuid4())
+ service.name = str(uuid4())
+ customer.subscribe_service("service_type")
+ service_subscription = customer.get_service_subscription_by_service_type("service_type")
+ cloud_region = CloudRegion.create(
+ "test_owner", "test_cloud_region", orchestration_disabled=True, in_maint=False
+ )
+ cloud_region.add_tenant(
+ tenant_id="test_tenant_name", tenant_name="test_tenant_name", tenant_context="test_tenant_context"
+ )
+ tenant = cloud_region.get_tenant(tenant_id="test_tenant_name")
+ service_subscription.link_to_cloud_region_and_tenant(cloud_region=cloud_region, tenant=tenant)
+ owning_entity = "test_owning_entity"
+ project = "test_project"
+ line_of_business = "test_line_of_business"
+ platform = "test_platform"
+
+ vfm_instance_params = [
+ InstantiationParameter(name="vfm_param", value="vfm_param_value"),
+
+ ]
+ vfm_params = VfmoduleParameters("base", vfm_instance_params)
+
+ vnf_instance_params = [
+ InstantiationParameter(name="vnf_param", value="vnf_param_value")
+ ]
+
+ vnf_params = VnfParameters("test_vnf_model", vnf_instance_params, [vfm_params])
+
+ # Service instantiation
+ service._distributed = True
+ assert len(list(service_subscription.service_instances)) == 0
+ service_instantiation_request = ServiceInstantiation.instantiate_macro(
+ sdc_service=service,
+ customer=customer,
+ owning_entity=owning_entity,
+ project=project,
+ line_of_business=line_of_business,
+ platform=platform,
+ cloud_region=cloud_region,
+ tenant=tenant,
+ vnf_parameters=[vnf_params],
+ service_subscription=service_subscription
+ )
+ assert service_instantiation_request.status == ServiceInstantiation.StatusEnum.IN_PROGRESS
+ time.sleep(2) # After 1 second mocked server changed request status to complete
+ assert service_instantiation_request.status == ServiceInstantiation.StatusEnum.COMPLETED
+ assert len(list(service_subscription.service_instances)) == 1
+ service_instance = next(service_subscription.service_instances)
+
+ # Cleanup
+ with patch.object(ServiceInstance, "sdc_service", return_value=service) as service_mock:
+ service_deletion_request = service_instance.delete()
+ assert service_deletion_request.status == ServiceDeletionRequest.StatusEnum.IN_PROGRESS
+ time.sleep(2) # After 1 second mocked server changed request status to complete
+ assert service_deletion_request.status == ServiceDeletionRequest.StatusEnum.COMPLETED
+ assert len(list(service_subscription.service_instances)) == 0
+
+@patch.object(Service, "vnfs", new_callable=PropertyMock)
+@patch.object(Service, "components", new_callable=PropertyMock)
+@pytest.mark.integration
+def test_instantiate_macro_multiple_vnf(mock_service_components, mock_service_vnfs):
+ requests.get(f"{ServiceInstantiation.base_url}/reset")
+ requests.get(f"{Customer.base_url}/reset")
+ requests.post(f"{ServiceInstantiation.base_url}/set_aai_mock", json={"AAI_MOCK": settings.AAI_URL})
+
+ customer = Customer.create(global_customer_id="test_global_customer_id",
+ subscriber_name="test_subscriber_name",
+ subscriber_type="test_subscriber_type")
+ service = Service("test_service")
+ service._tosca_template = "n/a"
+
+ mock_service_vnfs.return_value = [
+ Vnf(
+ name="test_vnf",
+ node_template_type="vf",
+ model_name= "test_vnf_model",
+ model_version_id = str(uuid4()),
+ model_invariant_id=str(uuid4()),
+ model_version="1.0",
+ model_customization_id=str(uuid4()),
+ model_instance_name=str(uuid4()),
+ component=MagicMock(),
+ vf_modules=[
+ VfModule(
+ name="TestVnfModel..base..module-0",
+ group_type="vf-module",
+ model_name="TestVnfModel..base..module-0",
+ model_version_id=str(uuid4()),
+ model_invariant_uuid=str(uuid4()),
+ model_version="1",
+ model_customization_id=str(uuid4()),
+ properties=None
+ )
+ ]
+ )
+ ]
+ service.unique_uuid = str(uuid4())
+ service.identifier = str(uuid4())
+ service.name = str(uuid4())
+ customer.subscribe_service("service_type")
+ service_subscription = customer.get_service_subscription_by_service_type("service_type")
+ cloud_region = CloudRegion.create(
+ "test_owner", "test_cloud_region", orchestration_disabled=True, in_maint=False
+ )
+ cloud_region.add_tenant(
+ tenant_id="test_tenant_name", tenant_name="test_tenant_name", tenant_context="test_tenant_context"
+ )
+ tenant = cloud_region.get_tenant(tenant_id="test_tenant_name")
+ service_subscription.link_to_cloud_region_and_tenant(cloud_region=cloud_region, tenant=tenant)
+ owning_entity = "test_owning_entity"
+ project = "test_project"
+ line_of_business = "test_line_of_business"
+ platform = "test_platform"
+
+ so_service = SoService.load({
+ "subscription_service_type": "service_type",
+ "vnfs": [
+ {
+ "model_name": "test_vnf_model",
+ "instance_name": "vnf0",
+ "parameters": {
+ "param1": "value1"
+ },
+ "vf_modules": [
+ {
+ "instance_name": "vnf0_vfm0",
+ "model_name": "base",
+ "parameters": {
+ "vfm_param1": "vfm_value1"
+ }
+ }
+ ]
+ },
+ {
+ "model_name": "test_vnf_model",
+ "instance_name": "vnf1",
+ "parameters": {
+ "param2": "value2"
+ },
+ "vf_modules": [
+ {
+ "instance_name": "vnf1_vfm0",
+ "model_name": "base",
+ "parameters": {
+ "vfm_param2": "vfm_value2"
+ }
+ }
+ ]
+ }
+ ]
+ })
+
+ # Service instantiation
+ service._distributed = True
+ assert len(list(service_subscription.service_instances)) == 0
+ service_instantiation_request = ServiceInstantiation.instantiate_macro(
+ sdc_service=service,
+ customer=customer,
+ owning_entity=owning_entity,
+ project=project,
+ line_of_business=line_of_business,
+ platform=platform,
+ cloud_region=cloud_region,
+ tenant=tenant,
+ so_service=so_service
+ )
+ assert service_instantiation_request.status == ServiceInstantiation.StatusEnum.IN_PROGRESS
+ time.sleep(2) # After 1 second mocked server changed request status to complete
+ assert service_instantiation_request.status == ServiceInstantiation.StatusEnum.COMPLETED
+ assert len(list(service_subscription.service_instances)) == 1
+ service_instance = next(service_subscription.service_instances)
+
+ # Cleanup
+ with patch.object(ServiceInstance, "sdc_service", return_value=service) as service_mock:
+ service_deletion_request = service_instance.delete()
+ assert service_deletion_request.status == ServiceDeletionRequest.StatusEnum.IN_PROGRESS
+ time.sleep(2) # After 1 second mocked server changed request status to complete
+ assert service_deletion_request.status == ServiceDeletionRequest.StatusEnum.COMPLETED
+ assert len(list(service_subscription.service_instances)) == 0
diff --git a/integration_tests/test_08_cds.py b/integration_tests/test_08_cds.py
new file mode 100644
index 0000000..3d75f37
--- /dev/null
+++ b/integration_tests/test_08_cds.py
@@ -0,0 +1,65 @@
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import os
+import pytest
+import requests
+
+from tempfile import TemporaryDirectory
+
+from onapsdk.configuration import settings
+from onapsdk.cds.blueprint import Blueprint
+from onapsdk.cds.data_dictionary import DataDictionary, DataDictionarySet
+
+
+@pytest.mark.integration
+def test_cds_connection():
+
+ TEST_DD_PATH = os.path.join(os.getcwd(), "integration_tests/test_files/test_dd.json")
+ TEST_CBA_PATH = os.path.join(os.getcwd(), "integration_tests/test_files/test_vLB_CBA_Python.zip")
+
+
+ # Endpoint availability
+ response = requests.post("{}/api/v1/dictionary".format(settings.CDS_URL))
+ assert response.status_code == 200
+
+ response = requests.post("{}/api/v1/blueprint-model/enrich".format(settings.CDS_URL))
+ assert response.status_code == 200
+
+ response = requests.post("{}/api/v1/blueprint-model/publish".format(settings.CDS_URL))
+ assert response.status_code == 200
+
+
+ # Reads from the file system
+ dd_set = DataDictionarySet.load_from_file(TEST_DD_PATH, True)
+ blueprint = Blueprint.load_from_file(TEST_CBA_PATH)
+
+
+ # Connection availability between CDS API and Blueprint/DataDictionarySet
+ dd_set.upload()
+ assert type(blueprint.cba_file_bytes) == bytes
+
+ for dd in dd_set.dd_set:
+ dd_obj = DataDictionary.get_by_name(dd.name)
+ assert dd_obj == dd
+
+ blueprint = blueprint.enrich()
+ assert type(blueprint.cba_file_bytes) == bytes
+
+ blueprint.publish()
+
+
+ # Writes to the file system
+ with TemporaryDirectory() as tmpdirname:
+ path = os.path.join(tmpdirname, "test-CBA-enriched.zip")
+ blueprint.save(path)
diff --git a/integration_tests/test_09_clamp.py b/integration_tests/test_09_clamp.py
new file mode 100644
index 0000000..f745e2f
--- /dev/null
+++ b/integration_tests/test_09_clamp.py
@@ -0,0 +1,78 @@
+"""Integration test Clamp module."""
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import os
+
+import pytest
+
+import requests
+
+from onapsdk.sdc.service import Service
+from onapsdk.clamp.clamp_element import Clamp
+from onapsdk.clamp.loop_instance import LoopInstance
+
+@pytest.mark.integration
+def test_Clamp_requirements():
+ """Integration tests for Clamp."""
+ requests.get("{}/reset".format(Clamp._base_url))
+ # no add resource in clamp
+ # svc already exists in mock clamp
+ Clamp()
+ svc = Service(name="service01")
+ template_exists = Clamp.check_loop_template(service=svc)
+ assert template_exists
+ policy_exists = Clamp.check_policies(policy_name="MinMax",
+ req_policies=2)
+ assert policy_exists
+
+@pytest.mark.integration
+def test_Loop_creation():
+ """Integration tests for Loop Instance."""
+ requests.get("{}/reset".format(Clamp._base_url))
+ Clamp()
+ svc = Service(name="service01")
+ loop_template = Clamp.check_loop_template(service=svc)
+ response = requests.post("{}/reset".format(Clamp._base_url))
+ response.raise_for_status()
+ loop = LoopInstance(template=loop_template, name="instance01", details={})
+ loop.create()
+
+@pytest.mark.integration
+def test_Loop_customization():
+ """Integration tests for Loop Instance."""
+ requests.get("{}/reset".format(Clamp._base_url))
+ Clamp()
+ svc = Service(name="service01")
+ loop_template = Clamp.check_loop_template(service=svc)
+ response = requests.post("{}/reset".format(Clamp._base_url))
+ response.raise_for_status()
+ loop = LoopInstance(template=loop_template, name="instance01", details={})
+ loop.create()
+ loop.update_microservice_policy()
+ #add op policy FrequencyLimiter that already exists in clamp
+ loop.add_operational_policy(policy_type="onap.policies.controlloop.guard.common.FrequencyLimiter",
+ policy_version="1.0.0")
+ #only frequency configuration is available in mock clamp
+ loop.add_op_policy_config(loop.add_frequency_limiter, limit=1)
+ submit = loop.act_on_loop_policy(loop.submit)
+ assert submit
+ stop = loop.act_on_loop_policy(loop.stop)
+ assert stop
+ restart = loop.act_on_loop_policy(loop.restart)
+ assert restart
+ deploy = loop.deploy_microservice_to_dcae()
+ assert deploy
+ loop.undeploy_microservice_from_dcae()
+ new_details = loop._update_loop_details()
+ assert new_details["components"]["DCAE"]["componentState"]["stateName"] == "MICROSERVICE_UNINSTALLED_SUCCESSFULLY"
diff --git a/integration_tests/test_10_msb_k8s.py b/integration_tests/test_10_msb_k8s.py
new file mode 100644
index 0000000..5b2c0ee
--- /dev/null
+++ b/integration_tests/test_10_msb_k8s.py
@@ -0,0 +1,125 @@
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import logging
+import os
+
+import pytest
+
+from onapsdk.msb.k8s import (
+ Definition,
+ Instance,
+ ConnectivityInfo)
+
+logger = logging.getLogger("")
+logger.setLevel(logging.DEBUG)
+fh = logging.StreamHandler()
+fh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s')
+fh.setFormatter(fh_formatter)
+logger.addHandler(fh)
+
+RB_NAME = "test_definition"
+RB_VERSION = "ver_1"
+PROFILE_NAME = "test-profile"
+PROFILE_NAMESPACE = "test"
+PROFILE_K8S_VERSION = "1.0"
+PROFILE_ARTIFACT_PATH = "artifacts\\profile.tar.gz" # FILL ME
+TEMPLATE_NAME = "test_template"
+TEMPLATE_DESCRIPTION = "test description"
+CLOUD_REGION_ID = "k8s_region_test" # FILL ME
+CLOUD_OWNER = "CloudOwner"
+KUBECONFIG_PATH = "artifacts\\kubeconfig" # FILL ME
+MYPATH = os.path.dirname(os.path.realpath(__file__))
+
+pytest.INSTANCE_ID = ""
+
+
+@pytest.mark.integration
+def test_definition_create_upload_artifact():
+ definition = Definition.create(RB_NAME, RB_VERSION)
+ definition.upload_artifact(b'definition_artifact_file')
+
+
+@pytest.mark.integration
+def test_definition_get_all():
+ definitions = list(Definition.get_all())
+
+
+@pytest.mark.integration
+def test_configuration_template():
+ definition = Definition.get_definition_by_name_version(RB_NAME,
+ RB_VERSION)
+ definition.create_configuration_template(TEMPLATE_NAME, TEMPLATE_DESCRIPTION)
+ definition.get_all_configuration_templates()
+ definition.get_configuration_template_by_name(TEMPLATE_NAME)
+
+
+@pytest.mark.integration
+def test_profile_create_upload_artifact():
+ definition = Definition.get_definition_by_name_version(RB_NAME,
+ RB_VERSION)
+ profile = definition.create_profile(PROFILE_NAME,
+ PROFILE_NAMESPACE,
+ PROFILE_K8S_VERSION)
+ profile.upload_artifact(b'profile_artifact_file')
+
+
+@pytest.mark.integration
+def test_profile_get_all():
+ definition = Definition.get_definition_by_name_version(RB_NAME,
+ RB_VERSION)
+ profiles = list(definition.get_all_profiles())
+
+
+@pytest.mark.integration
+def test_connectivity_info_create():
+ conninfo = ConnectivityInfo.create(CLOUD_REGION_ID,
+ CLOUD_OWNER,
+ b'kubeconfig_content_test')
+
+
+@pytest.mark.integration
+def test_instance_create():
+ definition = Definition.get_definition_by_name_version(RB_NAME,
+ RB_VERSION)
+ profile = definition.get_profile_by_name(PROFILE_NAME)
+ instance = Instance.create(CLOUD_REGION_ID,
+ profile.profile_name,
+ definition.rb_name,
+ definition.rb_version)
+ pytest.INSTANCE_ID = instance.instance_id
+
+
+@pytest.mark.integration
+def test_instance_get_all():
+ instances = list(Instance.get_all())
+
+
+@pytest.mark.integration
+def test_instance_delete():
+ instance = Instance.get_by_id(pytest.INSTANCE_ID)
+ instance.delete()
+
+
+@pytest.mark.integration
+def test_connectivity_info_delete():
+ conninfo = ConnectivityInfo.get_connectivity_info_by_region_id(CLOUD_REGION_ID)
+ conninfo.delete()
+
+
+@pytest.mark.integration
+def test_definition_profile_get_delete():
+ definition = Definition.get_definition_by_name_version(RB_NAME, RB_VERSION)
+ profile = definition.get_profile_by_name(PROFILE_NAME)
+ profile.delete()
+ definition.delete()
diff --git a/integration_tests/test_11_ves.py b/integration_tests/test_11_ves.py
new file mode 100644
index 0000000..5553176
--- /dev/null
+++ b/integration_tests/test_11_ves.py
@@ -0,0 +1,109 @@
+# Copyright 2022 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import pytest
+import logging
+import os
+import requests
+
+from onapsdk.configuration import settings
+from onapsdk.utils.jinja import jinja_env
+from onapsdk.ves.ves import Ves
+from onapsdk.dmaap.dmaap import Dmaap
+
+logging.basicConfig(level=os.environ.get("LOGLEVEL", "DEBUG"))
+
+
+def reset_dmaap_mock():
+ requests.get("{}/reset".format(settings.DMAAP_URL))
+
+
+@pytest.mark.integration
+def test_should_send_event_to_ves():
+ # given
+
+ requests.post("{}/set_dmaap_address".format(settings.VES_URL), json={"DMAAP_MOCK": settings.DMAAP_URL})
+ event: str = jinja_env().get_template("ves_stnd_event.json.j2").render()
+
+ # when
+ response = Ves.send_event(
+ basic_auth={'username': 'sample1', 'password': 'sample1'},
+ json_event=event,
+ version="v7"
+ )
+
+ # then
+ assert response.status_code == 202
+
+
+@pytest.mark.integration
+def test_should_send_batch_event_to_ves():
+ # given
+
+ requests.post("{}/set_dmaap_address".format(settings.VES_URL), json={"DMAAP_MOCK": settings.DMAAP_URL})
+ event: str = jinja_env().get_template("ves7_batch_with_stndDefined_valid.json.j2").render()
+
+ # when
+ response = Ves.send_batch_event(
+ basic_auth={'username': 'sample1', 'password': 'sample1'},
+ json_event=event,
+ version="v7"
+ )
+
+ # then
+ assert response.status_code == 202
+
+
+@pytest.mark.integration
+def test_should_send_event_to_ves_and_dmaap():
+ # given
+
+ requests.post("{}/set_dmaap_address".format(settings.VES_URL), json={"DMAAP_MOCK": settings.DMAAP_URL})
+ event: str = jinja_env().get_template("ves_stnd_event.json.j2").render()
+
+ # when
+ reset_dmaap_mock()
+ response = Ves.send_event(
+ basic_auth={'username': 'sample1', 'password': 'sample1'},
+ json_event=event,
+
+ version="v7"
+ )
+
+ # then
+ assert response.status_code == 202
+ events = Dmaap.get_events_for_topic("fault",
+ basic_auth={'username': 'dcae@dcae.onap.org', 'password': 'demo123456!'})
+ assert len(events) == 1
+
+
+@pytest.mark.integration
+def test_should_send_batch_event_to_ves_and_dmaap():
+ # given
+
+ requests.post("{}/set_dmaap_address".format(settings.VES_URL), json={"DMAAP_MOCK": settings.DMAAP_URL})
+ event: str = jinja_env().get_template("ves7_batch_with_stndDefined_valid.json.j2").render()
+
+ # when
+ reset_dmaap_mock()
+ response = Ves.send_batch_event(
+ basic_auth={'username': 'sample1', 'password': 'sample1'},
+ json_event=event,
+ version="v7"
+ )
+
+ # then
+ assert response.status_code == 202
+ events = Dmaap.get_events_for_topic("fault",
+ basic_auth={'username': 'dcae@dcae.onap.org', 'password': 'demo123456!'})
+ assert len(events) == 2
diff --git a/integration_tests/test_12_dmaap.py b/integration_tests/test_12_dmaap.py
new file mode 100644
index 0000000..a3e9247
--- /dev/null
+++ b/integration_tests/test_12_dmaap.py
@@ -0,0 +1,31 @@
+# Copyright 2022 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import pytest
+import logging
+import os
+
+from onapsdk.dmaap.dmaap import Dmaap
+
+logging.basicConfig(level=os.environ.get("LOGLEVEL", "DEBUG"))
+
+
+@pytest.mark.integration
+def test_should_get_all_topics_from_dmaap():
+ # given
+
+ # when
+ response = Dmaap.get_all_topics(basic_auth={'username': 'demo', 'password': 'demo123456!'})
+
+ # then
+ assert len(response) == 9
diff --git a/integration_tests/test_files/test_dd.json b/integration_tests/test_files/test_dd.json
new file mode 100644
index 0000000..26f0b90
--- /dev/null
+++ b/integration_tests/test_files/test_dd.json
@@ -0,0 +1,48 @@
+[
+ {
+ "name": "vpg_int_pktgen_private_ip_0",
+ "tags": "vpg_int_pktgen_private_ip_0",
+ "data_type": "string",
+ "description": "vpg_int_pktgen_private_ip_0",
+ "entry_schema": "string",
+ "updatedBy": "Singal, Kapil <ks220y@att.com>",
+ "definition": {
+ "tags": "vpg_int_pktgen_private_ip_0",
+ "name": "vpg_int_pktgen_private_ip_0",
+ "property": {
+ "description": "vpg_int_pktgen_private_ip_0",
+ "type": "string"
+ },
+ "updated-by": "Singal, Kapil <ks220y@att.com>",
+ "sources": {
+ "input": {
+ "type": "source-input"
+ },
+ "default": {
+ "type": "source-default",
+ "properties": {}
+ },
+ "sdnc": {
+ "type": "source-rest",
+ "properties": {
+ "verb": "GET",
+ "type": "JSON",
+ "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vpg_int_pktgen_private_ip_0",
+ "path": "/param/0/value",
+ "input-key-mapping": {
+ "service-instance-id": "service-instance-id",
+ "vnf-id": "vnf-id"
+ },
+ "output-key-mapping": {
+ "vpg_int_pktgen_private_ip_0": "value"
+ },
+ "key-dependencies": [
+ "service-instance-id",
+ "vnf-id"
+ ]
+ }
+ }
+ }
+ }
+ }
+]
diff --git a/integration_tests/test_files/test_vLB_CBA_Python.zip b/integration_tests/test_files/test_vLB_CBA_Python.zip
new file mode 100644
index 0000000..ddd41ac
--- /dev/null
+++ b/integration_tests/test_files/test_vLB_CBA_Python.zip
Binary files differ
diff --git a/integration_tests/ubuntu16.zip b/integration_tests/ubuntu16.zip
new file mode 100644
index 0000000..9a98baa
--- /dev/null
+++ b/integration_tests/ubuntu16.zip
Binary files differ
diff --git a/integration_tests/urls.py b/integration_tests/urls.py
new file mode 100644
index 0000000..2d6b11e
--- /dev/null
+++ b/integration_tests/urls.py
@@ -0,0 +1,23 @@
+# Copyright 2022 Orange, Deutsche Telekom AG
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+SDC_BE_URL = "http://sdc.api.fe.simpledemo.onap.org:30206"
+SDC_FE_URL = "http://sdc.api.fe.simpledemo.onap.org:30206"
+AAI_URL = "http://aai.api.sparky.simpledemo.onap.org:5000"
+SO_URL = "http://so.api.simpledemo.onap.org:5001"
+SDNC_URL = "http://sdnc.api.simpledemo.onap.org:5002"
+CLAMP_URL = "http://clamp.api.simpledemo.onap.org:30258"
+CDS_URL = "http://cds.api.simpledemo.onap.org:8080"
+MSB_URL = "http://msb.k8s.api.simpledemo.onap.org:5003"
+VES_URL = "http://ves.api.simpledemo.onap.org:30417"
+DMAAP_URL = "http://dmaap.api.simpledemo.onap.org:3904"