vim_data = "{schema_version: '1.0', name: fakeVim, vim_type: openstack, vim_url: 'http://10.11.12.13/fake'"\
", vim_tenant_name: 'vimtenant', vim_user: vimuser, vim_password: vimpassword}"
self.test("Create VIM", "POST", "/admin/v1/vim_accounts", headers_yaml, vim_data,
- (201), {"Location": "/admin/v1/vim_accounts/", "Content-Type": "application/yaml"}, "yaml")
+ (201, 202), {"Location": "/admin/v1/vim_accounts/", "Content-Type": "application/yaml"}, "yaml")
return self.last_id
def print_results(self):
engine.remove_authorization() # To finish
+class TestProjectsDescriptors:
+ description = "test descriptors visibility among projects"
+
+ @staticmethod
+ def run(engine, test_osm, manual_check, test_params=None):
+ vnfd_ids = []
+ engine.set_test_name("ProjectDescriptors")
+ engine.get_autorization()
+
+ project_admin_id = None
+ res = engine.test("Get my project Padmin", "GET", "/admin/v1/projects/{}".format(engine.project), headers_json,
+ None, 200, r_header_json, "json")
+ if res:
+ response = res.json()
+ project_admin_id = response["_id"]
+ engine.test("Create project Padmin", "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 P2", "POST", "/admin/v1/projects", headers_json, {"name": "P2"},
+ (201, 204), {"Location": "/admin/v1/projects/", "Content-Type": "application/json"}, "json")
+ engine.test("Create project P3", "POST", "/admin/v1/projects", headers_json, {"name": "P3"},
+ (201, 204), {"Location": "/admin/v1/projects/", "Content-Type": "application/json"}, "json")
+
+ engine.test("Create user U1", "POST", "/admin/v1/users", headers_json,
+ {"username": "U1", "password": "pw1",
+ "project_role_mappings": [{"project": "Padmin", "role": "system_admin"},
+ {"project": "P2", "role": "project_admin"},
+ {"project": "P3", "role": "project_admin"}],
+ }, 201, {"Location": "/admin/v1/users/", "Content-Type": "application/json"}, "json")
+
+ engine.test("Onboard VNFD id1", "POST", "/vnfpkgm/v1/vnf_packages_content?id=id1", headers_yaml,
+ TestDescriptors.vnfd_empty, 201, r_headers_yaml_location_vnfd, "yaml")
+ vnfd_ids.append(engine.last_id)
+ engine.test("Onboard VNFD id2 PUBLIC", "POST", "/vnfpkgm/v1/vnf_packages_content?id=id2&PUBLIC=TRUE",
+ headers_yaml, TestDescriptors.vnfd_empty, 201, r_headers_yaml_location_vnfd, "yaml")
+ vnfd_ids.append(engine.last_id)
+ engine.test("Onboard VNFD id3", "POST", "/vnfpkgm/v1/vnf_packages_content?id=id3&PUBLIC=FALSE", headers_yaml,
+ TestDescriptors.vnfd_empty, 201, r_headers_yaml_location_vnfd, "yaml")
+ vnfd_ids.append(engine.last_id)
+
+ res = engine.test("Get VNFD descriptors", "GET", "/vnfpkgm/v1/vnf_packages?id=id1,id2,id3",
+ headers_json, None, 200, r_header_json, "json")
+ response = res.json()
+ if len(response) != 3:
+ logger.error("Only 3 vnfds should be present for project admin. {} listed".format(len(response)))
+ engine.failed_tests += 1
+
+ # Change to other project Padmin
+ res = engine.test("Change to user U1 project Padmin", "POST", "/admin/v1/tokens", headers_json,
+ {"username": "U1", "password": "pw1", "project_id": "Padmin"}, (200, 201),
+ r_header_json, "json")
+ if res:
+ response = res.json()
+ engine.set_header({"Authorization": "Bearer {}".format(response["id"])})
+
+ # list vnfds
+ res = engine.test("List VNFD descriptors for Padmin", "GET", "/vnfpkgm/v1/vnf_packages",
+ headers_json, None, 200, r_header_json, "json")
+ response = res.json()
+ if len(response) != 0:
+ logger.error("Only 0 vnfds should be present for project Padmin. {} listed".format(len(response)))
+ engine.failed_tests += 1
+
+ # list Public vnfds
+ res = engine.test("List VNFD public descriptors", "GET", "/vnfpkgm/v1/vnf_packages?PUBLIC=True",
+ headers_json, None, 200, r_header_json, "json")
+ response = res.json()
+ if len(response) != 1:
+ logger.error("Only 1 vnfds should be present for project Padmin. {} listed".format(len(response)))
+ engine.failed_tests += 1
+
+ # list vnfds belonging to project "admin"
+ res = engine.test("List VNFD of admin project", "GET",
+ "/vnfpkgm/v1/vnf_packages?ADMIN={}".format(project_admin_id),
+ headers_json, None, 200, r_header_json, "json")
+ response = res.json()
+ if len(response) != 3:
+ logger.error("Only 3 vnfds should be present for project Padmin. {} listed".format(len(response)))
+ engine.failed_tests += 1
+
+ # Get Public vnfds
+ engine.test("Get VNFD public descriptors", "GET", "/vnfpkgm/v1/vnf_packages/{}".format(vnfd_ids[1]),
+ headers_json, None, 200, r_header_json, "json")
+ # Edit not owned vnfd
+ engine.test("Edit VNFD ", "PATCH", "/vnfpkgm/v1/vnf_packages/{}".format(vnfd_ids[0]),
+ headers_yaml, '{name: pepe}', 404, r_header_yaml, "yaml")
+
+ # Add to my catalog
+ engine.test("Add VNFD id2 to my catalog", "PATCH", "/vnfpkgm/v1/vnf_packages/{}?SET_PROJECT".
+ format(vnfd_ids[1]), headers_json, None, 204, None, 0)
+
+ # Add a new vnfd
+ engine.test("Onboard VNFD id4", "POST", "/vnfpkgm/v1/vnf_packages_content?id=id4", headers_yaml,
+ TestDescriptors.vnfd_empty, 201, r_headers_yaml_location_vnfd, "yaml")
+ vnfd_ids.append(engine.last_id)
+
+ # list vnfds
+ res = engine.test("List VNFD public descriptors", "GET", "/vnfpkgm/v1/vnf_packages",
+ headers_json, None, 200, r_header_json, "json")
+ response = res.json()
+ if len(response) != 2:
+ logger.error("Only 2 vnfds should be present for project Padmin. {} listed".format(len(response)))
+ engine.failed_tests += 1
+
+ if manual_check:
+ input('VNFDs have been omboarded. Perform manual check and press enter to resume')
+
+ test_rest.test("Delete VNFD id2", "DELETE", "/vnfpkgm/v1/vnf_packages/{}".format(vnfd_ids[1]),
+ headers_yaml, None, 204, None, 0)
+
+ # change to admin project
+ engine.remove_authorization() # To force get authorization
+ engine.get_autorization()
+ test_rest.test("Delete VNFD id1", "DELETE", "/vnfpkgm/v1/vnf_packages/{}".format(vnfd_ids[0]),
+ headers_yaml, None, 204, None, 0)
+ test_rest.test("Delete VNFD id2", "DELETE", "/vnfpkgm/v1/vnf_packages/{}".format(vnfd_ids[1]),
+ headers_yaml, None, 204, None, 0)
+ test_rest.test("Delete VNFD id3", "DELETE", "/vnfpkgm/v1/vnf_packages/{}".format(vnfd_ids[2]),
+ headers_yaml, None, 204, None, 0)
+ test_rest.test("Delete VNFD id4", "DELETE", "/vnfpkgm/v1/vnf_packages/{}".format(vnfd_ids[3]),
+ headers_yaml, None, 404, r_header_yaml, "yaml")
+ test_rest.test("Delete VNFD id4", "DELETE", "/vnfpkgm/v1/vnf_packages/{}?ADMIN".format(vnfd_ids[3]),
+ headers_yaml, None, 204, None, 0)
+ # Get Public vnfds
+ engine.test("Get VNFD deleted id1", "GET", "/vnfpkgm/v1/vnf_packages/{}?ADMIN".format(vnfd_ids[0]),
+ headers_json, None, 404, r_header_json, "json")
+ engine.test("Get VNFD deleted id2", "GET", "/vnfpkgm/v1/vnf_packages/{}?ADMIN".format(vnfd_ids[1]),
+ headers_json, None, 404, r_header_json, "json")
+ engine.test("Get VNFD deleted id3", "GET", "/vnfpkgm/v1/vnf_packages/{}?ADMIN".format(vnfd_ids[2]),
+ headers_json, None, 404, r_header_json, "json")
+ engine.test("Get VNFD deleted id4", "GET", "/vnfpkgm/v1/vnf_packages/{}?ADMIN".format(vnfd_ids[3]),
+ headers_json, None, 404, r_header_json, "json")
+
+ engine.test("Delete user U1", "DELETE", "/admin/v1/users/U1", headers_json, None, 204, None, None)
+ engine.test("Delete project Padmin", "DELETE", "/admin/v1/projects/Padmin", headers_json, None, 204, None, None)
+ engine.test("Delete project P2", "DELETE", "/admin/v1/projects/P2", headers_json, None, 204, None, None)
+ engine.test("Delete project P3", "DELETE", "/admin/v1/projects/P3", headers_json, None, 204, None, None)
+
+
class TestFakeVim:
description = "Creates/edit/delete fake VIMs and SDN controllers"
engine.set_test_name("FakeVim")
engine.get_autorization()
- engine.test("Create VIM", "POST", "/admin/v1/vim_accounts", headers_json, self.vim, (201, 204),
+ engine.test("Create VIM", "POST", "/admin/v1/vim_accounts", headers_json, self.vim, (201, 202),
{"Location": "/admin/v1/vim_accounts/", "Content-Type": "application/json"}, "json")
vim_id = engine.last_id
engine.test("Create VIM without name, bad schema", "POST", "/admin/v1/vim_accounts", headers_json,
engine.set_test_name("VimSdn")
engine.get_autorization()
# Added SDN
- engine.test("Create SDN", "POST", "/admin/v1/sdns", headers_json, self.sdn, (201, 204),
+ engine.test("Create SDN", "POST", "/admin/v1/sdns", headers_json, self.sdn, (201, 202),
{"Location": "/admin/v1/sdns/", "Content-Type": "application/json"}, "json")
sdnc_id = engine.last_id
# sleep(5)
# Edit SDN
engine.test("Edit SDN", "PATCH", "/admin/v1/sdns/{}".format(sdnc_id), headers_json, {"name": "new_sdn_name"},
- 204, None, None)
+ (202, 204), None, None)
# sleep(5)
# VIM with SDN
self.vim["config"]["sdn-controller"] = sdnc_id
self.vim["config"]["sdn-port-mapping"] = self.port_mapping
- engine.test("Create VIM", "POST", "/admin/v1/vim_accounts", headers_json, self.vim, (200, 204, 201),
+ engine.test("Create VIM", "POST", "/admin/v1/vim_accounts", headers_json, self.vim, (200, 202, 201),
{"Location": "/admin/v1/vim_accounts/", "Content-Type": "application/json"}, "json"),
vim_id = engine.last_id
self.port_mapping[0]["compute_node"] = "compute node XX"
engine.test("Edit VIM change port-mapping", "PUT", "/admin/v1/vim_accounts/{}".format(vim_id), headers_json,
- {"config": {"sdn-port-mapping": self.port_mapping}}, 204, None, None)
+ {"config": {"sdn-port-mapping": self.port_mapping}}, (202, 204), None, None)
engine.test("Edit VIM remove port-mapping", "PUT", "/admin/v1/vim_accounts/{}".format(vim_id), headers_json,
- {"config": {"sdn-port-mapping": None}}, 204, None, None)
+ {"config": {"sdn-port-mapping": None}}, (202, 204), None, None)
- engine.test("Create WIM", "POST", "/admin/v1/wim_accounts", headers_json, self.wim, (200, 204, 201),
+ engine.test("Create WIM", "POST", "/admin/v1/wim_accounts", headers_json, self.wim, (200, 202, 201),
{"Location": "/admin/v1/wim_accounts/", "Content-Type": "application/json"}, "json"),
wim_id = engine.last_id
ns_data_text = yaml.safe_dump(ns_data, default_flow_style=True, width=256)
# create NS Two steps
r = engine.test("Create NS step 1", "POST", "/nslcm/v1/ns_instances",
- headers_yaml, ns_data_text, 201,
+ headers_yaml, ns_data_text, (201, 202),
{"Location": "nslcm/v1/ns_instances/", "Content-Type": "application/yaml"}, "yaml")
if not r:
return
self.ns_id = engine.last_id
engine.test("Instantiate NS step 2", "POST",
"/nslcm/v1/ns_instances/{}/instantiate".format(self.ns_id), headers_yaml, ns_data_text,
- 201, r_headers_yaml_location_nslcmop, "yaml")
+ (201, 202), r_headers_yaml_location_nslcmop, "yaml")
nslcmop_id = engine.last_id
if test_osm:
# remove deployment
if test_osm:
engine.test("Terminate NS", "POST", "/nslcm/v1/ns_instances/{}/terminate".format(self.ns_id), headers_yaml,
- None, 201, r_headers_yaml_location_nslcmop, "yaml")
+ None, (201, 202), r_headers_yaml_location_nslcmop, "yaml")
nslcmop2_id = engine.last_id
# Wait until status is Ok
engine.wait_operation_ready("ns", nslcmop2_id, timeout_deploy)
self.test_name = "CIRROS-SCALE"
self.vnfd_filenames = ("cirros_vnf.tar.gz",)
self.nsd_filename = "cirros_2vnf_ns.tar.gz"
-
- def create_descriptors(self, engine):
- super().create_descriptors(engine)
# Modify VNFD to add scaling and count=2
self.descriptor_edit = {
"vnfd0": {
for i in range(0, 2):
engine.test("Execute scale action over NS", "POST",
"/nslcm/v1/ns_instances/{}/scale".format(self.ns_id), headers_yaml, payload,
- 201, r_headers_yaml_location_nslcmop, "yaml")
+ (201, 202), r_headers_yaml_location_nslcmop, "yaml")
nslcmop2_scale_out = engine.last_id
engine.wait_operation_ready("ns", nslcmop2_scale_out, timeout_deploy)
if manual_check:
for i in range(0, 2):
engine.test("Execute scale IN action over NS", "POST",
"/nslcm/v1/ns_instances/{}/scale".format(self.ns_id), headers_yaml, payload,
- 201, r_headers_yaml_location_nslcmop, "yaml")
+ (201, 202), r_headers_yaml_location_nslcmop, "yaml")
nslcmop2_scale_in = engine.last_id
engine.wait_operation_ready("ns", nslcmop2_scale_in, timeout_deploy)
if manual_check:
# perform scale in that must fail as reached limit
engine.test("Execute scale IN out of limit action over NS", "POST",
"/nslcm/v1/ns_instances/{}/scale".format(self.ns_id), headers_yaml, payload,
- 201, r_headers_yaml_location_nslcmop, "yaml")
+ (201, 202), r_headers_yaml_location_nslcmop, "yaml")
nslcmop2_scale_in = engine.last_id
engine.wait_operation_ready("ns", nslcmop2_scale_in, timeout_deploy, expected_fail=True)
self.users = {'1': "ubuntu", '2': "ubuntu"}
self.passwords = {'1': "osm4u", '2': "osm4u"}
self.descriptor_edit = {
- "vnfd0": yaml.full_load(
+ "vnfd0": yaml.safe_load(
"""
vnf-configuration:
terminate-config-primitive:
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,
- 201, r_headers_yaml_location_nslcmop, "yaml")
+ (201, 202), r_headers_yaml_location_nslcmop, "yaml")
nslcmop2_action = engine.last_id
# Wait until status is Ok
engine.wait_operation_ready("ns", nslcmop2_action, timeout_deploy)
# '{scaling-group-descriptor: scale_dataVM, member-vnf-index: "1"}}}'
# engine.test("Execute scale action over NS", "POST",
# "/nslcm/v1/ns_instances/{}/scale".format(self.ns_id), headers_yaml, payload,
- # 201, r_headers_yaml_location_nslcmop, "yaml")
+ # (201, 202), r_headers_yaml_location_nslcmop, "yaml")
# nslcmop2_scale_out = engine.last_id
# engine.wait_operation_ready("ns", nslcmop2_scale_out, timeout_deploy)
# if manual_check:
# '{scaling-group-descriptor: scale_dataVM, member-vnf-index: "1"}}}'
# engine.test("Execute scale action over NS", "POST",
# "/nslcm/v1/ns_instances/{}/scale".format(self.ns_id), headers_yaml, payload,
- # 201, r_headers_yaml_location_nslcmop, "yaml")
+ # (201, 202), r_headers_yaml_location_nslcmop, "yaml")
# nslcmop2_scale_in = engine.last_id
# engine.wait_operation_ready("ns", nslcmop2_scale_in, timeout_deploy)
# if manual_check:
'{scaling-group-descriptor: scale_dataVM, member-vnf-index: "1"}}}'
engine.test("Execute scale action over NS", "POST",
"/nslcm/v1/ns_instances/{}/scale".format(self.ns_id), headers_yaml, payload,
- 201, r_headers_yaml_location_nslcmop, "yaml")
+ (201, 202), r_headers_yaml_location_nslcmop, "yaml")
nslcmop2_scale_out = engine.last_id
engine.wait_operation_ready("ns", nslcmop2_scale_out, timeout_deploy)
if manual_check:
'{scaling-group-descriptor: scale_dataVM, member-vnf-index: "1"}}}'
engine.test("Execute scale action over NS", "POST",
"/nslcm/v1/ns_instances/{}/scale".format(self.ns_id), headers_yaml, payload,
- 201, r_headers_yaml_location_nslcmop, "yaml")
+ (201, 202), r_headers_yaml_location_nslcmop, "yaml")
nslcmop2_scale_in = engine.last_id
engine.wait_operation_ready("ns", nslcmop2_scale_in, timeout_deploy)
if manual_check:
class TestDescriptors:
description = "Test VNFD, NSD, PDU descriptors CRUD and dependencies"
+ vnfd_empty = """vnfd:vnfd-catalog:
+ vnfd:
+ - name: prova
+ short-name: prova
+ id: prova
+ """
+ vnfd_prova = """vnfd:vnfd-catalog:
+ vnfd:
+ - connection-point:
+ - name: cp_0h8m
+ type: VPORT
+ id: prova
+ name: prova
+ short-name: prova
+ vdu:
+ - id: vdu_z4bm
+ image: ubuntu
+ interface:
+ - external-connection-point-ref: cp_0h8m
+ name: eth0
+ virtual-interface:
+ type: VIRTIO
+ name: vdu_z4bm
+ version: '1.0'
+ """
def __init__(self):
self.vnfd_filename = "hackfest_3charmed_vnfd.tar.gz"
self.descriptor_url = "https://osm-download.etsi.org/ftp/osm-3.0-three/2nd-hackfest/packages/"
self.vnfd_id = None
self.nsd_id = None
- self.vnfd_empty = """vnfd:vnfd-catalog:
- vnfd:
- - name: prova
- short-name: prova
- id: prova
- """
- self.vnfd_prova = """vnfd:vnfd-catalog:
- vnfd:
- - connection-point:
- - name: cp_0h8m
- type: VPORT
- id: prova
- name: prova
- short-name: prova
- vdu:
- - id: vdu_z4bm
- image: ubuntu
- interface:
- - external-connection-point-ref: cp_0h8m
- name: eth0
- virtual-interface:
- type: VIRTIO
- name: vdu_z4bm
- version: '1.0'
- """
def run(self, engine, test_osm, manual_check, test_params=None):
engine.set_test_name("Descriptors")
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,
+ headers_yaml, ns_data_text, (201, 202),
{"Location": "nsilcm/v1/netslice_instances/", "Content-Type": "application/yaml"}, "yaml")
return r
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")
+ (201, 202), 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")
+ headers_yaml, None, (201, 202), 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,
test_classes = {
"NonAuthorized": TestNonAuthorized,
"FakeVIM": TestFakeVim,
- "TestUsersProjects": TestUsersProjects,
+ "Users-Projects": TestUsersProjects,
+ "Projects-Descriptors": TestProjectsDescriptors,
"VIM-SDN": TestVIMSDN,
"Deploy-Custom": TestDeploy,
"Deploy-Hackfest-Cirros": TestDeployHackfestCirros,
"Deploy-Hackfest-3Charmed3": TestDeployHackfest3Charmed3,
"Deploy-Hackfest-4": TestDeployHackfest4,
"Deploy-CirrosMacIp": TestDeployIpMac,
- "TestDescriptors": TestDescriptors,
- "TestDeployHackfest1": TestDeployHackfest1,
+ "Descriptors": TestDescriptors,
+ "Deploy-Hackfest1": TestDeployHackfest1,
# "Deploy-MultiVIM": TestDeployMultiVIM,
- "DeploySingleVdu": TestDeploySingleVdu,
- "DeployHnfd": TestDeployHnfd,
+ "Deploy-SingleVdu": TestDeploySingleVdu,
+ "Deploy-Hnfd": TestDeployHnfd,
"Upload-Slice-Template": TestNetSliceTemplates,
"Deploy-Slice-Instance": TestNetSliceInstances,
- "TestDeploySimpleCharm": TestDeploySimpleCharm,
- "TestDeploySimpleCharm2": TestDeploySimpleCharm2,
+ "Deploy-SimpleCharm": TestDeploySimpleCharm,
+ "Deploy-SimpleCharm2": TestDeploySimpleCharm2,
}
test_to_do = []
test_params = {}