X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=test%2Ftest_RO.py;h=42bc9cbda5a0947b50bd9ce6d691f5ffcf338d96;hb=6082b7d161e7ccfbb38c1b7938c88c2619b8f690;hp=21af36cdb08dee9cc9fa7716f629696e9d171753;hpb=114050ebb5d734d4e45ee2584a7a48081791dc8e;p=osm%2FRO.git diff --git a/test/test_RO.py b/test/test_RO.py index 21af36cd..42bc9cbd 100755 --- a/test/test_RO.py +++ b/test/test_RO.py @@ -20,33 +20,33 @@ # ## -''' +""" Module for testing openmano functionality. It uses openmanoclient.py for invoking openmano -''' -__author__ = "Pablo Montes, Alfonso Tierno" -__date__ = "$16-Feb-2017 17:08:16$" -__version__ = "0.0.4" -version_date = "Jun 2017" +""" import logging import os -from argparse import ArgumentParser import argcomplete import unittest import string import inspect import random -import traceback +# import traceback import glob import yaml import sys import time -from pyvcloud.vcloudair import VCA import uuid import json +from argparse import ArgumentParser + +__author__ = "Pablo Montes, Alfonso Tierno" +__date__ = "$16-Feb-2017 17:08:16$" +__version__ = "0.1.0" +version_date = "Oct 2017" + +test_config = {} # used for global variables with the test configuration -global test_config # used for global variables with the test configuration -test_config = {} class test_base(unittest.TestCase): test_index = 1 @@ -150,7 +150,7 @@ class test_VIM_datacenter_operations(test_base): self.datacenter = test_config["client"].attach_datacenter(name=self.__class__.datacenter_name, vim_tenant_name='fake') logger.debug("{}".format(self.datacenter)) - assert ('vim_tenants' in self.datacenter.get('datacenter', {})) + assert ('uuid' in self.datacenter.get('datacenter', {})) def test_030_list_attached_datacenter(self): self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], self.__class__.test_index, @@ -279,25 +279,8 @@ class test_VIM_tenant_operations(test_base): logger.debug("{}".format(tenant)) assert ('deleted' in tenant.get('result', "")) -class test_vimconn_connect(test_base): - # test_index = 1 - # test_text = None - - # @classmethod - # def setUpClass(cls): - # logger.info("{}. {}".format(test_config["test_number"], cls.__name__)) - # @classmethod - # def tearDownClass(cls): - # test_config["test_number"] += 1 - - # def tearDown(self): - # exec_info = sys.exc_info() - # if exec_info == (None, None, None): - # logger.info(self.__class__.test_text+" -> TEST OK") - # else: - # logger.warning(self.__class__.test_text+" -> TEST NOK") - # logger.critical("Traceback error",exc_info=True) +class test_vimconn_connect(test_base): def test_000_connect(self): self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], @@ -308,29 +291,10 @@ class test_vimconn_connect(test_base): if test_config['vimtype'] == 'vmware': vca_object = test_config["vim_conn"].connect() logger.debug("{}".format(vca_object)) - self.assertIsInstance(vca_object, VCA) - + self.assertIsNotNone(vca_object) class test_vimconn_new_network(test_base): - # test_index = 1 network_name = None - # test_text = None - - # @classmethod - # def setUpClass(cls): - # logger.info("{}. {}".format(test_config["test_number"], cls.__name__)) - - # @classmethod - # def tearDownClass(cls): - # test_config["test_number"] += 1 - - # def tearDown(self): - # exec_info = sys.exc_info() - # if exec_info == (None, None, None): - # logger.info(self.__class__.test_text+" -> TEST OK") - # else: - # logger.warning(self.__class__.test_text+" -> TEST NOK") - # logger.critical("Traceback error",exc_info=True) def test_000_new_network(self): self.__class__.network_name = _get_random_string(20) @@ -345,7 +309,7 @@ class test_vimconn_new_network(test_base): self.__class__.network_id = network logger.debug("{}".format(network)) - network_list = test_config["vim_conn"].get_vcd_network_list() + network_list = test_config["vim_conn"].get_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')) @@ -373,7 +337,7 @@ class test_vimconn_new_network(test_base): delete_net_ids.append(network_id) logger.debug("{}".format(network_id)) - network_list = test_config["vim_conn"].get_vcd_network_list() + network_list = test_config["vim_conn"].get_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')) @@ -425,7 +389,7 @@ class test_vimconn_new_network(test_base): self.__class__.network_id = network logger.debug("{}".format(network)) - network_list = test_config["vim_conn"].get_vcd_network_list() + network_list = test_config["vim_conn"].get_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')) @@ -450,7 +414,7 @@ class test_vimconn_new_network(test_base): self.__class__.network_id = network logger.debug("{}".format(network)) - network_list = test_config["vim_conn"].get_vcd_network_list() + network_list = test_config["vim_conn"].get_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')) @@ -473,7 +437,7 @@ class test_vimconn_new_network(test_base): net_type='unknowntype') self.__class__.network_id = network logger.debug("{}".format(network)) - network_list = test_config["vim_conn"].get_vcd_network_list() + network_list = test_config["vim_conn"].get_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')) @@ -520,18 +484,8 @@ class test_vimconn_new_network(test_base): self.assertEqual(net_dict, {}) class test_vimconn_get_network_list(test_base): - # test_index = 1 network_name = None - # test_text = None - # @classmethod - # def setUpClass(cls): - # logger.info("{}. {}".format(test_config["test_number"], cls.__name__)) - - # @classmethod - # def tearDownClass(cls): - # test_config["test_number"] += 1 - def setUp(self): # creating new network self.__class__.network_name = _get_random_string(20) @@ -543,12 +497,6 @@ class test_vimconn_get_network_list(test_base): def tearDown(self): test_base.tearDown(self) - # exec_info = sys.exc_info() - # if exec_info == (None, None, None): - # logger.info(self.__class__.test_text+" -> TEST OK") - # else: - # logger.warning(self.__class__.test_text+" -> TEST NOK") - # logger.critical("Traceback error",exc_info=True) # Deleting created network result = test_config["vim_conn"].delete_network(self.__class__.network_id) @@ -666,17 +614,7 @@ class test_vimconn_get_network_list(test_base): self.assertEqual(network_list, []) class test_vimconn_get_network(test_base): - # test_index = 1 network_name = None - # test_text = None - - # @classmethod - # def setUpClass(cls): - # logger.info("{}. {}".format(test_config["test_number"], cls.__name__)) - - # @classmethod - # def tearDownClass(cls): - # test_config["test_number"] += 1 def setUp(self): # creating new network @@ -689,12 +627,6 @@ class test_vimconn_get_network(test_base): def tearDown(self): test_base.tearDown(self) - # exec_info = sys.exc_info() - # if exec_info == (None, None, None): - # logger.info(self.__class__.test_text+" -> TEST OK") - # else: - # logger.warning(self.__class__.test_text+" -> TEST NOK") - # logger.critical("Traceback error",exc_info=True) # Deleting created network result = test_config["vim_conn"].delete_network(self.__class__.network_id) @@ -721,30 +653,13 @@ class test_vimconn_get_network(test_base): 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"].get_network(Non_exist_id) - network_info = test_config["vim_conn"].get_network(Non_exist_id) - self.assertEqual(network_info, {}) + self.assertEqual((context.exception).http_code, 404) class test_vimconn_delete_network(test_base): - # test_index = 1 network_name = None - # test_text = None - - # @classmethod - # def setUpClass(cls): - # logger.info("{}. {}".format(test_config["test_number"], cls.__name__)) - - # @classmethod - # def tearDownClass(cls): - # test_config["test_number"] += 1 - - # def tearDown(self): - # exec_info = sys.exc_info() - # if exec_info == (None, None, None): - # logger.info(self.__class__.test_text+" -> TEST OK") - # else: - # logger.warning(self.__class__.test_text+" -> TEST NOK") - # logger.critical("Traceback error",exc_info=True) def test_000_delete_network(self): # Creating network @@ -784,24 +699,6 @@ class test_vimconn_delete_network(test_base): self.assertEqual((context.exception).http_code, 400) class test_vimconn_get_flavor(test_base): - # test_index = 1 - # test_text = None - - # @classmethod - # def setUpClass(cls): - # logger.info("{}. {}".format(test_config["test_number"], cls.__name__)) - - # @classmethod - # def tearDownClass(cls): - # test_config["test_number"] += 1 - - # def tearDown(self): - # exec_info = sys.exc_info() - # if exec_info == (None, None, None): - # logger.info(self.__class__.test_text+" -> TEST OK") - # else: - # logger.warning(self.__class__.test_text+" -> TEST NOK") - # logger.critical("Traceback error",exc_info=True) def test_000_get_flavor(self): test_directory_content = os.listdir(test_config["test_directory"]) @@ -926,9 +823,10 @@ class test_vimconn_new_image(test_base): image_path = test_config['image_path'] if image_path: - image_id = test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : image_path }) - self.assertEqual(type(image_id),str) - self.assertIsInstance(uuid.UUID(image_id),uuid.UUID) + self.__class__.image_id = test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : image_path }) + time.sleep(20) + self.assertEqual(type(self.__class__.image_id),str) + self.assertIsInstance(uuid.UUID(self.__class__.image_id),uuid.UUID) else: self.skipTest("Skipping test as image file not present at RO container") @@ -945,6 +843,28 @@ class test_vimconn_new_image(test_base): 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.assertEqual(type(image_id),str) + + 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): @@ -1084,7 +1004,7 @@ class test_vimconn_new_vminstance(test_base): net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'vpci': vpci, 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] - self.__class__.instance_id = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=self.__class__.image_id, flavor_id=flavor_id, net_list=net_list) + self.__class__.instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=self.__class__.image_id, flavor_id=flavor_id, net_list=net_list) self.assertEqual(type(self.__class__.instance_id),str) @@ -1103,7 +1023,7 @@ class test_vimconn_new_vminstance(test_base): net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, 'model': model_name, 'type': 'virtual', 'net_id': self.__class__.network_id}] - instance_id = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=self.__class__.image_id, + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=self.__class__.image_id, flavor_id=flavor_id, net_list=net_list) self.assertEqual(type(instance_id),str) @@ -1127,7 +1047,7 @@ class test_vimconn_new_vminstance(test_base): net_list = [{'use': net_use, 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] - instance_id = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=self.__class__.image_id, + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=self.__class__.image_id, flavor_id=flavor_id, net_list=net_list) self.assertEqual(type(instance_id),str) @@ -1151,7 +1071,7 @@ class test_vimconn_new_vminstance(test_base): net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, 'type': _type, 'net_id': self.__class__.network_id}] - instance_id = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=self.__class__.image_id, + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=self.__class__.image_id, flavor_id=flavor_id, net_list=net_list) self.assertEqual(type(instance_id),str) @@ -1181,7 +1101,7 @@ class test_vimconn_new_vminstance(test_base): net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] - instance_id = test_config["vim_conn"].new_vminstance(name='Cloud_vm', image_id=self.__class__.image_id, + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Cloud_vm', image_id=self.__class__.image_id, flavor_id=flavor_id, net_list=net_list, cloud_config=cloud_data) @@ -1207,7 +1127,7 @@ class test_vimconn_new_vminstance(test_base): net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] - instance_id = test_config["vim_conn"].new_vminstance(name='VM_test1', image_id=self.__class__.image_id, + instance_id, _ = test_config["vim_conn"].new_vminstance(name='VM_test1', image_id=self.__class__.image_id, flavor_id=flavor_id, net_list=net_list, disk_list=device_data) @@ -1333,6 +1253,128 @@ class test_vimconn_new_vminstance(test_base): test_config["vim_conn"].delete_vminstance(self.__class__.instance_id) time.sleep(10) +class test_vimconn_get_tenant_list(test_base): + tenant_id = None + + def test_000_get_tenant_list(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 + + # Getting tenant list + tenant_list = test_config["vim_conn"].get_tenant_list() + + for item in tenant_list: + if test_config['tenant'] == item['name']: + self.__class__.tenant_id = item['id'] + self.assertEqual(type(item['name']), str) + self.assertEqual(type(item['id']), str) + + def test_010_get_tenant_list_by_id(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 + + # Getting filter tenant list by its id + filter_tenant_list = test_config["vim_conn"].get_tenant_list({'id': self.__class__.tenant_id}) + + for item in filter_tenant_list: + self.assertEqual(type(item['id']), str) + self.assertEqual(item['id'], self.__class__.tenant_id) + + def test_020_get_tenant_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 + + # Getting filter tenant list by its name + filter_tenant_list = test_config["vim_conn"].get_tenant_list({'name': test_config['tenant']}) + + for item in filter_tenant_list: + self.assertEqual(type(item['name']), str) + self.assertEqual(item['name'], test_config['tenant']) + + def test_030_get_tenant_list_by_name_and_id(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 + + # 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}) + + for item in filter_tenant_list: + self.assertEqual(type(item['name']), str) + self.assertEqual(type(item['id']), str) + self.assertEqual(item['name'], test_config['tenant']) + self.assertEqual(item['id'], self.__class__.tenant_id) + + def test_040_get_tenant_list_negative(self): + non_exist_tenant_name = "Tenant_123" + non_exist_tenant_id = "kjhgrt456-45345kjhdfgnbdk-34dsfjdfg" + 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 + + filter_tenant_list = test_config["vim_conn"].get_tenant_list({'name': non_exist_tenant_name, + 'id': non_exist_tenant_id}) + + self.assertEqual(filter_tenant_list, []) + +class test_vimconn_new_tenant(test_base): + tenant_id = None + + def test_000_new_tenant(self): + tenant_name = _get_random_string(20) + 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__.tenant_id = test_config["vim_conn"].new_tenant(tenant_name) + time.sleep(15) + + self.assertEqual(type(self.__class__.tenant_id), str) + + def test_010_new_tenant_negative(self): + Invalid_tenant_name = 10121 + 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_tenant(Invalid_tenant_name) + + self.assertEqual((context.exception).http_code, 400) + + def test_020_delete_tenant(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 + + tenant_id = test_config["vim_conn"].delete_tenant(self.__class__.tenant_id) + self.assertEqual(type(tenant_id), str) + + def test_030_delete_tenant_negative(self): + 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) + + self.assertEqual((context.exception).http_code, 404) + + ''' IMPORTANT NOTE The following unittest class does not have the 'test_' on purpose. This test is the one used for the @@ -1341,14 +1383,13 @@ scenario based tests. class descriptor_based_scenario_test(test_base): test_index = 0 scenario_test_path = None - scenario_uuid = None - instance_scenario_uuid = None - to_delete_list = [] @classmethod def setUpClass(cls): cls.test_index = 1 cls.to_delete_list = [] + cls.scenario_uuids = [] + cls.instance_scenario_uuids = [] cls.scenario_test_path = test_config["test_directory"] + '/' + test_config["test_folder"] logger.info("{}. {} {}".format(test_config["test_number"], cls.__name__, test_config["test_folder"])) @@ -1361,55 +1402,72 @@ class descriptor_based_scenario_test(test_base): inspect.currentframe().f_code.co_name, test_config["test_folder"]) self.__class__.test_index += 1 - vnfd_files = glob.glob(self.__class__.scenario_test_path+'/vnfd_*.yaml') + # load VNFD and NSD + descriptor_files = glob.glob(self.__class__.scenario_test_path+'/*.yaml') + vnf_descriptors = [] + scenario_descriptors = [] + for descriptor_file in descriptor_files: + with open(descriptor_file, 'r') as stream: + descriptor = yaml.load(stream) + if "vnf" in descriptor or "vnfd:vnfd-catalog" in descriptor or "vnfd-catalog" in descriptor: + vnf_descriptors.append(descriptor) + else: + scenario_descriptors.append(descriptor) + scenario_file = glob.glob(self.__class__.scenario_test_path + '/scenario_*.yaml') - if len(vnfd_files) == 0 or len(scenario_file) > 1: + if not vnf_descriptors or not scenario_descriptors or len(scenario_descriptors) > 1: raise Exception("Test '{}' not valid. It must contain an scenario file and at least one vnfd file'".format( test_config["test_folder"])) - #load all vnfd - for vnfd in vnfd_files: - with open(vnfd, 'r') as stream: - vnf_descriptor = yaml.load(stream) - - vnfc_list = vnf_descriptor['vnf']['VNFC'] - for vnfc in vnfc_list: - vnfc['image name'] = test_config["image_name"] - devices = vnfc.get('devices',[]) - for device in devices: - if device['type'] == 'disk' and 'image name' in device: - device['image name'] = test_config["image_name"] - + # load all vnfd + for vnf_descriptor in vnf_descriptors: logger.debug("VNF descriptor: {}".format(vnf_descriptor)) - vnf = test_config["client"].create_vnf(descriptor=vnf_descriptor) + vnf = test_config["client"].create_vnf(descriptor=vnf_descriptor, image_name=test_config["image_name"]) logger.debug(vnf) + if 'vnf' in vnf: + vnf_uuid = vnf['vnf']['uuid'] + else: + vnf_uuid = vnf['vnfd'][0]['uuid'] self.__class__.to_delete_list.insert(0, {"item": "vnf", "function": test_config["client"].delete_vnf, - "params": {"uuid": vnf['vnf']['uuid']}}) - - #load the scenario definition - with open(scenario_file[0], 'r') as stream: - scenario_descriptor = yaml.load(stream) - networks = scenario_descriptor['scenario']['networks'] - networks[test_config["mgmt_net"]] = networks.pop('mgmt') - logger.debug("Scenario descriptor: {}".format(scenario_descriptor)) - scenario = test_config["client"].create_scenario(descriptor=scenario_descriptor) - logger.debug(scenario) - self.__class__.to_delete_list.insert(0,{"item": "scenario", "function": test_config["client"].delete_scenario, - "params":{"uuid": scenario['scenario']['uuid']} }) - self.__class__.scenario_uuid = scenario['scenario']['uuid'] + "params": {"uuid": vnf_uuid}}) + + # load the scenario definition + for scenario_descriptor in scenario_descriptors: + # networks = scenario_descriptor['scenario']['networks'] + # networks[test_config["mgmt_net"]] = networks.pop('mgmt') + logger.debug("Scenario descriptor: {}".format(scenario_descriptor)) + scenario = test_config["client"].create_scenario(descriptor=scenario_descriptor) + logger.debug(scenario) + if 'scenario' in scenario: + scenario_uuid = scenario['scenario']['uuid'] + else: + scenario_uuid = scenario['nsd'][0]['uuid'] + self.__class__.to_delete_list.insert(0, {"item": "scenario", + "function": test_config["client"].delete_scenario, + "params": {"uuid": scenario_uuid}}) + self.__class__.scenario_uuids.append(scenario_uuid) def test_010_instantiate_scenario(self): self.__class__.test_text = "{}.{}. TEST {} {}".format(test_config["test_number"], self.__class__.test_index, inspect.currentframe().f_code.co_name, test_config["test_folder"]) self.__class__.test_index += 1 - - instance = test_config["client"].create_instance(scenario_id=self.__class__.scenario_uuid, - name=self.__class__.test_text) - self.__class__.instance_scenario_uuid = instance['uuid'] - logger.debug(instance) - self.__class__.to_delete_list.insert(0, {"item": "instance", "function": test_config["client"].delete_instance, - "params": {"uuid": instance['uuid']}}) + for scenario_uuid in self.__class__.scenario_uuids: + instance_descriptor = { + "instance":{ + "name": self.__class__.test_text, + "scenario": scenario_uuid, + "networks":{ + "mgmt": {"sites": [ { "netmap-use": test_config["mgmt_net"]} ]} + } + } + } + instance = test_config["client"].create_instance(instance_descriptor) + self.__class__.instance_scenario_uuids.append(instance['uuid']) + logger.debug(instance) + self.__class__.to_delete_list.insert(0, {"item": "instance", + "function": test_config["client"].delete_instance, + "params": {"uuid": instance['uuid']}}) def test_020_check_deployent(self): self.__class__.test_text = "{}.{}. TEST {} {}".format(test_config["test_number"], self.__class__.test_index, @@ -1422,15 +1480,19 @@ class descriptor_based_scenario_test(test_base): return keep_waiting = test_config["timeout"] - instance_active = False - while True: - result = check_instance_scenario_active(self.__class__.instance_scenario_uuid) - if result[0]: - break - elif 'ERROR' in result[1]: - msg = 'Got error while waiting for the instance to get active: '+result[1] - logging.error(msg) - raise Exception(msg) + pending_instance_scenario_uuids = list(self.__class__.instance_scenario_uuids) # make a copy + while pending_instance_scenario_uuids: + index = 0 + while index < len(pending_instance_scenario_uuids): + result = check_instance_scenario_active(pending_instance_scenario_uuids[index]) + if result[0]: + del pending_instance_scenario_uuids[index] + break + elif 'ERROR' in result[1]: + msg = 'Got error while waiting for the instance to get active: '+result[1] + logging.error(msg) + raise Exception(msg) + index += 1 if keep_waiting >= 5: time.sleep(5)