X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Ftests%2Ftest.py;h=4c6b069cf8b11130ea975ec72676685c2e95a74f;hp=5d6a4875ee2d1922361c416815058cc7ec9bf338;hb=e4a07d5db1e38e6a52788d5788c6cc3396e1052d;hpb=1f1f6e03c7f6d6c1edd708e8d0b980827c7768ab diff --git a/osm_nbi/tests/test.py b/osm_nbi/tests/test.py index 5d6a487..4c6b069 100755 --- a/osm_nbi/tests/test.py +++ b/osm_nbi/tests/test.py @@ -85,6 +85,7 @@ r_headers_yaml_location_vnfd = {"Location": "/vnfpkgm/v1/vnf_packages_content/", r_headers_yaml_location_nsd = {"Location": "/nsd/v1/ns_descriptors_content/", "Content-Type": "application/yaml"} r_headers_yaml_location_nst = {"Location": "/nst/v1/netslice_templates_content", "Content-Type": "application/yaml"} r_headers_yaml_location_nslcmop = {"Location": "nslcm/v1/ns_lcm_op_occs/", "Content-Type": "application/yaml"} +r_headers_yaml_location_nsilcmop = {"Location": "/osm/nsilcm/v1/nsi_lcm_op_occs/", "Content-Type": "application/yaml"} # test ones authorized test_authorized_list = ( @@ -130,7 +131,7 @@ class TestRest: self.test_name = test_name self.step = 0 self.last_id = "" - + def set_header(self, header): self.s.headers.update(header) @@ -459,7 +460,7 @@ class TestUsersProjects: engine.test("Create project admin", "POST", "/admin/v1/projects", headers_json, {"name": "Padmin", "admin": True}, (201, 204), {"Location": "/admin/v1/projects/", "Content-Type": "application/json"}, "json") - engine.test("Create project bad format", "POST", "/admin/v1/projects", headers_json, {"name": 1}, 422, + engine.test("Create project bad format", "POST", "/admin/v1/projects", headers_json, {"name": 1}, (400, 422), r_header_json, "json") engine.test("Create user with bad project", "POST", "/admin/v1/users", headers_json, {"username": "U1", "projects": ["P1", "P2", "Padmin"], "password": "pw1"}, 409, @@ -543,11 +544,57 @@ class TestUsersProjects: # change to admin engine.remove_authorization() # To force get authorization engine.get_autorization() - engine.test("Delete user U1", "DELETE", "/admin/v1/users/U1", headers_json, None, 204, None, None) - engine.test("Delete project P1", "DELETE", "/admin/v1/projects/P1", headers_json, None, 204, None, None) - engine.test("Delete project Padmin", "DELETE", "/admin/v1/projects/Padmin", headers_json, None, 204, + engine.test("Delete user U1 by Name", "DELETE", "/admin/v1/users/U1", headers_json, None, 204, None, None) + engine.test("Delete project P1 by Name", "DELETE", "/admin/v1/projects/P1", headers_json, None, 204, None, None) + engine.test("Delete project Padmin by Name", "DELETE", "/admin/v1/projects/Padmin", headers_json, None, 204, None, None) + # BEGIN New Tests - Addressing Projects/Users by Name/ID + res = engine.test("Create new project P1", "POST", "/admin/v1/projects", headers_json, {"name": "P1"}, + 201, {"Location": "/admin/v1/projects/", "Content-Type": "application/json"}, "json") + if res: + pid1 = res.json()["id"] + # print("# pid =", pid1) + res = engine.test("Create new project P2", "POST", "/admin/v1/projects", headers_json, {"name": "P2"}, + 201, {"Location": "/admin/v1/projects/", "Content-Type": "application/json"}, "json") + if res: + pid2 = res.json()["id"] + # print("# pid =", pid2) + res = engine.test("Create new user U1", "POST", "/admin/v1/users", headers_json, + {"username": "U1", "projects": ["P1"], "password": "pw1"}, 201, + {"Location": "/admin/v1/users/", "Content-Type": "application/json"}, "json") + if res: + uid1 = res.json()["id"] + # print("# uid =", uid1) + res = engine.test("Create new user U2", "POST", "/admin/v1/users", headers_json, + {"username": "U2", "projects": ["P2"], "password": "pw2"}, 201, + {"Location": "/admin/v1/users/", "Content-Type": "application/json"}, "json") + if res: + uid2 = res.json()["id"] + # print("# uid =", uid2) + engine.test("Get Project P1 by Name", "GET", "/admin/v1/projects/P1", headers_json, None, 200, None, "json") + engine.test("Get Project P1 by ID", "GET", "/admin/v1/projects/"+pid1, headers_json, None, 200, None, "json") + engine.test("Get User U1 by Name", "GET", "/admin/v1/users/U1", headers_json, None, 200, None, "json") + engine.test("Get User U1 by ID", "GET", "/admin/v1/users/"+uid1, headers_json, None, 200, None, "json") + engine.test("Rename Project P1 by Name", "PUT", "/admin/v1/projects/P1", headers_json, + {"name": "P3"}, 204, None, None) + engine.test("Rename Project P2 by ID", "PUT", "/admin/v1/projects/"+pid2, headers_json, + {"name": "P4"}, 204, None, None) + engine.test("Rename User U1 by Name", "PUT", "/admin/v1/users/U1", headers_json, + {"username": "U3"}, 204, None, None) + engine.test("Rename User U2 by ID", "PUT", "/admin/v1/users/"+uid2, headers_json, + {"username": "U4"}, 204, None, None) + engine.test("Get Project P1 by new Name", "GET", "/admin/v1/projects/P3", headers_json, None, 200, None, "json") + engine.test("Get User U1 by new Name", "GET", "/admin/v1/users/U3", headers_json, None, 200, None, "json") + engine.test("Delete User U1 by Name", "DELETE", "/admin/v1/users/U3", headers_json, None, 204, None, None) + engine.test("Delete User U2 by ID", "DELETE", "/admin/v1/users/"+uid2, headers_json, None, 204, None, None) + engine.test("Delete Project P1 by Name", "DELETE", "/admin/v1/projects/P3", headers_json, None, 204, None, + None) + engine.test("Delete Project P2 by ID", "DELETE", "/admin/v1/projects/"+pid2, headers_json, None, 204, None, + None) + # END New Tests - Addressing Projects/Users by Name + engine.remove_authorization() # To finish + class TestFakeVim: description = "Creates/edit/delete fake VIMs and SDN controllers" @@ -715,6 +762,7 @@ class TestDeploy: self.timeout = 120 self.qforce = "" self.ns_params = None + self.vnfr_ip_list = {} def create_descriptors(self, engine): temp_dir = os.path.dirname(os.path.abspath(__file__)) + "/temp/" @@ -874,6 +922,7 @@ class TestDeploy: _keys = keys if keys is not None else self.keys _timeout = timeout if timeout != 0 else self.timeout + # vnfr_list=[d8272263-6bd3-4680-84ca-6a4be23b3f2d, 88b22e2f-994a-4b61-94fd-4a3c90de3dc4] for vnfr_id in vnfr_list: r = engine.test("Get VNFR to get IP_ADDRESS", "GET", "/nslcm/v1/vnfrs/{}".format(vnfr_id), headers_json, None, @@ -883,37 +932,36 @@ class TestDeploy: vnfr_data = r.json() vnf_index = str(vnfr_data["member-vnf-index-ref"]) - if not _commands.get(vnf_index): - continue - if vnfr_data.get("ip-address"): - description = "Exec command='{}' at VNFR={} IP={}".format(_commands.get(vnf_index)[0], vnf_index, - vnfr_data['ip-address']) - engine.step += 1 - test_description = "{}{} {}".format(engine.test_name, engine.step, description) - logger.warning(test_description) - while _timeout >= time: - result, message = self.do_checks([vnfr_data["ip-address"]], - vnf_index=vnfr_data["member-vnf-index-ref"], - commands=_commands.get(vnf_index), user=_users.get(vnf_index), - passwd=_passwds.get(vnf_index), key=_keys.get(vnf_index)) - if result == 1: - engine.passed_tests += 1 - logger.debug(message) - break - elif result == 0: - time += 20 - sleep(20) - elif result == -1: - engine.failed_tests += 1 - logger.error(message) - break + + ip_address = self.get_vnfr_ip(engine, vnf_index) + description = "Exec command='{}' at VNFR={} IP={}".format(_commands.get(vnf_index)[0], vnf_index, + ip_address) + engine.step += 1 + test_description = "{}{} {}".format(engine.test_name, engine.step, description) + logger.warning(test_description) + while _timeout >= time: + result, message = self.do_checks([ip_address], + vnf_index=vnfr_data["member-vnf-index-ref"], + commands=_commands.get(vnf_index), user=_users.get(vnf_index), + passwd=_passwds.get(vnf_index), key=_keys.get(vnf_index)) + if result == 1: + engine.passed_tests += 1 + logger.debug(message) + break + elif result == 0: + time += 20 + sleep(20) + elif result == -1: + engine.failed_tests += 1 + logger.error(message) + break else: time -= 20 engine.failed_tests += 1 logger.error(message) else: engine.failed_tests += 1 - logger.error("VNFR {} has not mgmt address. Check failed".format(vnfr_id)) + logger.error("VNFR {} has not mgmt address. Check failed".format(vnf_index)) def do_checks(self, ip, vnf_index, commands=[], user=None, passwd=None, key=None): try: @@ -989,6 +1037,32 @@ class TestDeploy: self.terminate(engine) self.delete_descriptors(engine) + def get_first_ip(self, ip_string): + # When using a floating IP, the vnfr_data['ip-address'] contains a semicolon-separated list of IP:s. + first_ip = ip_string.split(";")[0] if ip_string else "" + return first_ip + + def get_vnfr_ip(self, engine, vnfr_index_wanted): + # If the IP address list has been obtained before, it has been stored in 'vnfr_ip_list' + ip = self.vnfr_ip_list.get(vnfr_index_wanted, "") + if (ip): + return self.get_first_ip(ip) + r = engine.test("Get VNFR to get IP_ADDRESS", "GET", + "/nslcm/v1/vnfrs?member-vnf-index-ref={}&nsr-id-ref={}".format( + vnfr_index_wanted, self.ns_id), headers_json, None, + 200, r_header_json, "json") + if not r: + return "" + vnfr_data = r.json() + if not (vnfr_data and vnfr_data[0]): + return "" + # Store the IP (or list of IPs) in 'vnfr_ip_list' + ip_list = vnfr_data[0].get("ip-address", "") + if ip_list: + self.vnfr_ip_list[vnfr_index_wanted] = ip_list + ip = self.get_first_ip(ip_list) + return ip + class TestDeployHackfestCirros(TestDeploy): description = "Load and deploy Hackfest cirros_2vnf_ns example" @@ -1248,11 +1322,34 @@ class TestDeployHackfest3Charmed(TestDeploy): self.commands = {'1': ['ls -lrt /home/ubuntu/first-touch'], '2': ['ls -lrt /home/ubuntu/first-touch']} self.users = {'1': "ubuntu", '2': "ubuntu"} self.passwords = {'1': "osm4u", '2': "osm4u"} + self.descriptor_edit = { + "vnfd0": yaml.full_load( + """ + vnf-configuration: + terminate-config-primitive: + - seq: '1' + name: touch + parameter: + - name: filename + value: '/home/ubuntu/last-touch1' + - seq: '3' + name: touch + parameter: + - name: filename + value: '/home/ubuntu/last-touch3' + - seq: '2' + name: touch + parameter: + - name: filename + value: '/home/ubuntu/last-touch2' + """) + } def additional_operations(self, engine, test_osm, manual_check): if not test_osm: return # 1 perform action + vnfr_index_selected = "2" payload = '{member_vnf_index: "2", primitive: touch, primitive_params: { filename: /home/ubuntu/OSMTESTNBI }}' engine.test("Exec service primitive over NS", "POST", "/nslcm/v1/ns_instances/{}/action".format(self.ns_id), headers_yaml, payload, @@ -1260,9 +1357,12 @@ class TestDeployHackfest3Charmed(TestDeploy): nslcmop2_action = engine.last_id # Wait until status is Ok engine.wait_operation_ready("ns", nslcmop2_action, timeout_deploy) + vnfr_ip = self.get_vnfr_ip(engine, vnfr_index_selected) if manual_check: - input('NS service primitive has been executed. Check that file /home/ubuntu/OSMTESTNBI is present at ' - 'TODO_PUT_IP') + input( + "NS service primitive has been executed." + "Check that file /home/ubuntu/OSMTESTNBI is present at {}". + format(vnfr_ip)) if test_osm: commands = {'1': [''], '2': ['ls -lrt /home/ubuntu/OSMTESTNBI', ]} self.test_ns(engine, test_osm, commands=commands) @@ -1412,20 +1512,20 @@ class TestDeployHackfest3Charmed3(TestDeployHackfest3Charmed): "$[1]": parameter: "$[0]": - value: "" # default-value: /home/ubuntu/first-touch + value: "" # default-value: /home/ubuntu/first-touch config-primitive: "$[0]": parameter: "$[0]": - default-value: "" + default-value: "" """) } self.ns_params = { "additionalParamsForVnf": [ - {"member-vnf-index": "1", "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"}}, + {"member-vnf-index": "1", "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"}}, ] } @@ -1904,12 +2004,39 @@ class TestNetSliceTemplates: description = "Upload a NST to OSM" def __init__(self): - self.nst_filenames = ("@./cirros_slice/cirros_slice_vld.yaml") + self.vnfd_filename = ("@./slice_shared/vnfd/slice_shared_vnfd.yaml") + self.vnfd_filename_middle = ("@./slice_shared/vnfd/slice_shared_middle_vnfd.yaml") + self.nsd_filename = ("@./slice_shared/nsd/slice_shared_nsd.yaml") + self.nsd_filename_middle = ("@./slice_shared/nsd/slice_shared_middle_nsd.yaml") + self.nst_filenames = ("@./slice_shared/slice_shared_nstd.yaml") def run(self, engine, test_osm, manual_check, test_params=None): # nst CREATE - engine.set_test_name("NST") + engine.set_test_name("NST step ") engine.get_autorization() + temp_dir = os.path.dirname(os.path.abspath(__file__)) + "/temp/" + if not os.path.exists(temp_dir): + os.makedirs(temp_dir) + + # Onboard VNFDs + engine.test("Onboard edge VNFD", "POST", "/vnfpkgm/v1/vnf_packages_content", headers_yaml, + self.vnfd_filename, 201, r_headers_yaml_location_vnfd, "yaml") + self.vnfd_edge_id = engine.last_id + + engine.test("Onboard middle VNFD", "POST", "/vnfpkgm/v1/vnf_packages_content", headers_yaml, + self.vnfd_filename_middle, 201, r_headers_yaml_location_vnfd, "yaml") + self.vnfd_middle_id = engine.last_id + + # Onboard NSDs + engine.test("Onboard NSD edge", "POST", "/nsd/v1/ns_descriptors_content", headers_yaml, + self.nsd_filename, 201, r_headers_yaml_location_nsd, "yaml") + self.nsd_edge_id = engine.last_id + + engine.test("Onboard NSD middle", "POST", "/nsd/v1/ns_descriptors_content", headers_yaml, + self.nsd_filename_middle, 201, r_headers_yaml_location_nsd, "yaml") + self.nsd_middle_id = engine.last_id + + # Onboard NST engine.test("Onboard NST", "POST", "/nst/v1/netslice_templates_content", headers_yaml, self.nst_filenames, 201, r_headers_yaml_location_nst, "yaml") nst_id = engine.last_id @@ -1922,51 +2049,227 @@ class TestNetSliceTemplates: engine.test("Delete NSTD", "DELETE", "/nst/v1/netslice_templates/{}".format(nst_id), headers_json, None, 204, None, 0) + # NSDs DELETE + test_rest.test("Delete NSD middle", "DELETE", "/nsd/v1/ns_descriptors/{}".format(self.nsd_middle_id), + headers_json, None, 204, None, 0) + + test_rest.test("Delete NSD edge", "DELETE", "/nsd/v1/ns_descriptors/{}".format(self.nsd_edge_id), headers_json, + None, 204, None, 0) + + # VNFDs DELETE + test_rest.test("Delete VNFD edge", "DELETE", "/vnfpkgm/v1/vnf_packages/{}".format(self.vnfd_edge_id), + headers_yaml, None, 204, None, 0) + + test_rest.test("Delete VNFD middle", "DELETE", "/vnfpkgm/v1/vnf_packages/{}".format(self.vnfd_middle_id), + headers_yaml, None, 204, None, 0) + class TestNetSliceInstances: + ''' + Test procedure: + 1. Populate databases with VNFD, NSD, NST with the following scenario + +-----------------management-----------------+ + | | | + +--+---+ +----+----+ +---+--+ + | | | | | | + | edge +---data1----+ middle +---data2-----+ edge | + | | | | | | + +------+ +---------+ +------+ + shared-nss + 2. Create NSI-1 + 3. Instantiate NSI-1 + 4. Create NSI-2 + 5. Instantiate NSI-2 + Manual check - Are 2 slices instantiated correctly? + NSI-1 3 nss (2 nss-edges + 1 nss-middle) + NSI-2 2 nss (2 nss-edge sharing nss-middle) + 6. Terminate NSI-1 + 7. Delete NSI-1 + Manual check - Is slice NSI-1 deleted correctly? + NSI-2 with 2 nss-edge + 1 nss-middle (The one from NSI-1) + 8. Create NSI-3 + 9. Instantiate NSI-3 + Manual check - Is slice NSI-3 instantiated correctly? + NSI-3 reuse nss-middle. NSI-3 only create 2 nss-edge + 10. Delete NSI-2 + 11. Terminate NSI-2 + 12. Delete NSI-3 + 13. Terminate NSI-3 + Manual check - All cleaned correctly? + NSI-2 and NSI-3 were terminated and deleted + 14. Cleanup database + ''' + description = "Upload a NST to OSM" def __init__(self): self.vim_id = None - self.nst_filenames = ("@./cirros_slice/cirros_slice.yaml") + self.vnfd_filename = ("@./slice_shared/vnfd/slice_shared_vnfd.yaml") + self.vnfd_filename_middle = ("@./slice_shared/vnfd/slice_shared_middle_vnfd.yaml") + self.nsd_filename = ("@./slice_shared/nsd/slice_shared_nsd.yaml") + self.nsd_filename_middle = ("@./slice_shared/nsd/slice_shared_middle_nsd.yaml") + self.nst_filenames = ("@./slice_shared/slice_shared_nstd.yaml") + + def create_slice(self, engine, nsi_data, name): + ns_data_text = yaml.safe_dump(nsi_data, default_flow_style=True, width=256) + r = engine.test(name, "POST", "/nsilcm/v1/netslice_instances", + headers_yaml, ns_data_text, 201, + {"Location": "nsilcm/v1/netslice_instances/", "Content-Type": "application/yaml"}, "yaml") + return r + + def instantiate_slice(self, engine, nsi_data, nsi_id, name): + ns_data_text = yaml.safe_dump(nsi_data, default_flow_style=True, width=256) + engine.test(name, "POST", + "/nsilcm/v1/netslice_instances/{}/instantiate".format(nsi_id), headers_yaml, ns_data_text, + 201, r_headers_yaml_location_nsilcmop, "yaml") + + def terminate_slice(self, engine, nsi_id, name): + engine.test(name, "POST", "/nsilcm/v1/netslice_instances/{}/terminate".format(nsi_id), + headers_yaml, None, 201, r_headers_yaml_location_nsilcmop, "yaml") + + def delete_slice(self, engine, nsi_id, name): + engine.test(name, "DELETE", "/nsilcm/v1/netslice_instances/{}".format(nsi_id), headers_yaml, None, + 204, None, 0) def run(self, engine, test_osm, manual_check, test_params=None): # nst CREATE engine.set_test_name("NSI") engine.get_autorization() - engine.test("Onboard NST", "POST", "/nst/v1/netslice_templates_content", headers_yaml, self.nst_filenames, 201, - r_headers_yaml_location_nst, "yaml") + + # Onboard VNFDs + engine.test("Onboard edge VNFD", "POST", "/vnfpkgm/v1/vnf_packages_content", headers_yaml, + self.vnfd_filename, 201, r_headers_yaml_location_vnfd, "yaml") + self.vnfd_edge_id = engine.last_id + + engine.test("Onboard middle VNFD", "POST", "/vnfpkgm/v1/vnf_packages_content", headers_yaml, + self.vnfd_filename_middle, 201, r_headers_yaml_location_vnfd, "yaml") + self.vnfd_middle_id = engine.last_id + + # Onboard NSDs + engine.test("Onboard NSD edge", "POST", "/nsd/v1/ns_descriptors_content", headers_yaml, + self.nsd_filename, 201, r_headers_yaml_location_nsd, "yaml") + self.nsd_edge_id = engine.last_id + + engine.test("Onboard NSD middle", "POST", "/nsd/v1/ns_descriptors_content", headers_yaml, + self.nsd_filename_middle, 201, r_headers_yaml_location_nsd, "yaml") + self.nsd_middle_id = engine.last_id + + # Onboard NST + engine.test("Onboard NST", "POST", "/nst/v1/netslice_templates_content", headers_yaml, self.nst_filenames, + 201, r_headers_yaml_location_nst, "yaml") nst_id = engine.last_id - # nsi CREATE self.vim_id = engine.get_create_vim(test_osm) - ns_data = {"nsiDescription": "default description", "nsiName": "my_slice", "nstId": nst_id, - "vimAccountId": self.vim_id} - ns_data_text = yaml.safe_dump(ns_data, default_flow_style=True, width=256) + # CREATE NSI-1 + ns_data = {'nsiName': 'Deploy-NSI-1', 'vimAccountId': self.vim_id, 'nstId': nst_id, 'nsiDescription': 'default'} + r = self.create_slice(engine, ns_data, "Create NSI-1 step 1") + if not r: + return + self.nsi_id1 = engine.last_id - engine.test("Onboard NSI", "POST", "/nsilcm/v1/netslice_instances_content", headers_yaml, ns_data_text, 201, - r_headers_yaml_location_nst, "yaml") - nsi_id = engine.last_id - - # TODO: Improve the wait with a polling if NSI was deployed - wait = 120 - sleep(wait) - - # Check deployment - engine.test("Wait until NSI is deployed", "GET", "/nsilcm/v1/netslice_instances_content/{}".format(nsi_id), - headers_json, None, 200, r_header_json, "json") - - # nsi DELETE - engine.test("Delete NSI", "DELETE", "/nsilcm/v1/netslice_instances_content/{}".format(nsi_id), headers_json, - None, 202, r_header_json, "json") + # INSTANTIATE NSI-1 + self.instantiate_slice(engine, ns_data, self.nsi_id1, "Instantiate NSI-1 step 2") + nsilcmop_id1 = engine.last_id + + # Waiting for NSI-1 + if test_osm: + engine.wait_operation_ready("nsi", nsilcmop_id1, timeout_deploy) + + # CREATE NSI-2 + ns_data = {'nsiName': 'Deploy-NSI-2', 'vimAccountId': self.vim_id, 'nstId': nst_id, 'nsiDescription': 'default'} + r = self.create_slice(engine, ns_data, "Create NSI-2 step 1") + if not r: + return + self.nsi_id2 = engine.last_id + + # INSTANTIATE NSI-2 + self.instantiate_slice(engine, ns_data, self.nsi_id2, "Instantiate NSI-2 step 2") + nsilcmop_id2 = engine.last_id + + # Waiting for NSI-2 + if test_osm: + engine.wait_operation_ready("nsi", nsilcmop_id2, timeout_deploy) + + if manual_check: + input('NSI-1 AND NSI-2 has been deployed. Perform manual check and press enter to resume') + + # TERMINATE NSI-1 + if test_osm: + self.terminate_slice(engine, self.nsi_id1, "Terminate NSI-1") + nsilcmop1_id = engine.last_id + + # Wait terminate NSI-1 + engine.wait_operation_ready("nsi", nsilcmop1_id, timeout_deploy) + + # DELETE NSI-1 + self.delete_slice(engine, self.nsi_id1, "Delete NS") + + if manual_check: + input('NSI-1 has been deleted. Perform manual check and press enter to resume') + + # CREATE NSI-3 + ns_data = {'nsiName': 'Deploy-NSI-3', 'vimAccountId': self.vim_id, 'nstId': nst_id, 'nsiDescription': 'default'} + r = self.create_slice(engine, ns_data, "Create NSI-3 step 1") + + if not r: + return + self.nsi_id3 = engine.last_id + + # INSTANTIATE NSI-3 + self.instantiate_slice(engine, ns_data, self.nsi_id3, "Instantiate NSI-3 step 2") + nsilcmop_id3 = engine.last_id + + # Wait Instantiate NSI-3 + if test_osm: + engine.wait_operation_ready("nsi", nsilcmop_id3, timeout_deploy) + + if manual_check: + input('NSI-3 has been deployed. Perform manual check and press enter to resume') + + # TERMINATE NSI-2 + if test_osm: + self.terminate_slice(engine, self.nsi_id2, "Terminate NSI-2") + nsilcmop2_id = engine.last_id + + # Wait terminate NSI-2 + engine.wait_operation_ready("nsi", nsilcmop2_id, timeout_deploy) - sleep(60) + # DELETE NSI-2 + self.delete_slice(engine, self.nsi_id2, "DELETE NSI-2") + + # TERMINATE NSI-3 + if test_osm: + self. terminate_slice(engine, self.nsi_id3, "Terminate NSI-3") + nsilcmop3_id = engine.last_id + + # Wait terminate NSI-3 + engine.wait_operation_ready("nsi", nsilcmop3_id, timeout_deploy) + + # DELETE NSI-3 + self.delete_slice(engine, self.nsi_id3, "DELETE NSI-3") + + if manual_check: + input('NSI-2 and NSI-3 has been deleted. Perform manual check and press enter to resume') # nstd DELETE engine.test("Delete NSTD", "DELETE", "/nst/v1/netslice_templates/{}".format(nst_id), headers_json, None, 204, None, 0) + # NSDs DELETE + test_rest.test("Delete NSD middle", "DELETE", "/nsd/v1/ns_descriptors/{}".format(self.nsd_middle_id), + headers_json, None, 204, None, 0) + + test_rest.test("Delete NSD edge", "DELETE", "/nsd/v1/ns_descriptors/{}".format(self.nsd_edge_id), headers_json, + None, 204, None, 0) + + # VNFDs DELETE + test_rest.test("Delete VNFD edge", "DELETE", "/vnfpkgm/v1/vnf_packages/{}".format(self.vnfd_edge_id), + headers_yaml, None, 204, None, 0) + + test_rest.test("Delete VNFD middle", "DELETE", "/vnfpkgm/v1/vnf_packages/{}".format(self.vnfd_middle_id), + headers_yaml, None, 204, None, 0) + if __name__ == "__main__": global logger @@ -2007,8 +2310,8 @@ if __name__ == "__main__": # "Deploy-MultiVIM": TestDeployMultiVIM, "DeploySingleVdu": TestDeploySingleVdu, "DeployHnfd": TestDeployHnfd, - # "Upload-Slice-Template": TestNetSliceTemplates, - # "Deploy-Slice-Instance": TestNetSliceInstances, + "Upload-Slice-Template": TestNetSliceTemplates, + "Deploy-Slice-Instance": TestNetSliceInstances, "TestDeploySimpleCharm": TestDeploySimpleCharm, "TestDeploySimpleCharm2": TestDeploySimpleCharm2, } @@ -2087,7 +2390,7 @@ if __name__ == "__main__": test_class = test_classes[test] test_class().run(test_rest, test_osm, manual_check, test_params.get(text_index)) else: - for test, test_class in test_classes.items(): + for test, test_class in sorted(test_classes.items()): if fail_fast and test_rest.failed_tests: break test_class().run(test_rest, test_osm, manual_check, test_params.get(0))