##
# DEBUG WITH PDB
-import os
-if os.getenv('OSMRO_PDB_DEBUG'):
+from os import getenv
+if getenv('OSMRO_PDB_DEBUG'):
import sys
print(sys.path)
import pdb
self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], self.__class__.test_index,
inspect.currentframe().f_code.co_name)
self.__class__.test_index += 1
+ logger.debug("Test create tenant")
tenant = test_config["client"].create_tenant(name=self.__class__.tenant_name,
description=self.__class__.tenant_name)
logger.debug("{}".format(tenant))
logger.debug("{}".format(network_list))
self.assertIsNotNone(network_list)
+
class test_vimconn_new_network(test_base):
network_name = None
network, _ = test_config["vim_conn"].new_network(net_name=self.__class__.network_name,
net_type=network_type)
self.__class__.network_id = network
- logger.debug("{}".format(network))
+ logger.debug("Created network {}".format(network))
network_list = test_config["vim_conn"].get_network_list()
+ logger.debug("Network list {}".format(network_list))
for net in network_list:
if self.__class__.network_name in net.get('name'):
self.assertIn(self.__class__.network_name, net.get('name'))
else:
logger.info("Failed to delete network id {}".format(self.__class__.network_id))
+ network_list = test_config["vim_conn"].get_network_list()
+ logger.debug("Network list after deletion {}".format(network_list))
+
def test_010_new_network_by_types(self):
delete_net_ids = []
network_types = ['data','bridge','mgmt']
self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
self.__class__.test_index,
inspect.currentframe().f_code.co_name)
+ network_list = test_config["vim_conn"].get_network_list()
+ logger.debug("Network list at start {}".format(network_list))
self.__class__.test_index += 1
for net_type in network_types:
self.__class__.network_name = _get_random_string(20)
logger.info("Network id {} sucessfully deleted".format(net_id))
else:
logger.info("Failed to delete network id {}".format(net_id))
+ network_list = test_config["vim_conn"].get_network_list()
+ logger.debug("Network list after test {}".format(network_list))
def test_020_new_network_by_ipprofile(self):
test_directory_content = os.listdir(test_config["test_directory"])
with open(vnfd, 'r') as stream:
vnf_descriptor = yaml.load(stream)
- internal_connections_list = vnf_descriptor['vnf']['internal-connections']
+ #internal_connections_list = vnf_descriptor['vnf']['internal-connections']
+ internal_connections_list = vnf_descriptor['vnfd-catalog']['vnfd'][0]['ip-profiles']
for item in internal_connections_list:
- if 'ip-profile' in item:
- version = item['ip-profile']['ip-version']
- dhcp_count = item['ip-profile']['dhcp']['count']
- dhcp_enabled = item['ip-profile']['dhcp']['enabled']
- dhcp_start_address = item['ip-profile']['dhcp']['start-address']
- subnet_address = item['ip-profile']['subnet-address']
-
+ version = item['ip-version']
+ dhcp_count = item['dhcp-params']['count']
+ dhcp_enabled = item['dhcp-params']['enabled']
+ dhcp_start_address = item['dhcp-params']['start-address']
+ subnet_address = item['subnet-address']
self.__class__.network_name = _get_random_string(20)
ip_profile = {'dhcp_count': dhcp_count,
logger.debug("{}".format(network))
network_list = test_config["vim_conn"].get_network_list()
+ logger.debug("Created network by ip_profile {}".format(network_list))
for net in network_list:
if self.__class__.network_name in net.get('name'):
self.assertIn(self.__class__.network_name, net.get('name'))
self.__class__.test_index += 1
# refresh net status
+ # if azure network name must have the following format
+ if test_config['vimtype'] == 'azure':
+ unknown_net_id = "/" + "/".join(["subscriptions", test_config["vim_conn"].subscription_id,
+ "resourceGroups", test_config["vim_conn"].resource_group,
+ "providers", "Microsoft.Network",
+ "virtualNetworks", test_config["vim_conn"].vnet_name,
+ "subnets", unknown_net_id])
+ #unknown_net_id = "/subscriptions/ca3d18ab-d373-4afb-a5d6-7c44f098d16a/resourceGroups/osmRG/providers/Microsoft.Network/virtualNetworks/osm_vnet/subnets/unnkown_net"
+
net_dict = test_config["vim_conn"].refresh_nets_status([unknown_net_id])
if test_config['vimtype'] in ('openstack', 'azure'):
self.assertEqual(net_dict[unknown_net_id]['status'], 'DELETED')
flavor_id = test_config["vim_conn"].new_flavor(flavor_data)
# get flavor by id
result = test_config["vim_conn"].get_flavor(flavor_id)
-
- if test_config['vimtype'] != 'azure':
- self.assertEqual(ram, result['ram'])
- self.assertEqual(vcpus, result['vcpus'])
- self.assertEqual(disk, result['disk'])
- else:
- self.assertTrue(ram <= result['ram'])
- self.assertTrue(vcpus <= result['vcpus'])
- self.assertTrue(disk <= result['disk'])
+ self.assertEqual(ram, result['ram'])
+ self.assertEqual(vcpus, result['vcpus'])
+ self.assertEqual(disk, result['disk'])
# delete flavor
- if test_config['vimtype'] != 'azure':
- result = test_config["vim_conn"].delete_flavor(flavor_id)
- if result:
- logger.info("Flavor id {} sucessfully deleted".format(result))
- else:
- logger.info("Failed to delete flavor id {}".format(result))
+ result = test_config["vim_conn"].delete_flavor(flavor_id)
+ if result:
+ logger.info("Flavor id {} sucessfully deleted".format(result))
+ else:
+ logger.info("Failed to delete flavor id {}".format(result))
def test_010_get_flavor_negative(self):
Non_exist_flavor_id = str(uuid.uuid4())
inspect.currentframe().f_code.co_name)
self.__class__.test_index += 1
- # create new flavor
- self.__class__.flavor_id = test_config["vim_conn"].new_flavor(flavor_data)
- self.assertIsInstance(self.__class__.flavor_id, (str, unicode))
- self.assertIsInstance(uuid.UUID(self.__class__.flavor_id), uuid.UUID)
+ if test_config['vimtype'] == 'azure':
+ with self.assertRaises(Exception) as context:
+ test_config["vim_conn"].new_flavor(flavor_data)
+
+ self.assertEqual((context.exception).http_code, 401)
+ else:
+ # create new flavor
+ self.__class__.flavor_id = test_config["vim_conn"].new_flavor(flavor_data)
+ self.assertIsInstance(self.__class__.flavor_id, (str, unicode))
+ self.assertIsInstance(uuid.UUID(self.__class__.flavor_id), uuid.UUID)
def test_010_delete_flavor(self):
self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
with self.assertRaises(Exception) as context:
test_config["vim_conn"].new_flavor(Invalid_flavor_data)
-
- if test_config['vimtype'] == 'azure':
- self.assertEqual((context.exception).http_code, 404)
- else:
+ if test_config['vimtype'] != 'azure':
self.assertEqual((context.exception).http_code, 400)
+ else:
+ self.assertEqual((context.exception).http_code, 401)
def test_030_delete_flavor_negative(self):
Non_exist_flavor_id = str(uuid.uuid4())
with self.assertRaises(Exception) as context:
test_config["vim_conn"].delete_flavor(Non_exist_flavor_id)
- if test_config['vimtype'] == 'azure':
- self.assertEqual((context.exception).http_code, 401)
- else:
+ if test_config['vimtype'] != 'azure':
self.assertEqual((context.exception).http_code, 404)
-
-class test_vimconn_new_image(test_base):
-
- def test_000_new_image(self):
- self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
- self.__class__.test_index,
- inspect.currentframe().f_code.co_name)
- self.__class__.test_index += 1
-
- image_path = test_config['image_path']
- if image_path:
- self.__class__.image_id = test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : image_path,
- 'metadata': {'upload_location':None} })
- time.sleep(20)
-
- self.assertIsInstance(self.__class__.image_id, (str, unicode))
- self.assertIsInstance(uuid.UUID(self.__class__.image_id), uuid.UUID)
- else:
- self.skipTest("Skipping test as image file not present at RO container")
-
- def test_010_new_image_negative(self):
- Non_exist_image_path = '/temp1/cirros.ovf'
-
- self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
- self.__class__.test_index,
- inspect.currentframe().f_code.co_name)
- self.__class__.test_index += 1
-
- with self.assertRaises(Exception) as context:
- test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : Non_exist_image_path})
-
- self.assertEqual((context.exception).http_code, 400)
-
- def test_020_delete_image(self):
- self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
- self.__class__.test_index,
- inspect.currentframe().f_code.co_name)
- self.__class__.test_index += 1
-
- image_id = test_config["vim_conn"].delete_image(self.__class__.image_id)
-
- self.assertIsInstance(image_id, (str, unicode))
-
- def test_030_delete_image_negative(self):
- Non_exist_image_id = str(uuid.uuid4())
-
- self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
- self.__class__.test_index,
- inspect.currentframe().f_code.co_name)
- self.__class__.test_index += 1
-
- with self.assertRaises(Exception) as context:
- test_config["vim_conn"].delete_image(Non_exist_image_id)
-
- self.assertEqual((context.exception).http_code, 404)
-
-class test_vimconn_get_image_id_from_path(test_base):
-
- def test_000_get_image_id_from_path(self):
- self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
- self.__class__.test_index,
- inspect.currentframe().f_code.co_name)
- self.__class__.test_index += 1
-
- image_path = test_config['image_path']
- if image_path:
- image_id = test_config["vim_conn"].get_image_id_from_path( image_path )
- self.assertEqual(type(image_id),str)
else:
- self.skipTest("Skipping test as image file not present at RO container")
-
- def test_010_get_image_id_from_path_negative(self):
- Non_exist_image_path = '/temp1/cirros.ovf'
-
- self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
- self.__class__.test_index,
- inspect.currentframe().f_code.co_name)
- self.__class__.test_index += 1
+ self.assertEqual((context.exception).http_code, 401)
- with self.assertRaises(Exception) as context:
- test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : Non_exist_image_path })
+# class test_vimconn_new_image(test_base):
+#
+# def test_000_new_image(self):
+# self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+# self.__class__.test_index,
+# inspect.currentframe().f_code.co_name)
+# self.__class__.test_index += 1
+#
+# image_path = test_config['image_path']
+# if image_path:
+# self.__class__.image_id = test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : image_path, 'metadata': {'upload_location':None} })
+# time.sleep(20)
+#
+# self.assertIsInstance(self.__class__.image_id, (str, unicode))
+# self.assertIsInstance(uuid.UUID(self.__class__.image_id), uuid.UUID)
+# else:
+# self.skipTest("Skipping test as image file not present at RO container")
+#
+# def test_010_new_image_negative(self):
+# Non_exist_image_path = '/temp1/cirros.ovf'
+#
+# self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+# self.__class__.test_index,
+# inspect.currentframe().f_code.co_name)
+# self.__class__.test_index += 1
+#
+# with self.assertRaises(Exception) as context:
+# test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : Non_exist_image_path})
+#
+# self.assertEqual((context.exception).http_code, 400)
+#
+# def test_020_delete_image(self):
+# self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+# self.__class__.test_index,
+# inspect.currentframe().f_code.co_name)
+# self.__class__.test_index += 1
+#
+# image_id = test_config["vim_conn"].delete_image(self.__class__.image_id)
+#
+# self.assertIsInstance(image_id, (str, unicode))
+#
+# def test_030_delete_image_negative(self):
+# Non_exist_image_id = str(uuid.uuid4())
+#
+# self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+# self.__class__.test_index,
+# inspect.currentframe().f_code.co_name)
+# self.__class__.test_index += 1
+#
+# with self.assertRaises(Exception) as context:
+# test_config["vim_conn"].delete_image(Non_exist_image_id)
+#
+# self.assertEqual((context.exception).http_code, 404)
- self.assertEqual((context.exception).http_code, 400)
+# class test_vimconn_get_image_id_from_path(test_base):
+#
+# def test_000_get_image_id_from_path(self):
+# self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+# self.__class__.test_index,
+# inspect.currentframe().f_code.co_name)
+# self.__class__.test_index += 1
+#
+# image_path = test_config['image_path']
+# if image_path:
+# image_id = test_config["vim_conn"].get_image_id_from_path( image_path )
+# self.assertEqual(type(image_id),str)
+# else:
+# self.skipTest("Skipping test as image file not present at RO container")
+#
+# def test_010_get_image_id_from_path_negative(self):
+# Non_exist_image_path = '/temp1/cirros.ovf'
+#
+# self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
+# self.__class__.test_index,
+# inspect.currentframe().f_code.co_name)
+# self.__class__.test_index += 1
+#
+# with self.assertRaises(Exception) as context:
+# test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : Non_exist_image_path })
+#
+# self.assertEqual((context.exception).http_code, 400)
class test_vimconn_get_image_list(test_base):
image_name = None
inspect.currentframe().f_code.co_name)
self.__class__.test_index += 1
- if test_config['image_name']:
- image_list = test_config['vim_conn'].get_image_list({'name': test_config['image_name']})
- else:
+ if test_config['vimtype'] != 'azure':
image_list = test_config["vim_conn"].get_image_list()
-
- for item in image_list:
- if 'name' in item:
- self.__class__.image_name = item['name']
- self.__class__.image_id = item['id']
- self.assertIsInstance(self.__class__.image_name, (str, unicode))
- self.assertIsInstance(self.__class__.image_id, (str, unicode))
+ logger.debug("{}: Result image list: {}".format(self.__class__.test_text, image_list))
+
+ for item in image_list:
+ if 'name' in item:
+ self.__class__.image_name = item['name']
+ self.__class__.image_id = item['id']
+ self.assertIsInstance(self.__class__.image_name, (str, unicode))
+ self.assertIsInstance(self.__class__.image_id, (str, unicode))
+ else:
+ with self.assertRaises(Exception) as context:
+ image_list = test_config["vim_conn"].get_image_list()
+ self.assertEqual((context.exception).http_code, 401)
+ logger.debug(self.__class__.test_text + "Exception unauthorized: " + str(context.exception))
def test_010_get_image_list_by_name(self):
self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
self.__class__.test_index,
inspect.currentframe().f_code.co_name)
self.__class__.test_index += 1
+ self.__class__.image_name = test_config['image_name']
+ logger.debug("{}: Image name: {}".format(self.__class__.test_text, self.__class__.image_name))
image_list = test_config["vim_conn"].get_image_list({'name': self.__class__.image_name})
+ logger.debug("{}: Result image list: {}".format(self.__class__.test_text, image_list))
for item in image_list:
self.assertIsInstance(item['id'], (str, unicode))
self.assertIsInstance(item['name'], (str, unicode))
- self.assertEqual(item['id'], self.__class__.image_id)
+ #self.assertEqual(item['id'], self.__class__.image_id)
self.assertEqual(item['name'], self.__class__.image_name)
def test_020_get_image_list_by_id(self):
for action in action_list:
# sleep for sometime till status is changed
time.sleep(25)
- instance_id = test_config["vim_conn"].action_vminstance(new_instance_id, {action: None})
+ instance_id = test_config["vim_conn"].action_vminstance(new_instance_id,
+ { action: None})
self.assertTrue(instance_id is None)
- #Deleting created vm instance
+ # Deleting created vm instance
logger.info("Deleting created vm intance")
test_config["vim_conn"].delete_vminstance(new_instance_id)
time.sleep(10)
# Getting tenant list
tenant_list = test_config["vim_conn"].get_tenant_list()
+ logger.debug(self.__class__.test_text + "Tenant list: " + str(tenant_list))
for item in tenant_list:
if test_config['tenant'] == item['name']:
# Getting filter tenant list by its id
filter_tenant_list = test_config["vim_conn"].get_tenant_list({'id': self.__class__.tenant_id})
+ logger.debug(self.__class__.test_text + "Tenant list: " + str(filter_tenant_list))
for item in filter_tenant_list:
self.assertIsInstance(item['id'], (str, unicode))
# Getting filter tenant list by its name
filter_tenant_list = test_config["vim_conn"].get_tenant_list({'name': test_config['tenant']})
+ logger.debug(self.__class__.test_text + "Tenant list: " + str(filter_tenant_list))
for item in filter_tenant_list:
self.assertIsInstance(item['name'], (str, unicode))
# Getting filter tenant list by its name and id
filter_tenant_list = test_config["vim_conn"].get_tenant_list({'name': test_config['tenant'],
'id': self.__class__.tenant_id})
+ logger.debug(self.__class__.test_text + "Tenant list: " + str(filter_tenant_list))
for item in filter_tenant_list:
self.assertIsInstance(item['name'], (str, unicode))
filter_tenant_list = test_config["vim_conn"].get_tenant_list({'name': non_exist_tenant_name,
'id': non_exist_tenant_id})
+ logger.debug(self.__class__.test_text + "Tenant list: " + str(filter_tenant_list))
self.assertEqual(filter_tenant_list, [])
self.assertIsInstance(self.__class__.tenant_id, (str, unicode))
else:
with self.assertRaises(Exception) as context:
- test_config["vim_conn"].new_tenant(self.__class__.tenant_id)
+ test_config["vim_conn"].new_tenant(self.__class__.tenant_id, "")
self.assertEqual((context.exception).http_code, 401)
+ logger.debug(self.__class__.test_text + "Exception unauthorized: " + str(context.exception))
def test_010_new_tenant_negative(self):
self.assertEqual((context.exception).http_code, 400)
else:
self.assertEqual((context.exception).http_code, 401)
+ logger.debug(self.__class__.test_text + "Exception unauthorized: " + str(context.exception))
def test_020_delete_tenant(self):
with self.assertRaises(Exception) as context:
test_config["vim_conn"].delete_tenant(self.__class__.tenant_id)
self.assertEqual((context.exception).http_code, 401)
+ logger.debug(self.__class__.test_text + "Exception unauthorized: " + str(context.exception))
def test_030_delete_tenant_negative(self):
- Non_exist_tenant_name = 'Test_30_tenant'
+ non_exist_tenant_name = 'Test_30_tenant'
self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"],
self.__class__.test_index,
inspect.currentframe().f_code.co_name)
self.__class__.test_index += 1
with self.assertRaises(Exception) as context:
- test_config["vim_conn"].delete_tenant(Non_exist_tenant_name)
+ test_config["vim_conn"].delete_tenant(non_exist_tenant_name)
if test_config['vimtype'] != 'azure':
self.assertEqual((context.exception).http_code, 404)
else:
self.assertEqual((context.exception).http_code, 401)
+ logger.debug(self.__class__.test_text + "Exception unauthorized: " + str(context.exception))
def get_image_id():
'port_security': True, 'type': 'virtual', 'net_id': net_id})
c = c+1
- instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False,
- image_id=image_id, flavor_id=flavor_id, net_list=net_list)
+ instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=image_id,
+ flavor_id=flavor_id, net_list=net_list)
self.assertEqual(type(instance_id),str)
logger.info("Deleting created vm instance")
test_config['image_path'] = args.image_path
test_config['image_name'] = args.image_name
#test_config['sriov_net_name'] = args.sriov_net_name
+ args_log_level = "DEBUG" if args.debug else "INFO"
# azure connector obj
vim_persistent_info = {}
uuid="test-uuid-1", name="VIO-azure",
tenant_id=None, tenant_name=tenant_name,
url=vim_url, url_admin=None,
- user=os_user, passwd=os_passwd,
+ user=os_user, passwd=os_passwd, log_level= args_log_level,
config=config_params, persistent_info=vim_persistent_info
)
test_config['vim_conn'].debug = "true"