def test_post_ns_instances_nsinstanceid_instantiate( post_ns_instances_nsinstanceid_instantiate_keys): """Tests API call to create a NS instance resource""" # Helpers._delete_test_ns_instance() Helpers._upload_reference_vnfd_for_nsd() Helpers._upload_test_nsd() time.sleep(5) # Wait osm_nsd = OSMClient.Nsd(HOST_URL) osm_nslcm = OSMClient.Nslcm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _nsd_list = json.loads(osm_nsd.get_ns_descriptors(token=_token["id"])) _nsd_list = json.loads(_nsd_list["data"]) _nsd = None for _n in _nsd_list: if "test_osm_cirros_2vnf_nsd" == _n['id']: _nsd = _n['_id'] response = json.loads( osm_nslcm.post_ns_instances_nsinstanceid_instantiate( token=_token["id"], nsDescription=NSDESCRIPTION, nsName=NSNAME, nsdId=_nsd, vimAccountId=VIMACCOUNTID)) response = json.loads(response["data"]) Helpers._delete_test_nsd("test_osm_cirros_2vnf_nsd") assert isinstance(response, dict) assert set(post_ns_instances_nsinstanceid_instantiate_keys).issubset( response.keys()), "All keys should be in the response" time.sleep(5) # Wait for NS instantiation
def test_put_vnf_packages_vnfpkgid_package_content(): """Tests API call to Upload a VNF package by providing the content of the VNF package""" osm_vnfpkgm_vnfd = OSMClient.VnfPkgm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) Helpers._upload_test_vnf() _vnfd_list = json.loads( osm_vnfpkgm_vnfd.get_vnf_packages(token=_token["id"])) _vnfd_list = json.loads(_vnfd_list["data"]) _vnfd = None for _v in _vnfd_list: if "test_osm_cirros_vnfd" == _v['id']: _vnfd = _v['_id'] response = json.loads( osm_vnfpkgm_vnfd.put_vnf_packages_vnfpkgid_package_content( token=_token["id"], vnfPkgId=_vnfd, data_path="tests/samples/test_osm_cirros_vnfd.tar.gz")) Helpers._delete_test_vnf("test_osm_cirros_2vnf_nsd") if response["error"]: return True else: return False
def test_put_ns_descriptors_nsd_content(): """Tests API call to upload the content of a NSD""" osm_nsd = OSMClient.Nsd(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) Helpers._upload_reference_vnfd_for_nsd() Helpers._upload_test_nsd() _nsd_list = json.loads(osm_nsd.get_ns_descriptors(token=_token["id"])) _nsd_list = json.loads(_nsd_list["data"]) _nsd = None for _n in _nsd_list: if "test_osm_cirros_2vnf_nsd" == _n['id']: _nsd = _n['_id'] response = json.loads( osm_nsd.put_ns_descriptors_nsd_content( token=_token["id"], nsdinfoid=_nsd, data_path="tests/samples/test_osm_cirros_nsd.tar.gz")) Helpers._delete_test_nsd("test_osm_cirros_2vnf_nsd") if response["error"]: return True else: return False
def test_get_sdn_list(): """Tests API call to get the list of sdns""" osm_admin = OSMClient.Admin(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) response = json.loads(osm_admin.get_sdn_list(token=_token["id"])) response = json.loads(response["data"])
def test_get_vnf_packages(get_vnf_packages_keys): """Tests API call to fetch multiple NS descriptor resources""" osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) response = json.loads(osm_vnfpkgm.get_vnf_packages(token=_token["id"])) response = json.loads(response["data"]) assert isinstance(response, list) if len(response) > 0: assert set(get_vnf_packages_keys).issubset( response[0].keys()), "All keys should be in the response"
def test_get_ns_instances(get_ns_instances_keys): """Tests API call query multiple NS instances""" osm_nslcm = OSMClient.Nslcm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) response = json.loads(osm_nslcm.get_ns_instances(token=_token["id"])) response = json.loads(response["data"]) assert isinstance(response, list) if len(response) > 0: assert set(get_ns_instances_keys).issubset( response[0].keys()), "All keys should be in the response"
def test_get_user_list(get_user_list_keys): """Tests API call to get the list of users""" osm_admin = OSMClient.Admin(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) response = json.loads(osm_admin.get_user_list(token=_token["id"])) response = json.loads(response["data"]) assert isinstance(response, list) if len(response) > 0: assert set(get_user_list_keys).issubset( response[0].keys()), "All keys should be in the response"
def _upload_test_ns_instance(): time.sleep(3) # Wait osm_nslcm = OSMClient.Nslcm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) response = json.loads( osm_nslcm.post_ns_instances(token=_token["id"], nsDescription=NSDESCRIPTION, nsName=NSNAME, nsdId=NSDID, vimAccountId=VIMACCOUNTID)) response = json.loads(response["data"])
def _upload_test_vnf(): time.sleep(3) # Wait osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) response = json.loads( osm_vnfpkgm.post_vnf_packages( token=_token["id"], package_path="tests/samples/test_osm_cirros_vnfd.tar.gz")) if response["error"]: return True else: return False
def test_get_vnf_packages_vnfpkgid(get_vnf_packages_vnfpkgid_keys): """Tests API call to onboard VNF descriptor resources""" osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _vnfd_list = json.loads(osm_vnfpkgm.get_vnf_packages(token=_token["id"])) _vnfd_list = json.loads(_vnfd_list["data"]) for _v in _vnfd_list: if "test_osm_cirros_vnfd" == _v['id']: _vnfd = _v['_id'] response = json.loads( osm_vnfpkgm.get_vnf_packages_vnfpkgid(token=_token["id"], vnfPkgId=_vnfd))
def test_get_vim_info(get_vim_info_keys): """Tests API call to get the information about individual vim""" osm_admin = OSMClient.Admin(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _v_list = json.loads(osm_admin.get_vim_list(token=_token["id"])) _v_list = json.loads(_v_list["data"]) _vim = _v_list[0]['_id'] response = json.loads(osm_admin.get_vim_info(token=_token["id"], id=_vim)) if response["error"]: return True else: return False
def test_post_vnf_packages(post_vnf_packages_keys): """Tests API call to onboard VNF descriptor resources""" Helpers._delete_test_nsd() Helpers._delete_test_vnf() osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) response = json.loads( osm_vnfpkgm.post_vnf_packages( token=_token["id"], package_path="tests/samples/test_osm_cirros_vnfd.tar.gz")) response = json.loads(response["data"]) assert isinstance(response, dict) assert set(post_vnf_packages_keys).issubset( response.keys()), "All keys should be in the response"
def test_auth(auth_keys): """Tests API call to fetch Auth token""" osm_c = OSMClient.Auth(HOST_URL) response = json.loads(osm_c.auth(username=USERNAME, password=PASSWORD)) response = json.loads(response["data"]) assert isinstance(response, dict) assert set(auth_keys).issubset( response.keys()), "All keys should be in the response"
def test_get_user_info(): """Tests API call to get the information about individual users""" osm_admin = OSMClient.Admin(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _u_list = json.loads(osm_admin.get_user_list(token=_token["id"])) _u_list = json.loads(_u_list["data"]) for _u in _u_list: if USERNAME == _u['_id']: _usr = _u['_id'] response = json.loads(osm_admin.get_user_info(token=_token["id"], id=_usr)) if response["error"]: return True else: return False
def test_get_vnf_instances_vnfinstanceid(get_vnf_instances_vnfinstanceid_keys): """Tests API call to read an individual VNF instance resource""" osm_nslcm = OSMClient.Nslcm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _vnf_list = json.loads(osm_nslcm.get_vnf_instances(token=_token["id"])) _vnf_list = json.loads(_vnf_list["data"]) response = json.loads( osm_nslcm.get_vnf_instances_vnfinstanceid( token=_token["id"], vnfInstanceId=_vnf_list[0]["id"])) assert response['error'] == False response = json.loads(response["data"]) assert isinstance(response, dict) assert set(get_vnf_instances_vnfinstanceid_keys).issubset( response.keys()), "All keys should be in the response"
def test_delete_ns_descriptors_nsdinfoid(delete_ns_descriptors_nsdinfoid_keys): """Tests API call to delete NS descriptor resources""" osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL) osm_nsd = OSMClient.Nsd(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _nsd_list = json.loads(osm_nsd.get_ns_descriptors(token=_token["id"])) _nsd_list = json.loads(_nsd_list["data"]) _nsd = None for _n in _nsd_list: if "test_osm_cirros_2vnf_nsd" == _n['id']: _nsd = _n['_id'] time.sleep(10) # Wait for NSD onboarding response = json.loads( osm_nsd.delete_ns_descriptors_nsdinfoid(token=_token["id"], nsdinfoid=_nsd)) time.sleep(2) # Wait for NSD onboarding _vnfd_list = json.loads(osm_vnfpkgm.get_vnf_packages(token=_token["id"])) _vnfd_list = json.loads(_vnfd_list["data"]) _vnfd = None for _v in _vnfd_list: if "test_osm_cirros_vnfd" == _v['id']: _vnfd = _v['_id'] response = None if _vnfd: response = json.loads( osm_vnfpkgm.delete_vnf_packages_vnfpkgid(token=_token["id"], vnfPkgId=_vnfd)) assert isinstance(response, dict) assert response["data"] == "" assert isinstance(response, dict) assert response["data"] == ""
def _delete_test_ns_instance(): time.sleep(3) # Wait osm_nslcm = OSMClient.Nslcm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _ns_list = json.loads(osm_nslcm.get_ns_instances(token=_token["id"])) _ns_list = json.loads(_ns_list["data"]) _ns = None for _n in _ns_list: if "test" == _n['short-name']: _ns = _n['_id'] # time.sleep(5) #wait for NS Creation response = None if _ns: response = json.loads( osm_nslcm.post_ns_instances_nsinstanceid_terminate( token=_token["id"], nsInstanceId=_ns)) _rid = response["data"]
def test_get_project_info(get_project_info_keys): """Tests API call to get the information about individual project""" osm_admin = OSMClient.Admin(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _p_list = json.loads(osm_admin.get_project_list(token=_token["id"])) _p_list = json.loads(_p_list["data"]) _project = None for _p in _p_list: if "test" == _p['_id']: _project = _p['_id'] response = json.loads( osm_admin.get_project_info(token=_token["id"], id=_project)) if response["error"]: return True else: return False
def _delete_test_vnf(vnfname="test_osm_cirros_vnfd"): time.sleep(3) # Wait osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _vnfd_list = json.loads( osm_vnfpkgm.get_vnf_packages(token=_token["id"])) _vnfd_list = json.loads(_vnfd_list["data"]) _vnfd = None for _v in _vnfd_list: if vnfname == _v['id']: _vnfd = _v['_id'] response = None if _vnfd: response = json.loads( osm_vnfpkgm.delete_vnf_packages_vnfpkgid(token=_token["id"], vnfPkgId=_vnfd))
def test_delete_vnf_packages_vnfpkgid(delete_vnf_packages_vnfpkgid_keys): """Tests API call to delete NS descriptor resources""" osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) Helpers._upload_test_vnf() _vnfd_list = json.loads(osm_vnfpkgm.get_vnf_packages(token=_token["id"])) _vnfd_list = json.loads(_vnfd_list["data"]) _vnfd = None for _v in _vnfd_list: if "test_osm_cirros_vnfd" == _v['id']: _vnfd = _v['_id'] response = None if _vnfd: response = json.loads( osm_vnfpkgm.delete_vnf_packages_vnfpkgid(token=_token["id"], vnfPkgId=_vnfd)) assert isinstance(response, dict) assert response["data"] == ""
def test_get_ns_descriptors_nsdinfoid(): """Tests API call to read information about an individual NS descriptor resource""" osm_nsd = OSMClient.Nsd(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) Helpers._upload_test_nsd() _nsd_list = json.loads(osm_nsd.get_ns_descriptors(token=_token["id"])) _nsd_list = json.loads(_nsd_list["data"]) for _n in _nsd_list: if "test_osm_cirros_2vnf_nsd" == _n['id']: _nsd = _n['_id'] response = json.loads( osm_nsd.get_ns_descriptors_nsdinfoid(token=_token["id"], nsdinfoid=_nsd)) Helpers._delete_test_nsd() if response["error"]: return True else: return False
def test_post_ns_instances_nsinstanceid_terminate( post_ns_instances_nsinstanceid_terminate_keys): """Tests API call to delete NS instance resource""" osm_nslcm = OSMClient.Nslcm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _ns_list = json.loads(osm_nslcm.get_ns_instances(token=_token["id"])) _ns_list = json.loads(_ns_list["data"]) _ns = None for _n in _ns_list: if "test_osm_cirros_2vnf_nsd" == _n['nsd']['id']: _ns = _n['_id'] response = None if _ns: response = json.loads( osm_nslcm.post_ns_instances_nsinstanceid_terminate( token=_token["id"], nsInstanceId=_ns)) _rid = response["data"] assert isinstance(response, dict) assert response["data"] == _rid
def test_get_vnf_packages_vnfpkgid_vnfd(): """Tests API call to read VNFD of an onboarded VNF package""" osm_vnfpkgm_vnfd = OSMClient.VnfPkgm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) Helpers._upload_test_vnf() _vnfd_list = json.loads( osm_vnfpkgm_vnfd.get_vnf_packages(token=_token["id"])) _vnfd_list = json.loads(_vnfd_list["data"]) for _v in _vnfd_list: if "test_osm_cirros_vnfd" == _v['id']: _vnfd = _v['_id'] response = json.loads( osm_vnfpkgm_vnfd.get_vnf_packages_vnfpkgid_vnfd(token=_token["id"], vnfPkgId=_vnfd)) Helpers._delete_test_vnf() if response["error"]: return True else: return False
def _delete_test_nsd(nsdname="test_osm_cirros_2vnf_nsd"): osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL) osm_nsd = OSMClient.Nsd(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _nsd_list = json.loads(osm_nsd.get_ns_descriptors(token=_token["id"])) _nsd_list = json.loads(_nsd_list["data"]) _nsd = None for _n in _nsd_list: if "test_osm_cirros_2vnf_nsd" == _n['id']: _nsd = _n['_id'] time.sleep(10) # Wait for NSD onboarding response = json.loads( osm_nsd.delete_ns_descriptors_nsdinfoid(token=_token["id"], nsdinfoid=_nsd)) time.sleep(2) # Wait for NSD onboarding _vnfd_list = json.loads( osm_vnfpkgm.get_vnf_packages(token=_token["id"])) _vnfd_list = json.loads(_vnfd_list["data"]) _vnfd = None for _v in _vnfd_list: if nsdname == _v['id']: _vnfd = _v['_id'] response = None if _vnfd: response = json.loads( osm_vnfpkgm.delete_vnf_packages_vnfpkgid(token=_token["id"], vnfPkgId=_vnfd))
def test_get_ns_instances_nsinstanceid(): """Tests API call to read an individual NS instance resource""" # Helpers._upload_test_ns_instance() # time.sleep(5) # Wait for NS instantiation osm_nslcm = OSMClient.Nslcm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _ns_list = json.loads(osm_nslcm.get_ns_instances(token=_token["id"])) _ns_list = json.loads(_ns_list["data"]) _ns = None for _n in _ns_list: if "test_osm_cirros_2vnf_nsd" == _n['nsd']['id']: _ns = _n['_id'] response = json.loads( osm_nslcm.get_ns_instances_nsinstanceid(token=_token["id"], nsInstanceId=_ns)) if response["error"]: return True else: return False
DOCKER_EXCLUDE = ['experiment-runner'] IDLE_SLEEP = 1 NS_TERMINATION_SLEEP = 20 NO_INSTANCES = 100 USERNAME = "******" PASSWORD = "******" HOST_URL = "osmmano.cs.upb.de" NSNAME = "stress_case1" NSDESCRIPTION = "case1-100_NS" nsdId = "stress_case1-ns" VIMACCOUNTID = "6c74d590-aaad-4951-9200-5f1b6d8b0588" osm_nsd = OSMClient.Nsd(HOST_URL) osm_nslcm = OSMClient.Nslcm(HOST_URL) osm_auth = OSMClient.Auth(HOST_URL) HOST_URL = "osmmano.cs.upb.de" _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD)) _token = json.loads(_token["data"]) _ns_list = json.loads(osm_nslcm.get_ns_instances(token=_token["id"])) _ns_list = json.loads(_ns_list["data"]) _ns = None for _n in _ns_list: if nsdId == _n['nsd']['id']: _ns = _n['_id']