diff options
Diffstat (limited to 'test/functest/utils.py')
-rw-r--r-- | test/functest/utils.py | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/test/functest/utils.py b/test/functest/utils.py index be08572..90dfe93 100644 --- a/test/functest/utils.py +++ b/test/functest/utils.py @@ -9,21 +9,16 @@ # import sys import time -import os import functest.utils.functest_logger as ft_logger -import functest.utils.functest_utils as ft_utils import functest.utils.openstack_utils as os_utils import re +import config as sdnvpn_config logger = ft_logger.Logger("sndvpn_test_utils").getLogger() -REPO_PATH = os.environ['repos_dir'] + '/sdnvpn/' -config_file = REPO_PATH + 'test/functest/config.yaml' - -DEFAULT_FLAVOR = ft_utils.get_parameter_from_yaml( - "defaults.flavor", config_file) +common_config = sdnvpn_config.CommonConfig() def create_net(neutron_client, name): @@ -94,7 +89,7 @@ def create_instance(nova_client, **kwargs ): if 'flavor' not in kwargs: - kwargs['flavor'] = DEFAULT_FLAVOR + kwargs['flavor'] = common_config.default_flavor logger.info("Creating instance '%s'..." % name) logger.debug( @@ -117,6 +112,9 @@ def create_instance(nova_client, if instance is None: logger.error("Error while booting instance.") sys.exit(-1) + else: + logger.debug("Instance '%s' booted successfully. IP='%s'." % + (name, instance.networks.itervalues().next()[0])) # Retrieve IP of INSTANCE # instance_ip = instance.networks.get(network_id)[0] @@ -269,3 +267,26 @@ def wait_for_bgp_router_assocs(neutron_client, bgpvpn_id, *args): for id in args] # Return True if all associations succeeded return all(check) + + +def wait_before_subtest(*args, **kwargs): + ''' This is a placeholder. + TODO: Replace delay with polling logic. ''' + time.sleep(30) + + +def assert_and_get_compute_nodes(nova_client, required_node_number=2): + """Get the compute nodes in the deployment + + Exit if the deployment doesn't have enough compute nodes""" + compute_nodes = os_utils.get_hypervisors(nova_client) + + num_compute_nodes = len(compute_nodes) + if num_compute_nodes < 2: + logger.error("There are %s compute nodes in the deployment. " + "Minimum number of nodes to complete the test is 2." + % num_compute_nodes) + sys.exit(-1) + + logger.debug("Compute nodes: %s" % compute_nodes) + return compute_nodes |