X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Ftests%2Ftest_descriptor_topics.py;h=0b1d800b03e4b194a02e1461faf28228ce27657d;hp=faee74487d79952292dafe48123e850840e0638d;hb=f576eb9b45f9b1e12adbc503681a2194b8ec85aa;hpb=b995ea260a3a2f88a4e041c7e2dd745daee91825 diff --git a/osm_nbi/tests/test_descriptor_topics.py b/osm_nbi/tests/test_descriptor_topics.py index faee744..0b1d800 100755 --- a/osm_nbi/tests/test_descriptor_topics.py +++ b/osm_nbi/tests/test_descriptor_topics.py @@ -112,9 +112,21 @@ class Test_VnfdTopic(TestCase): self.assertEqual(db_args[1]["_admin"]["projects_read"], [test_pid], "Wrong read-only project list") self.assertEqual(db_args[1]["_admin"]["projects_write"], [test_pid], "Wrong read-write project list") tmp1 = test_vnfd["vdu"][0]["cloud-init-file"] - tmp2 = test_vnfd["vnf-configuration"][0]["juju"] + tmp2 = test_vnfd["df"][ + 0 + ]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][ + 0 + ]["execution-environment-list"][ + 0 + ]["juju"] del test_vnfd["vdu"][0]["cloud-init-file"] - del test_vnfd["vnf-configuration"][0]["juju"] + del test_vnfd["df"][ + 0 + ]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][ + 0 + ]["execution-environment-list"][ + 0 + ]["juju"] try: self.db.get_one.side_effect = [{"_id": did, "_admin": deepcopy(db_vnfd_content["_admin"])}, None] self.topic.upload_content(fake_session, did, test_vnfd, {}, {"Content-Type": []}) @@ -145,7 +157,13 @@ class Test_VnfdTopic(TestCase): compare_desc(self, test_vnfd, db_args[2], "VNFD") finally: test_vnfd["vdu"][0]["cloud-init-file"] = tmp1 - test_vnfd["vnf-configuration"][0]["juju"] = tmp2 + test_vnfd["df"][ + 0 + ]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][ + 0 + ]["execution-environment-list"][ + 0 + ]["juju"] = tmp2 self.db.get_one.side_effect = lambda table, filter, fail_on_empty=None, fail_on_more=None: \ {"_id": did, "_admin": deepcopy(db_vnfd_content["_admin"])} with self.subTest(i=2, t='Check Pyangbind Validation: additional properties'): @@ -178,14 +196,21 @@ class Test_VnfdTopic(TestCase): self.assertIn(norm("{} defined in vnf[id={}]:vdu[id={}] but not present in package" .format("cloud-init", test_vnfd["id"], test_vnfd["vdu"][0]["id"])), norm(str(e.exception)), "Wrong exception text") - with self.subTest(i=5, t='Check Input Validation: vnf-configuration[juju]'): + with self.subTest(i=5, t='Check Input Validation: day1-2 configuration[juju]'): del test_vnfd["vdu"][0]["cloud-init-file"] with self.assertRaises(EngineException, msg="Accepted non-existent charm in VNF configuration") as e: self.topic.upload_content(fake_session, did, test_vnfd, {}, {"Content-Type": []}) + print(str(e.exception)) self.assertEqual(e.exception.http_code, HTTPStatus.BAD_REQUEST, "Wrong HTTP status code") self.assertIn(norm("{} defined in vnf[id={}] but not present in package".format("charm", test_vnfd["id"])), norm(str(e.exception)), "Wrong exception text") - del test_vnfd["vnf-configuration"][0]["juju"] + del test_vnfd["df"][ + 0 + ]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][ + 0 + ]["execution-environment-list"][ + 0 + ]["juju"] with self.subTest(i=6, t='Check Input Validation: mgmt-cp'): tmp = test_vnfd["mgmt-cp"] del test_vnfd["mgmt-cp"] @@ -280,22 +305,30 @@ class Test_VnfdTopic(TestCase): vdu['monitoring-parameter'] = tmp with self.subTest(i=13, t='Check Input Validation: scaling-aspect vnf-configuration'): df = test_vnfd['df'][0] - tmp = test_vnfd.pop('vnf-configuration') + tmp = test_vnfd["df"][0]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"].pop() try: with self.assertRaises(EngineException, msg="Accepted non-existent Scaling Group VDU ID Reference") \ as e: self.topic.upload_content(fake_session, did, test_vnfd, {}, {"Content-Type": []}) self.assertEqual(e.exception.http_code, HTTPStatus.UNPROCESSABLE_ENTITY, "Wrong HTTP status code") - self.assertIn(norm("'vnf-configuration' not defined in the descriptor but it is referenced " + self.assertIn(norm("'day1-2 configuration' not defined in the descriptor but it is referenced " "by df[id='{}']:scaling-aspect[id='{}']:scaling-config-action" .format(df["id"], df['scaling-aspect'][0]["id"])), norm(str(e.exception)), "Wrong exception text") finally: - test_vnfd["vnf-configuration"] = tmp + test_vnfd["df"][0]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"].append(tmp) with self.subTest(i=14, t='Check Input Validation: scaling-config-action'): df = test_vnfd['df'][0] - tmp = test_vnfd['vnf-configuration'][0]['config-primitive'] - test_vnfd['vnf-configuration'][0]['config-primitive'] = [{'name': 'wrong-primitive'}] + tmp = test_vnfd["df"][0].get( + "lcm-operations-configuration" + ).get( + "operate-vnf-op-config" + )["day1-2"][0]['config-primitive'] + test_vnfd["df"][0].get( + "lcm-operations-configuration" + ).get( + "operate-vnf-op-config" + )["day1-2"][0]['config-primitive'] = [{'name': 'wrong-primitive'}] try: with self.assertRaises(EngineException, msg="Accepted non-existent Scaling Group VDU ID Reference") as e: @@ -303,14 +336,23 @@ class Test_VnfdTopic(TestCase): self.assertEqual(e.exception.http_code, HTTPStatus.UNPROCESSABLE_ENTITY, "Wrong HTTP status code") self.assertIn(norm("df[id='{}']:scaling-aspect[id='{}']:scaling-config-action:vnf-" "config-primitive-name-ref='{}' does not match any " - "vnf-configuration:config-primitive:name" + "day1-2 configuration:config-primitive:name" .format(df["id"], df['scaling-aspect'][0]["id"], sa['scaling-config-action'][0]['vnf-config-primitive-name-ref'])), norm(str(e.exception)), "Wrong exception text") finally: - test_vnfd['vnf-configuration'][0]['config-primitive'] = tmp + test_vnfd["df"][0].get( + "lcm-operations-configuration" + ).get( + "operate-vnf-op-config" + )["day1-2"][0]['config-primitive'] = tmp with self.subTest(i=15, t='Check Input Validation: everything right'): test_vnfd["id"] = "fake-vnfd-id" + test_vnfd["df"][0].get( + "lcm-operations-configuration" + ).get( + "operate-vnf-op-config" + )["day1-2"][0]["id"] = "fake-vnfd-id" self.db.get_one.side_effect = [{"_id": did, "_admin": deepcopy(db_vnfd_content["_admin"])}, None] rc = self.topic.upload_content(fake_session, did, test_vnfd, {}, {"Content-Type": []}) self.assertTrue(rc, "Input Validation: Unexpected failure") @@ -324,7 +366,9 @@ class Test_VnfdTopic(TestCase): with self.subTest(i=1, t='Normal Edition'): now = time() self.db.get_one.side_effect = [deepcopy(vnfd_content), None] - data = {"id": "new-vnfd-id", "product-name": "new-vnfd-name"} + data = { + "product-name": "new-vnfd-name" + } self.topic.edit(fake_session, did, data) db_args = self.db.replace.call_args[0] msg_args = self.msg.write.call_args[0] @@ -342,10 +386,9 @@ class Test_VnfdTopic(TestCase): "Wrong read-only project list") self.assertEqual(db_args[2]["_admin"]["projects_write"], vnfd_content["_admin"]["projects_write"], "Wrong read-write project list") - self.assertEqual(db_args[2]["id"], data["id"], "Wrong VNFD ID") self.assertEqual(db_args[2]["product-name"], data["product-name"], "Wrong VNFD Name") with self.subTest(i=2, t='Conflict on Edit'): - data = {"id": "fake-vnfd-id", "product-name": "new-vnfd-name"} + data = {"id": "hackfest3charmed-vnf", "product-name": "new-vnfd-name"} self.db.get_one.side_effect = [deepcopy(vnfd_content), {"_id": str(uuid4()), "id": data["id"]}] with self.assertRaises(EngineException, msg="Accepted existing VNFD ID") as e: self.topic.edit(fake_session, did, data) @@ -383,8 +426,8 @@ class Test_VnfdTopic(TestCase): self.assertEqual(db_gl_calls[0][0][0], "vnfrs", "Wrong DB topic") # self.assertEqual(db_gl_calls[0][0][1]["vnfd-id"], did, "Wrong DB VNFD ID") # Filter changed after call self.assertEqual(db_gl_calls[1][0][0], "nsds", "Wrong DB topic") - self.assertEqual(db_gl_calls[1][0][1]["constituent-vnfd.ANYINDEX.vnfd-id-ref"], db_vnfd_content["id"], - "Wrong DB NSD constituent-vnfd id-ref") + self.assertEqual(db_gl_calls[1][0][1]["vnfd-id"], db_vnfd_content["id"], + "Wrong DB NSD vnfd-id") self.db.set_one.assert_not_called() fs_del_calls = self.fs.file_delete.call_args_list @@ -395,14 +438,14 @@ class Test_VnfdTopic(TestCase): with self.assertRaises(EngineException, msg="Accepted VNFD in use by VNFR") as e: self.topic.delete(fake_session, did) self.assertEqual(e.exception.http_code, HTTPStatus.CONFLICT, "Wrong HTTP status code") - self.assertIn("there is at least one vnf using this descriptor", norm(str(e.exception)), + self.assertIn("there is at least one vnf instance using this descriptor", norm(str(e.exception)), "Wrong exception text") with self.subTest(i=3, t='Conflict on Delete - VNFD in use by NSD'): self.db.get_list.side_effect = [[], [{"_id": str(uuid4()), "name": "fake-nsd"}]] with self.assertRaises(EngineException, msg="Accepted VNFD in use by NSD") as e: self.topic.delete(fake_session, did) self.assertEqual(e.exception.http_code, HTTPStatus.CONFLICT, "Wrong HTTP status code") - self.assertIn("there is at least one nsd referencing this descriptor", norm(str(e.exception)), + self.assertIn("there is at least one ns package referencing this descriptor", norm(str(e.exception)), "Wrong exception text") with self.subTest(i=4, t='Non-existent VNFD'): excp_msg = "Not found any {} with filter='{}'".format("VNFD", {"_id": did}) @@ -613,11 +656,11 @@ class Test_VnfdTopic(TestCase): indata = deepcopy(db_vnfd_content) df = indata['df'][0] affected_sa = df['scaling-aspect'][0] - indata.pop('vnf-configuration') + indata["df"][0]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"].pop() with self.assertRaises(EngineException) as e: self.topic.validate_scaling_group_descriptor(indata) self.assertEqual(e.exception.http_code, HTTPStatus.UNPROCESSABLE_ENTITY, "Wrong HTTP status code") - self.assertIn(norm("'vnf-configuration' not defined in the descriptor but it is referenced " + self.assertIn(norm("'day1-2 configuration' not defined in the descriptor but it is referenced " "by df[id='{}']:scaling-aspect[id='{}']:scaling-config-action" .format(df["id"], affected_sa["id"])), norm(str(e.exception)), "Wrong exception text") @@ -627,13 +670,13 @@ class Test_VnfdTopic(TestCase): df = indata['df'][0] affected_sa = df['scaling-aspect'][0] affected_sca_primitive = affected_sa['scaling-config-action'][0]['vnf-config-primitive-name-ref'] - indata['vnf-configuration'][0]['config-primitive'] = [] + df["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][0]['config-primitive'] = [] with self.assertRaises(EngineException) as e: self.topic.validate_scaling_group_descriptor(indata) self.assertEqual(e.exception.http_code, HTTPStatus.UNPROCESSABLE_ENTITY, "Wrong HTTP status code") self.assertIn(norm("df[id='{}']:scaling-aspect[id='{}']:scaling-config-action:vnf-" "config-primitive-name-ref='{}' does not match any " - "vnf-configuration:config-primitive:name" + "day1-2 configuration:config-primitive:name" .format(df["id"], affected_sa["id"], affected_sca_primitive)), norm(str(e.exception)), "Wrong exception text") @@ -762,11 +805,11 @@ class Test_NsdTopic(TestCase): norm(str(e.exception)), "Wrong exception text") finally: del df['virtual-link-profile'] - with self.subTest(i=6, t='Check Descriptor Dependencies: constituent-vnfd[vnfd-id-ref]'): + with self.subTest(i=6, t='Check Descriptor Dependencies: vnfd-id[]'): self.db.get_one.side_effect = [{"_id": did, "_admin": db_nsd_content["_admin"]}, None] self.db.get_list.return_value = [] try: - with self.assertRaises(EngineException, msg="Accepted wrong constituent VNFD ID reference") as e: + with self.assertRaises(EngineException, msg="Accepted wrong VNFD ID reference") as e: self.topic.upload_content(fake_session, did, test_nsd, {}, {"Content-Type": []}) self.assertEqual(e.exception.http_code, HTTPStatus.CONFLICT, "Wrong HTTP status code") self.assertIn(norm("'vnfd-id'='{}' references a non existing vnfd".format(test_nsd['vnfd-id'][0])), @@ -876,7 +919,7 @@ class Test_NsdTopic(TestCase): with self.assertRaises(EngineException, msg="Accepted NSD in use by NSR") as e: self.topic.delete(fake_session, did) self.assertEqual(e.exception.http_code, HTTPStatus.CONFLICT, "Wrong HTTP status code") - self.assertIn("there is at least one ns using this descriptor", norm(str(e.exception)), + self.assertIn("there is at least one ns instance using this descriptor", norm(str(e.exception)), "Wrong exception text") with self.subTest(i=3, t='Conflict on Delete - NSD in use by NST'): self.db.get_list.side_effect = [[], [{"_id": str(uuid4()), "name": "fake-nst"}]]