X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Ftests%2Ftest.py;h=6bb04d956eb83c35ff0b3d4357cdfdd17a4cab36;hp=ddb5e697c0281fb16b1859d7b2c6a308039f4e3e;hb=29933fc257389f16f9c798f52a43e43800475a4a;hpb=bee085cdb94d0b864af28e8db9fc333e15e86209 diff --git a/osm_nbi/tests/test.py b/osm_nbi/tests/test.py index ddb5e69..6bb04d9 100755 --- a/osm_nbi/tests/test.py +++ b/osm_nbi/tests/test.py @@ -1002,6 +1002,29 @@ class TestDeployHackfestCirros(TestDeploy): self.users = {'1': "cirros", '2': "cirros"} self.passwords = {'1': "cubswin:)", '2': "cubswin:)"} + def terminate(self, engine): + # Make a delete in one step, overriding the normal two step of TestDeploy that launched terminate and delete + if test_osm: + engine.test("Terminate and delete NS in one step", "DELETE", "/nslcm/v1/ns_instances_content/{}". + format(self.ns_id), headers_yaml, None, 202, None, "yaml") + + engine .wait_until_delete("/nslcm/v1/ns_instances/{}".format(self.ns_id), timeout_deploy) + else: + engine.test("Delete NS with FORCE", "DELETE", "/nslcm/v1/ns_instances/{}?FORCE=True".format(self.ns_id), + headers_yaml, None, 204, None, 0) + + # check all it is deleted + engine.test("Check NS is deleted", "GET", "/nslcm/v1/ns_instances/{}".format(self.ns_id), headers_yaml, None, + 404, None, "yaml") + r = engine.test("Check NSLCMOPs are deleted", "GET", + "/nslcm/v1/ns_lcm_op_occs?nsInstanceId={}".format(self.ns_id), headers_json, None, + 200, None, "json") + if not r: + return + nslcmops = r.json() + if not isinstance(nslcmops, list) or nslcmops: + raise TestException("NS {} deleted but with ns_lcm_op_occ active: {}".format(self.ns_id, nslcmops)) + class TestDeployHackfest1(TestDeploy): description = "Load and deploy Hackfest_1_vnfd example" @@ -1168,52 +1191,49 @@ class TestDeployHackfest4(TestDeploy): self.commands = {'1': ['ls -lrt', ], '2': ['ls -lrt', ]} self.users = {'1': "ubuntu", '2': "ubuntu"} self.passwords = {'1': "osm4u", '2': "osm4u"} - - def create_descriptors(self, engine): - super().create_descriptors(engine) # Modify VNFD to add scaling - self.descriptor_edit = { - "vnfd0": { - 'vnf-configuration': { - 'config-primitive': [{ - 'name': 'touch', - 'parameter': [{ - 'name': 'filename', - 'data-type': 'STRING', - 'default-value': '/home/ubuntu/touched' - }] - }] - }, - 'scaling-group-descriptor': [{ - 'name': 'scale_dataVM', - 'scaling-policy': [{ - 'threshold-time': 0, - 'name': 'auto_cpu_util_above_threshold', - 'scaling-type': 'automatic', - 'scaling-criteria': [{ - 'name': 'cpu_util_above_threshold', - 'vnf-monitoring-param-ref': 'all_aaa_cpu_util', - 'scale-out-relational-operation': 'GE', - 'scale-in-threshold': 15, - 'scale-out-threshold': 60, - 'scale-in-relational-operation': 'LE' - }], - 'cooldown-time': 60 - }], - 'max-instance-count': 10, - 'scaling-config-action': [ - {'vnf-config-primitive-name-ref': 'touch', - 'trigger': 'post-scale-out'}, - {'vnf-config-primitive-name-ref': 'touch', - 'trigger': 'pre-scale-in'} - ], - 'vdu': [{ - 'vdu-id-ref': 'dataVM', - 'count': 1 - }] - }] - } - } + # self.descriptor_edit = { + # "vnfd0": { + # 'vnf-configuration': { + # 'config-primitive': [{ + # 'name': 'touch', + # 'parameter': [{ + # 'name': 'filename', + # 'data-type': 'STRING', + # 'default-value': '/home/ubuntu/touched' + # }] + # }] + # }, + # 'scaling-group-descriptor': [{ + # 'name': 'scale_dataVM', + # 'scaling-policy': [{ + # 'threshold-time': 0, + # 'name': 'auto_cpu_util_above_threshold', + # 'scaling-type': 'automatic', + # 'scaling-criteria': [{ + # 'name': 'cpu_util_above_threshold', + # 'vnf-monitoring-param-ref': 'all_aaa_cpu_util', + # 'scale-out-relational-operation': 'GE', + # 'scale-in-threshold': 15, + # 'scale-out-threshold': 60, + # 'scale-in-relational-operation': 'LE' + # }], + # 'cooldown-time': 60 + # }], + # 'max-instance-count': 10, + # 'scaling-config-action': [ + # {'vnf-config-primitive-name-ref': 'touch', + # 'trigger': 'post-scale-out'}, + # {'vnf-config-primitive-name-ref': 'touch', + # 'trigger': 'pre-scale-in'} + # ], + # 'vdu': [{ + # 'vdu-id-ref': 'dataVM', + # 'count': 1 + # }] + # }] + # } + # } class TestDeployHackfest3Charmed(TestDeploy): @@ -1347,7 +1367,7 @@ class TestDeployHackfest3Charmed3(TestDeployHackfest3Charmed): def __init__(self): super().__init__() self.test_name = "HACKFEST3v3-" - self.commands = {'1': ['ls -lrt /home/ubuntu/first-touch-1'], '2': ['ls -lrt /home/ubuntu/first-touch-1']} + self.commands = {'1': ['ls -lrt /home/ubuntu/first-touch-1'], '2': ['ls -lrt /home/ubuntu/first-touch-2']} self.descriptor_edit = { "vnfd0": yaml.load( """ @@ -1393,18 +1413,18 @@ class TestDeployHackfest3Charmed3(TestDeployHackfest3Charmed): parameter: "$[0]": value: "" # default-value: /home/ubuntu/first-touch - # config-primitive: - # "$[0]": - # parameter: - # "$[0]": - # default-value: "" + config-primitive: + "$[0]": + parameter: + "$[0]": + default-value: "" """) } self.ns_params = { "additionalParamsForVnf": [ {"member-vnf-index": "1", "additionalParams": {"touch-filename": "/home/ubuntu/first-touch-1", - "touch-filename2": "/home/ubuntu/second-touch-2"}}, - {"member-vnf-index": "2", "additionalParams": {"touch-filename": "/home/ubuntu/first-touch-1", + "touch-filename2": "/home/ubuntu/second-touch-1"}}, + {"member-vnf-index": "2", "additionalParams": {"touch-filename": "/home/ubuntu/first-touch-2", "touch-filename2": "/home/ubuntu/second-touch-2"}}, ] } @@ -1423,9 +1443,9 @@ class TestDeployHackfest3Charmed3(TestDeployHackfest3Charmed): nslcmop2_scale_out = engine.last_id engine.wait_operation_ready("ns", nslcmop2_scale_out, timeout_deploy) if manual_check: - input('NS scale out done. Check that file /home/ubuntu/touched is present and new VM is created') + input('NS scale out done. Check that file /home/ubuntu/second-touch-1 is present and new VM is created') if test_osm: - commands = {'1': ['ls -lrt /home/ubuntu/touched', ]} + commands = {'1': ['ls -lrt /home/ubuntu/second-touch-1', ]} self.test_ns(engine, test_osm, commands=commands) # TODO check automatic connection to scaled VM @@ -1438,7 +1458,7 @@ class TestDeployHackfest3Charmed3(TestDeployHackfest3Charmed): nslcmop2_scale_in = engine.last_id engine.wait_operation_ready("ns", nslcmop2_scale_in, timeout_deploy) if manual_check: - input('NS scale in done. Check that file /home/ubuntu/touched is updated and new VM is deleted') + input('NS scale in done. Check that file /home/ubuntu/second-touch-1 is updated and new VM is deleted') # TODO check automatic @@ -1791,6 +1811,14 @@ class TestDescriptors: "/vnfpkgm/v1/vnf_packages/{}/package_content".format(self.vnfd_id), headers_zip_yaml, "@b" + vnfd_filename_path, 204, None, 0) + queries = ["mgmt-interface.cp=mgmt", "vdu.0.interface.0.external-connection-point-ref=mgmt", + "vdu.0.interface.1.internal-connection-point-ref=internal", + "internal-vld.0.internal-connection-point.0.id-ref=internal"] + for query in queries: + engine.test("Upload invalid VNFD ", "PUT", + "/vnfpkgm/v1/vnf_packages/{}/package_content?{}".format(self.vnfd_id, query), + headers_zip_yaml, "@b" + vnfd_filename_path, 422, r_header_yaml, "yaml") + # test bug 605 engine.test("Upload invalid VNFD ", "PUT", "/vnfpkgm/v1/vnf_packages/{}/package_content".format(self.vnfd_id), headers_yaml, self.vnfd_prova, 422, r_header_yaml, "yaml") @@ -1821,6 +1849,12 @@ class TestDescriptors: "@b" + nsd_filename_path, 201, r_headers_yaml_location_nsd, "yaml") self.nsd_id = engine.last_id + queries = ["vld.0.vnfd-connection-point-ref.0.vnfd-id-ref=hf"] + for query in queries: + engine.test("Upload invalid NSD ", "PUT", + "/nsd/v1/ns_descriptors/{}/nsd_content?{}".format(self.nsd_id, query), + headers_zip_yaml, "@b" + nsd_filename_path, 422, r_header_yaml, "yaml") + # get nsd descriptor engine.test("Get NSD descriptor", "GET", "/nsd/v1/ns_descriptors/{}".format(self.nsd_id), headers_yaml, None, 200, r_header_yaml, "yaml")