summaryrefslogtreecommitdiffstats
path: root/sdnvpn/test/functest/testcase_12.py
diff options
context:
space:
mode:
Diffstat (limited to 'sdnvpn/test/functest/testcase_12.py')
-rw-r--r--sdnvpn/test/functest/testcase_12.py45
1 files changed, 22 insertions, 23 deletions
diff --git a/sdnvpn/test/functest/testcase_12.py b/sdnvpn/test/functest/testcase_12.py
index e6a7ac5..6bb8140 100644
--- a/sdnvpn/test/functest/testcase_12.py
+++ b/sdnvpn/test/functest/testcase_12.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
#
# Copyright (c) 2017 All rights reserved
# This program and the accompanying materials
@@ -11,8 +11,8 @@
import logging
import sys
-from functest.utils import openstack_utils as os_utils
from sdnvpn.lib import config as sdnvpn_config
+from sdnvpn.lib import openstack_utils as os_utils
from sdnvpn.lib import utils as test_utils
from sdnvpn.lib.results import Results
@@ -24,15 +24,14 @@ TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
def main():
- results = Results(COMMON_CONFIG.line_length)
+ conn = os_utils.get_os_connection()
+ results = Results(COMMON_CONFIG.line_length, conn)
results.add_to_summary(0, "=")
results.add_to_summary(2, "STATUS", "SUBTEST")
results.add_to_summary(0, "=")
- nova_client = os_utils.get_nova_client()
neutron_client = os_utils.get_neutron_client()
- glance_client = os_utils.get_glance_client()
openstack_nodes = test_utils.get_nodes()
(floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
@@ -40,14 +39,14 @@ def main():
try:
image_id = os_utils.create_glance_image(
- glance_client, TESTCASE_CONFIG.image_name,
+ conn, TESTCASE_CONFIG.image_name,
COMMON_CONFIG.image_path, disk=COMMON_CONFIG.image_format,
container="bare", public='public')
image_ids.append(image_id)
- network_1_id = test_utils.create_net(neutron_client,
+ network_1_id = test_utils.create_net(conn,
TESTCASE_CONFIG.net_1_name)
- subnet_1_id = test_utils.create_subnet(neutron_client,
+ subnet_1_id = test_utils.create_subnet(conn,
TESTCASE_CONFIG.subnet_1_name,
TESTCASE_CONFIG.subnet_1_cidr,
network_1_id)
@@ -56,12 +55,11 @@ def main():
subnet_ids.append(subnet_1_id)
sg_id = os_utils.create_security_group_full(
- neutron_client, TESTCASE_CONFIG.secgroup_name,
+ conn, TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
# Check required number of compute nodes
- compute_hostname = (
- nova_client.hypervisors.list()[0].hypervisor_hostname)
+ compute_hostname = conn.compute.hypervisors().next().name
compute_nodes = [node for node in openstack_nodes
if node.is_compute()]
@@ -76,7 +74,7 @@ def main():
# boot INSTANCES
vm_2 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_2_name,
image_id,
network_1_id,
@@ -85,7 +83,7 @@ def main():
compute_node=av_zone_1)
vm_1 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_1_name,
image_id,
network_1_id,
@@ -100,7 +98,7 @@ def main():
if not instances_up:
logger.error("One or more instances is down")
- logging.info("Wait before subtest")
+ logger.info("Wait before subtest")
test_utils.wait_before_subtest()
# Get added OVS flows and groups
added_ovs_flows = len(test_utils.get_ovs_flows(compute_nodes,
@@ -140,7 +138,7 @@ def main():
compute_node.run_cmd("sudo ovs-vsctl set-controller {} {}".
format(ovs_br, ovs_controller_conn))
- logging.info("Wait before subtest resync type 1")
+ logger.info("Wait before subtest resync type 1")
test_utils.wait_before_subtest()
# Get OVS flows added after the reconnection
resynced_ovs_flows = len(test_utils.get_ovs_flows(
@@ -164,7 +162,7 @@ def main():
compute_node.run_cmd("sudo iptables -D OUTPUT -p tcp --dport 6653"
" -j DROP")
- logging.info("Wait before subtest resync type 2")
+ logger.info("Wait before subtest resync type 2")
test_utils.wait_before_subtest()
# Get OVS flows added after the reconnection
resynced_ovs_flows = len(test_utils.get_ovs_flows(
@@ -185,11 +183,11 @@ def main():
raise
finally:
# Cleanup topology
- test_utils.cleanup_nova(nova_client, instance_ids)
- test_utils.cleanup_glance(glance_client, image_ids)
- test_utils.cleanup_neutron(neutron_client, floatingip_ids, bgpvpn_ids,
- interfaces, subnet_ids, router_ids,
- network_ids)
+ test_utils.cleanup_nova(conn, instance_ids)
+ test_utils.cleanup_glance(conn, image_ids)
+ test_utils.cleanup_neutron(conn, neutron_client, floatingip_ids,
+ bgpvpn_ids, interfaces, subnet_ids,
+ router_ids, network_ids)
return results.compile_summary()
@@ -202,7 +200,9 @@ def record_test_result(expected_flow_count, actual_flow_count,
" actual flow count %s" % (str(expected_flow_count),
str(actual_flow_count)))
results.add_to_summary(0, "-")
- if expected_flow_count == actual_flow_count:
+ # Using <= for flow validation because ODL adds some more
+ # ARP/ICMP flows after VMs spawn up
+ if expected_flow_count <= actual_flow_count:
results.add_success(msg)
else:
results.add_failure(msg)
@@ -220,5 +220,4 @@ def record_test_result(expected_flow_count, actual_flow_count,
if __name__ == '__main__':
- logging.basicConfig(level=logging.INFO)
sys.exit(main())