diff options
author | Romanos Skiadas <rski@intracom-telecom.com> | 2016-11-07 11:45:33 +0200 |
---|---|---|
committer | Romanos Skiadas <rski@intracom-telecom.com> | 2016-11-07 12:08:57 +0200 |
commit | 4db8c4108dcedae322ba6a3fde812e63f746d0f9 (patch) | |
tree | 7b836c092ae29b10ed59d44bf36d86569d92e1d5 /test/functest/utils.py | |
parent | b9eb7024b014cba0d299b1cf3b01e179c7d0482e (diff) |
Refactor common code across tests
- Move collecting test results in a method in Results class
- Create a util function for asserting the environment has
enough compute nodes
Change-Id: Ib7b9dfab7d2e9f50d5f352d3eadba4d4717ee750
Signed-off-by: Romanos Skiadas <rski@intracom-telecom.com>
Diffstat (limited to 'test/functest/utils.py')
-rw-r--r-- | test/functest/utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/functest/utils.py b/test/functest/utils.py index be08572..d416765 100644 --- a/test/functest/utils.py +++ b/test/functest/utils.py @@ -269,3 +269,20 @@ 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 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 |