From 2fe24fa022124324d5ab9325fc60835107f271d3 Mon Sep 17 00:00:00 2001 From: Pablo Montes Moreno Date: Mon, 27 Mar 2017 12:56:13 +0200 Subject: [PATCH] Added test for checking deployed scenarios Change-Id: I27b73720f92542a8aacdd72d7e4cdb17baea65ad Signed-off-by: Pablo Montes Moreno --- test/test_RO.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/test/test_RO.py b/test/test_RO.py index d6667556..3da3c314 100755 --- a/test/test_RO.py +++ b/test/test_RO.py @@ -50,6 +50,22 @@ global scenario_test_folder global test_image_name global management_network +def check_instance_scenario_active(uuid): + instance = client.get_instance(uuid=uuid) + + for net in instance['nets']: + status = net['status'] + if status != 'ACTIVE': + return (False, status) + + for vnf in instance['vnfs']: + for vm in vnf['vms']: + status = vm['status'] + if status != 'ACTIVE': + return (False, status) + + return (True, None) + ''' IMPORTANT NOTE All unittest classes for code based tests must have prefix 'test_' in order to be taken into account for tests @@ -429,11 +445,37 @@ class descriptor_based_scenario_test(unittest.TestCase): self.__class__.test_index += 1 instance = 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": client.delete_instance, "params": {"uuid": instance['uuid']}}) - def test_020_clean_deployment(self): + def test_020_check_deployent(self): + self.__class__.test_text = "{}.{}. TEST {} {}".format(test_number, self.__class__.test_index, + inspect.currentframe().f_code.co_name, + scenario_test_folder) + self.__class__.test_index += 1 + + keep_waiting = 50 + instance_active = False + while(keep_waiting): + 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) + + keep_waiting -= 1 + time.sleep(5) + + if keep_waiting == 0: + msg = 'Timeout reached while waiting instance scenario to get active' + logging.error(msg) + raise Exception(msg) + + def test_030_clean_deployment(self): self.__class__.test_text = "{}.{}. TEST {} {}".format(test_number, self.__class__.test_index, inspect.currentframe().f_code.co_name, scenario_test_folder) -- 2.25.1