X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Ftests%2Ftest.py;h=4c6b069cf8b11130ea975ec72676685c2e95a74f;hp=a48ee2656a722625e0f9e57d4727934a627915d6;hb=e4a07d5db1e38e6a52788d5788c6cc3396e1052d;hpb=587aeea73f8cdf5561a451dbc87107daef6efe04 diff --git a/osm_nbi/tests/test.py b/osm_nbi/tests/test.py index a48ee26..4c6b069 100755 --- a/osm_nbi/tests/test.py +++ b/osm_nbi/tests/test.py @@ -131,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) @@ -460,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, @@ -544,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" @@ -1466,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"}}, ] } @@ -2127,7 +2173,8 @@ class TestNetSliceInstances: nsilcmop_id1 = engine.last_id # Waiting for NSI-1 - engine.wait_operation_ready("nsi", nsilcmop_id1, timeout_deploy) + 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'} @@ -2141,17 +2188,19 @@ class TestNetSliceInstances: nsilcmop_id2 = engine.last_id # Waiting for NSI-2 - engine.wait_operation_ready("nsi", nsilcmop_id2, timeout_deploy) + 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 - self.terminate_slice(engine, self.nsi_id1, "Terminate NSI-1") - nsilcmop1_id = engine.last_id + 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) + # 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") @@ -2172,27 +2221,30 @@ class TestNetSliceInstances: nsilcmop_id3 = engine.last_id # Wait Instantiate NSI-3 - engine.wait_operation_ready("nsi", nsilcmop_id3, timeout_deploy) + 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 - self.terminate_slice(engine, self.nsi_id2, "Terminate NSI-2") - nsilcmop2_id = engine.last_id + 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) + # Wait terminate NSI-2 + engine.wait_operation_ready("nsi", nsilcmop2_id, timeout_deploy) # DELETE NSI-2 self.delete_slice(engine, self.nsi_id2, "DELETE NSI-2") # TERMINATE NSI-3 - 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) + 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") @@ -2338,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))