summaryrefslogtreecommitdiffstats
path: root/test/functest
diff options
context:
space:
mode:
Diffstat (limited to 'test/functest')
-rw-r--r--test/functest/results.py19
-rw-r--r--test/functest/testcase_1.py33
-rw-r--r--test/functest/testcase_2.py31
-rw-r--r--test/functest/testcase_4.py29
-rw-r--r--test/functest/utils.py23
5 files changed, 55 insertions, 80 deletions
diff --git a/test/functest/results.py b/test/functest/results.py
index baa6af7..7c73556 100644
--- a/test/functest/results.py
+++ b/test/functest/results.py
@@ -145,3 +145,22 @@ class Results(object):
% vm_source.name)
self.add_to_summary(2, "FAIL", test_case_name)
break
+
+ def compile_summary(self, SUCCESS_CRITERIA):
+ success_message = "All the subtests have passed."
+ failure_message = "One or more subtests have failed."
+
+ self.add_to_summary(0, "=")
+ logger.info("\n%s" % self.summary)
+ if self.test_result == "PASS":
+ logger.info(success_message)
+ else:
+ logger.info(failure_message)
+
+ status = "PASS"
+ success = 100 - \
+ (100 * int(self.num_tests_failed) / int(self.num_tests))
+ if success < int(SUCCESS_CRITERIA):
+ status = "FAILED"
+
+ return {"status": status, "details": self.details}
diff --git a/test/functest/testcase_1.py b/test/functest/testcase_1.py
index 4ad29b6..aa9bc92 100644
--- a/test/functest/testcase_1.py
+++ b/test/functest/testcase_1.py
@@ -11,8 +11,6 @@
import argparse
import os
from random import randint
-import sys
-import time
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
@@ -128,16 +126,8 @@ def main():
sg_id = os_utils.create_security_group_full(neutron_client,
SECGROUP_NAME, SECGROUP_DESCR)
- # Get hypervisors zones
- 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)
+ compute_nodes = test_utils.assert_and_get_compute_nodes(nova_client)
- logger.debug("Compute nodes: %s" % compute_nodes)
av_zone_1 = "nova:" + compute_nodes[0]
av_zone_2 = "nova:" + compute_nodes[1]
@@ -260,7 +250,7 @@ def main():
logger.info("Waiting for the VMs to connect to each other using the"
" updated network configuration")
- time.sleep(30)
+ test_utils.wait_before_subtest()
# Ping from VM4 to VM5 should work
results.get_ping_status(vm_4, vm_4_ip, vm_5, vm_5_ip,
@@ -281,9 +271,10 @@ def main():
"export_targets": TARGETS_1,
"name": vpn_name}
bgpvpn = os_utils.update_bgpvpn(neutron_client, bgpvpn_id, **kwargs)
+
logger.info("Waiting for the VMs to connect to each other using the"
" updated network configuration")
- time.sleep(30)
+ test_utils.wait_before_subtest()
# Ping from VM1 to VM4 should work
results.get_ping_status(vm_1, vm_1_ip, vm_4, vm_4_ip,
@@ -292,21 +283,7 @@ def main():
results.get_ping_status(vm_1, vm_1_ip, vm_5, vm_5_ip,
expected="PASS", timeout=30)
- results.add_to_summary(0, "=")
- logger.info("\n%s" % results.summary)
-
- if results.test_result == "PASS":
- logger.info("All the ping tests have passed as expected.")
- else:
- logger.info("One or more ping tests have failed.")
-
- status = "PASS"
- success = 100 - \
- (100 * int(results.num_tests_failed) / int(results.num_tests))
- if success < int(SUCCESS_CRITERIA):
- status = "FAILED"
-
- return {"status": status, "details": results.details}
+ return results.compile_summary(SUCCESS_CRITERIA)
if __name__ == '__main__':
diff --git a/test/functest/testcase_2.py b/test/functest/testcase_2.py
index ed86b02..dee70b4 100644
--- a/test/functest/testcase_2.py
+++ b/test/functest/testcase_2.py
@@ -12,7 +12,6 @@ import argparse
import os
from random import randint
import sys
-import time
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
@@ -148,16 +147,8 @@ def main():
sg_id = os_utils.create_security_group_full(neutron_client,
SECGROUP_NAME, SECGROUP_DESCR)
- # Get hypervisors zones
- 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)
+ compute_nodes = test_utils.assert_and_get_compute_nodes(nova_client)
- logger.debug("Compute nodes: %s" % compute_nodes)
av_zone_1 = "nova:" + compute_nodes[0]
av_zone_2 = "nova:" + compute_nodes[1]
@@ -268,7 +259,7 @@ def main():
logger.info("Waiting for the VMs to connect to each other using the"
" updated network configuration")
- time.sleep(30)
+ test_utils.wait_before_subtest()
# 10.10.10.12 should return sdnvpn-2 to sdnvpn-1
results.check_ssh_output(
@@ -303,7 +294,7 @@ def main():
logger.info("Waiting for the VMs to connect to each other using the"
" updated network configuration")
- time.sleep(30)
+ test_utils.wait_before_subtest()
# 10.10.11.13 should return sdnvpn-5 to sdnvpn-4
results.check_ssh_output(
@@ -313,21 +304,7 @@ def main():
results.check_ssh_output(
vm_4, vm_4_ip, vm_1, vm_1_ip, expected="not reachable", timeout=30)
- results.add_to_summary(0, "=")
- logger.info("\n%s" % results.summary)
-
- if results.test_result == "PASS":
- logger.info("All the sub tests have passed as expected.")
- else:
- logger.info("One or more sub tests have failed.")
-
- status = "PASS"
- success = 100 - \
- (100 * int(results.num_tests_failed) / int(results.num_tests))
- if success < int(SUCCESS_CRITERIA):
- status = "FAILED"
-
- return {"status": status, "details": results.details}
+ return results.compile_summary(SUCCESS_CRITERIA)
if __name__ == '__main__':
diff --git a/test/functest/testcase_4.py b/test/functest/testcase_4.py
index 6798c53..e49c774 100644
--- a/test/functest/testcase_4.py
+++ b/test/functest/testcase_4.py
@@ -11,8 +11,6 @@
import argparse
import os
from random import randint
-import sys
-import time
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
@@ -127,16 +125,8 @@ def main():
sg_id = os_utils.create_security_group_full(neutron_client,
SECGROUP_NAME, SECGROUP_DESCR)
- # Get hypervisors zones
- 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)
+ compute_nodes = test_utils.assert_and_get_compute_nodes(nova_client)
- logger.debug("Compute nodes: %s" % compute_nodes)
av_zone_1 = "nova:" + compute_nodes[0]
av_zone_2 = "nova:" + compute_nodes[1]
@@ -259,7 +249,7 @@ def main():
logger.info("Waiting for the VMs to connect to each other using the"
" updated network configuration")
- time.sleep(30)
+ test_utils.wait_before_subtest()
# Ping from VM4 to VM5 should work
results.get_ping_status(vm_4, vm_4_ip, vm_5, vm_5_ip,
@@ -283,7 +273,7 @@ def main():
logger.info("Waiting for the VMs to connect to each other using the"
" updated network configuration")
- time.sleep(30)
+ test_utils.wait_before_subtest()
# Ping from VM1 to VM4 should work
results.get_ping_status(vm_1, vm_1_ip, vm_4, vm_4_ip,
@@ -295,18 +285,7 @@ def main():
results.add_to_summary(0, "=")
logger.info("\n%s" % results.summary)
- if results.test_result == "PASS":
- logger.info("All the ping tests have passed as expected.")
- else:
- logger.info("One or more ping tests have failed.")
-
- status = "PASS"
- success = 100 - \
- (100 * int(results.num_tests_failed) / int(results.num_tests_failed))
- if success < int(SUCCESS_CRITERIA):
- status = "FAILED"
-
- return {"status": status, "details": results.details}
+ return results.compile_summary(SUCCESS_CRITERIA)
if __name__ == '__main__':
diff --git a/test/functest/utils.py b/test/functest/utils.py
index be08572..b75cb3b 100644
--- a/test/functest/utils.py
+++ b/test/functest/utils.py
@@ -269,3 +269,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