diff options
-rw-r--r-- | lcm/ns/tests/test_sol_ns_instances_api.py | 26 | ||||
-rw-r--r-- | lcm/ns/tests/test_sol_ns_instantiate_api.py | 117 | ||||
-rw-r--r-- | lcm/ns/tests/test_sol_ns_terminate_api.py | 2 |
3 files changed, 144 insertions, 1 deletions
diff --git a/lcm/ns/tests/test_sol_ns_instances_api.py b/lcm/ns/tests/test_sol_ns_instances_api.py index bf207702..242c2e80 100644 --- a/lcm/ns/tests/test_sol_ns_instances_api.py +++ b/lcm/ns/tests/test_sol_ns_instances_api.py @@ -65,6 +65,32 @@ class TestNsInstanceApi(TestCase): return response.data['id'] @mock.patch.object(restcall, 'call_req') + def test_create_ns_cpe(self, mock_call_req): + nspackage_info = { + "csarId": "c9f0a95e-dea0-4698-96e5-5a79bc5a233d", + "packageInfo": { + "nsPackageId": "c9f0a95e-dea0-4698-96e5-5a79bc5a233d", + "nsdId": "c9f0a95e-dea0-4698-96e5-5a79bc5a233d" + } + } + r1_query_nspackage_from_catalog = [0, json.JSONEncoder().encode(nspackage_info), '201'] + r2_create_ns_to_aai = [0, json.JSONEncoder().encode({}), '201'] + mock_call_req.side_effect = [r1_query_nspackage_from_catalog, r2_create_ns_to_aai] + + header = { + 'HTTP_GLOBALCUSTOMERID': 'global-customer-id-test1', + 'HTTP_SERVICETYPE': 'service-type-test1' + } + + data = { + "nsdId": "c9f0a95e-dea0-4698-96e5-5a79bc5a233d", + "nsName": "vcpe_e2e_vnf_test2", + "nsDescription": "null" + } + response = self.apiClient.post(self.ns_instances_url, data=data, format=self.format, **header) + self.failUnlessEqual(status.HTTP_201_CREATED, response.status_code) + + @mock.patch.object(restcall, 'call_req') def test_create_ns_when_ns_name_exist(self, mock_call_req): NSInstModel.objects.all().delete() NSInstModel(id="1", name="ns").save() diff --git a/lcm/ns/tests/test_sol_ns_instantiate_api.py b/lcm/ns/tests/test_sol_ns_instantiate_api.py index 37e9eda6..dfb296d1 100644 --- a/lcm/ns/tests/test_sol_ns_instantiate_api.py +++ b/lcm/ns/tests/test_sol_ns_instantiate_api.py @@ -366,3 +366,120 @@ class TestInstantiateNsApi(TestCase): self.failUnlessEqual(status.HTTP_405_METHOD_NOT_ALLOWED, response.status_code) response = self.client.get(self.url % '1', data=self.req_data, format='json') self.failUnlessEqual(status.HTTP_405_METHOD_NOT_ALLOWED, response.status_code) + + @mock.patch.object(restcall, 'call_req') + @mock.patch('lcm.pub.msapi.sdc_run_catalog.parse_nsd', MagicMock(return_value=nsd_model)) + @mock.patch.object(BuildInWorkflowThread, 'run') + def test_ns_instantiate_vcpe(self, mock_run, mock_call_req): + config.WORKFLOW_OPTION = "buildin" + vcpe_nsd_model = json.dumps({ + "model": json.dumps({ + "vnfs": [{ + "vnf_id": "b1bb0ce7-2222-4fa7-95ed-4840d70a1101", + "properties": { + "id": "vnfd0", + "nf_type": "test" + }, + "dependencies": [{ + "vl_id": "5" + }] + }, + { + "vnf_id": "0408f076-e6c0-4c82-9940-272fddbb82de", + "properties": { + "id": "vnfd1", + "nf_type": "test" + }, + "dependencies": [{ + "vl_id": "5" + }] + }, + { + "vnf_id": "b1bb0ce7-2222-4fa7-95ed-4840d70a1100", + "properties": { + "id": "vnfd2", + "nf_type": "test" + }, + "dependencies": [{ + "vl_id": "5" + }] + }, + { + "vnf_id": "b1bb0ce7-2222-4fa7-95ed-4840d70a1102", + "properties": { + "id": "vnfd3", + "nf_type": "test" + }, + "dependencies": [{ + "vl_id": "5" + }] + }, + { + "vnf_id": "3fca3543-07f5-492f-812c-ed462e4f94f4", + "properties": { + "id": "vnfd4", + "nf_type": "test" + }, + "dependencies": [{ + "vl_id": "5" + }] + }, + ], + "vls": [{ + "vl_id": "5", + "properties": {} + }] + }) + }) + mock_call_req.side_effect = [ + [0, vcpe_nsd_model, '200'], + [0, self.vnfms, '200'], + [0, self.vnfm, '200'] + ] + req_data = { + "nsFlavourId": 'default', + "aditionalParamsForNs": { + "nfvo": "vfc", + "nf_naming": "true", + "multi_stage_design": "false", + "availability_zone_max_count": "1", + "xyz": "123", + "nsd0_providing_service_invariant_uuid": "12204a12-7da2-4ddf-8c2f-992a1a1acebf", + "nsd0_providing_service_uuid": "5791dbeb-19d4-43e8-bf44-5b327ccf6bca" + }, + "additionalParamsForVnf": [ + { + "vnfProfileId": "b1bb0ce7-2222-4fa7-95ed-4840d70a1101", + "additionalParams": { + "vimId": "CloudOwner_regionOne" + } + }, + { + "vnfProfileId": "0408f076-e6c0-4c82-9940-272fddbb82de", + "additionalParams": { + "vimId": "CloudOwner_regionOne" + } + }, + { + "vnfProfileId": "b1bb0ce7-2222-4fa7-95ed-4840d70a1100", + "additionalParams": { + "vimId": "CloudOwner_regionOne" + } + }, + { + "vnfProfileId": "b1bb0ce7-2222-4fa7-95ed-4840d70a1102", + "additionalParams": { + "vimId": "CloudOwner_regionOne" + } + }, + { + "vnfProfileId": "3fca3543-07f5-492f-812c-ed462e4f94f4", + "additionalParams": { + "vimId": "CloudOwner_regionOne" + } + } + ] + } + response = self.client.post(self.url % '2', data=req_data, format='json') + self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code) + self.assertIsNotNone(response['Location']) diff --git a/lcm/ns/tests/test_sol_ns_terminate_api.py b/lcm/ns/tests/test_sol_ns_terminate_api.py index 0027312a..44de00e7 100644 --- a/lcm/ns/tests/test_sol_ns_terminate_api.py +++ b/lcm/ns/tests/test_sol_ns_terminate_api.py @@ -58,7 +58,7 @@ class TestTerminateNsApi(TestCase): @mock.patch.object(TerminateNsService, 'run') def test_terminate_vnf(self, mock_run): mock_run.re.return_value = "1" - req_data = {} + req_data = {"terminationTime": "2019-03-25T09:10:35.610"} response = self.client.post(self.url % self.ns_inst_id, data=req_data) self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code) self.assertIsNotNone(response['Location']) |