summaryrefslogtreecommitdiffstats
path: root/sdnvpn/test/functest
diff options
context:
space:
mode:
Diffstat (limited to 'sdnvpn/test/functest')
-rw-r--r--sdnvpn/test/functest/config.yaml396
-rw-r--r--sdnvpn/test/functest/run_sdnvpn_tests.py97
-rw-r--r--sdnvpn/test/functest/run_tempest.py108
-rw-r--r--sdnvpn/test/functest/testcase_1.py47
-rw-r--r--sdnvpn/test/functest/testcase_10.py61
-rw-r--r--sdnvpn/test/functest/testcase_11.py34
-rw-r--r--sdnvpn/test/functest/testcase_12.py34
-rw-r--r--sdnvpn/test/functest/testcase_13.py67
-rw-r--r--sdnvpn/test/functest/testcase_1bis.py209
-rw-r--r--sdnvpn/test/functest/testcase_2.py47
-rw-r--r--sdnvpn/test/functest/testcase_2bis.py188
-rw-r--r--sdnvpn/test/functest/testcase_3.py318
-rw-r--r--sdnvpn/test/functest/testcase_4.py45
-rw-r--r--sdnvpn/test/functest/testcase_4bis.py215
-rw-r--r--sdnvpn/test/functest/testcase_7.py42
-rw-r--r--sdnvpn/test/functest/testcase_8.py123
-rw-r--r--sdnvpn/test/functest/testcase_8bis.py176
-rw-r--r--sdnvpn/test/functest/testcase_9.py22
18 files changed, 1608 insertions, 621 deletions
diff --git a/sdnvpn/test/functest/config.yaml b/sdnvpn/test/functest/config.yaml
index d719453..3d2fd8b 100644
--- a/sdnvpn/test/functest/config.yaml
+++ b/sdnvpn/test/functest/config.yaml
@@ -1,37 +1,99 @@
+---
defaults:
- flavor: m1.tiny # adapt to your environment
+ flavor: m1.tiny # adapt to your environment
testcases:
- sdnvpn.test.functest.run_tempest:
- enabled: true
- description: Neutron BGPVPN tests in tempest
-
sdnvpn.test.functest.testcase_1:
- enabled: true
- description: VPN provides connectivity between subnets
+ enabled: true
+ order: 1
+ description: VPN provides connectivity between subnets
+ instance_1_name: sdnvpn-1-1
+ instance_2_name: sdnvpn-1-2
+ instance_3_name: sdnvpn-1-3
+ instance_4_name: sdnvpn-1-4
+ instance_5_name: sdnvpn-1-5
+ image_name: sdnvpn-image
+ net_1_name: sdnvpn-1-1-net
+ subnet_1_name: sdnvpn-1-1-subnet
+ subnet_1_cidr: 10.10.10.0/24
+ router_1_name: sdnvpn-1-1-router
+ net_2_name: sdnvpn-1-2-net
+ subnet_2_name: sdnvpn-1-2-subnet
+ subnet_2_cidr: 10.10.11.0/24
+ router_2_name: sdnvpn-1-2-router
+ secgroup_name: sdnvpn-sg
+ secgroup_descr: Security group for SDNVPN test cases
+ targets1: '88:88'
+ targets2: '55:55'
+ route_distinguishers: '11:11'
+
+ sdnvpn.test.functest.testcase_1bis:
+ enabled: true
+ order: 14
+ description: Test bed for HOT introduction - same tests as case 1
+ image_name: sdnvpn-image
+ stack_name: stack-1bis
+ hot_file_name: artifacts/testcase_1bis.yaml
+ heat_parameters:
instance_1_name: sdnvpn-1-1
instance_2_name: sdnvpn-1-2
instance_3_name: sdnvpn-1-3
instance_4_name: sdnvpn-1-4
instance_5_name: sdnvpn-1-5
- image_name: sdnvpn-image
net_1_name: sdnvpn-1-1-net
subnet_1_name: sdnvpn-1-1-subnet
subnet_1_cidr: 10.10.10.0/24
- router_1_name: sdnvpn-1-1-router
net_2_name: sdnvpn-1-2-net
subnet_2_name: sdnvpn-1-2-subnet
subnet_2_cidr: 10.10.11.0/24
- router_2_name: sdnvpn-1-2-router
secgroup_name: sdnvpn-sg
secgroup_descr: Security group for SDNVPN test cases
- targets1: '88:88'
- targets2: '55:55'
- route_distinguishers: '11:11'
+ targets1: '88:88'
+ targets2: '55:55'
+ route_distinguishers: '11:11'
sdnvpn.test.functest.testcase_2:
- enabled: true
- description: Tenant separation
+ enabled: true
+ order: 2
+ description: Tenant separation
+ instance_1_name: sdnvpn-2-1
+ instance_2_name: sdnvpn-2-2
+ instance_3_name: sdnvpn-2-3
+ instance_4_name: sdnvpn-2-4
+ instance_5_name: sdnvpn-2-5
+ instance_1_ip: 10.10.10.11
+ instance_2_ip: 10.10.10.12
+ instance_3_ip: 10.10.11.13
+ instance_4_ip: 10.10.10.12
+ instance_5_ip: 10.10.11.13
+ image_name: sdnvpn-image
+ net_1_name: sdnvpn-2-1-net
+ subnet_1a_name: sdnvpn-2-1a-subnet
+ subnet_1a_cidr: 10.10.10.0/24
+ subnet_1b_name: sdnvpn-2-1b-subnet
+ subnet_1b_cidr: 10.10.11.0/24
+ router_1_name: sdnvpn-2-1-router
+ net_2_name: sdnvpn-2-2-net
+ subnet_2a_name: sdnvpn-2-2a-subnet
+ subnet_2a_cidr: 10.10.11.0/24
+ subnet_2b_name: sdnvpn-2-2b-subnet
+ subnet_2b_cidr: 10.10.10.0/24
+ router_2_name: sdnvpn-2-2-router
+ secgroup_name: sdnvpn-sg
+ secgroup_descr: Security group for SDNVPN test cases
+ targets1: '88:88'
+ targets2: '55:55'
+ route_distinguishers1: '111:111'
+ route_distinguishers2: '222:222'
+
+ sdnvpn.test.functest.testcase_2bis:
+ enabled: true
+ order: 15
+ description: Tenant separation -same as test case 2
+ image_name: sdnvpn-image
+ stack_name: stack-2bis
+ hot_file_name: artifacts/testcase_2bis.yaml
+ heat_parameters:
instance_1_name: sdnvpn-2-1
instance_2_name: sdnvpn-2-2
instance_3_name: sdnvpn-2-3
@@ -42,7 +104,6 @@ testcases:
instance_3_ip: 10.10.11.13
instance_4_ip: 10.10.10.12
instance_5_ip: 10.10.11.13
- image_name: sdnvpn-image
net_1_name: sdnvpn-2-1-net
subnet_1a_name: sdnvpn-2-1a-subnet
subnet_1a_cidr: 10.10.10.0/24
@@ -57,43 +118,77 @@ testcases:
router_2_name: sdnvpn-2-2-router
secgroup_name: sdnvpn-sg
secgroup_descr: Security group for SDNVPN test cases
- targets1: '88:88'
- targets2: '55:55'
- route_distinguishers1: '111:111'
- route_distinguishers2: '222:222'
+ targets1: '88:88'
+ targets2: '55:55'
+ route_distinguishers1: '111:111'
+ route_distinguishers2: '222:222'
sdnvpn.test.functest.testcase_3:
- enabled: true
- description: Data center gateway integration
- secgroup_name: sdnvpn-sg
- secgroup_descr: Security group for SDNVPN test cases
- image_name: sdnvpn-image
- ubuntu_image_name: sdnvpn-ubuntu-image
- net_1_name: sdnvpn-3-1-net
- subnet_1_name: sdnvpn-3-1-subnet
- subnet_1_cidr: 10.10.10.0/24
- router_1_name: sdnvpn-3-1-router
- quagga_net_name: sdnvpn-3-2-quagga-net
- quagga_subnet_name: sdnvpn-3-2-quagga-subnet
- quagga_subnet_cidr: 10.10.11.0/24
- quagga_router_name: sdnvpn-3-2-quagga-router
- quagga_instance_name: sdnvpn-3-2-quagga
- quagga_instance_ip: 10.10.11.5
- instance_1_name: sdnvpn-3-1
- instance_1_ip: 10.10.10.5
- import_targets: '31:31'
- export_targets: '32:32'
-
+ enabled: true
+ order: 3
+ description: Data center gateway integration
+ secgroup_name: sdnvpn-sg
+ secgroup_descr: Security group for SDNVPN test cases
+ image_name: sdnvpn-image
+ ubuntu_image_name: sdnvpn-ubuntu-image
+ net_1_name: sdnvpn-3-1-net
+ subnet_1_name: sdnvpn-3-1-subnet
+ subnet_1_cidr: 10.10.10.0/24
+ router_1_name: sdnvpn-3-1-router
+ quagga_net_name: sdnvpn-3-2-quagga-net
+ quagga_subnet_name: sdnvpn-3-2-quagga-subnet
+ quagga_subnet_cidr: 10.10.11.0/24
+ quagga_router_name: sdnvpn-3-2-quagga-router
+ quagga_instance_name: sdnvpn-3-2-quagga
+ quagga_instance_ip: 10.10.11.5
+ instance_1_name: sdnvpn-3-1
+ instance_1_ip: 10.10.10.5
+ route_targets: '88:88'
+ import_targets: '88:88'
+ export_targets: '88:88'
+ route_distinguishers: '18:18'
+ external_network_name: External Network in Quagga VM
+ external_network_ip_prefix: 30.1.1.1/32
+ external_network_ip: 30.1.1.1
sdnvpn.test.functest.testcase_4:
- enabled: true
- description: VPN provides connectivity between subnets using router association
+ enabled: true
+ order: 4
+ description: "VPN provides connectivity between subnets using router \
+ association"
+ instance_1_name: sdnvpn-4-1
+ instance_2_name: sdnvpn-4-2
+ instance_3_name: sdnvpn-4-3
+ instance_4_name: sdnvpn-4-4
+ instance_5_name: sdnvpn-4-5
+ image_name: sdnvpn-image
+ net_1_name: sdnvpn-4-1-net
+ subnet_1_name: sdnvpn-4-1-subnet
+ subnet_1_cidr: 10.10.10.0/24
+ router_1_name: sdnvpn-4-1-router
+ net_2_name: sdnvpn-4-2-net
+ subnet_2_name: sdnvpn-4-2-subnet
+ subnet_2_cidr: 10.10.11.0/24
+ router_2_name: sdnvpn-4-2-router
+ secgroup_name: sdnvpn-sg
+ secgroup_descr: Security group for SDNVPN test cases
+ targets1: '88:88'
+ targets2: '55:55'
+ route_distinguishers: '12:12'
+
+ sdnvpn.test.functest.testcase_4bis:
+ enabled: true
+ order: 17
+ description: Test bed for HOT introduction - same tests as case 4
+ image_name: sdnvpn-image
+ stack_name: stack-4bis
+ hot_file_name: artifacts/testcase_4bis.yaml
+ heat_parameters:
instance_1_name: sdnvpn-4-1
instance_2_name: sdnvpn-4-2
instance_3_name: sdnvpn-4-3
instance_4_name: sdnvpn-4-4
instance_5_name: sdnvpn-4-5
- image_name: sdnvpn-image
net_1_name: sdnvpn-4-1-net
subnet_1_name: sdnvpn-4-1-subnet
subnet_1_cidr: 10.10.10.0/24
@@ -101,36 +196,62 @@ testcases:
net_2_name: sdnvpn-4-2-net
subnet_2_name: sdnvpn-4-2-subnet
subnet_2_cidr: 10.10.11.0/24
- router_2_name: sdnvpn-4-2-router
secgroup_name: sdnvpn-sg
secgroup_descr: Security group for SDNVPN test cases
- targets1: '88:88'
- targets2: '55:55'
- route_distinguishers: '12:12'
+ targets1: '88:88'
+ targets2: '55:55'
+ route_distinguishers: '12:12'
sdnvpn.test.functest.testcase_7:
- enabled: false
- description: Network associate VPNs with routers attached (ODL Bug 6962)
- image_name: sdnvpn-image
- instance_1_name: sdnvpn-7-1
- instance_2_name: sdnvpn-7-2
- net_1_name: sdnvpn-7-1
- subnet_1_name: sdnvpn-7-1-subnet
- subnet_1_cidr: 10.10.10.0/24
- router_1_name: sdnvpn-7-1-router
- net_2_name: sdnvpn-7-2
- subnet_2_name: sdnvpn-7-2-subnet
- subnet_2_cidr: 10.10.20.0/24
- router_2_name: sdnvpn-7-2-router
- secgroup_name: sdnvpn-sg
- secgroup_descr: Security group for SDNVPN test cases
- targets: '77:77'
- route_distinguishers: '11:11'
+ enabled: false
+ order: 7
+ description: Network associate VPNs with routers attached (ODL Bug 6962)
+ image_name: sdnvpn-image
+ instance_1_name: sdnvpn-7-1
+ instance_2_name: sdnvpn-7-2
+ net_1_name: sdnvpn-7-1
+ subnet_1_name: sdnvpn-7-1-subnet
+ subnet_1_cidr: 10.10.10.0/24
+ router_1_name: sdnvpn-7-1-router
+ net_2_name: sdnvpn-7-2
+ subnet_2_name: sdnvpn-7-2-subnet
+ subnet_2_cidr: 10.10.20.0/24
+ router_2_name: sdnvpn-7-2-router
+ secgroup_name: sdnvpn-sg
+ secgroup_descr: Security group for SDNVPN test cases
+ targets: '77:77'
+ route_distinguishers: '11:11'
sdnvpn.test.functest.testcase_8:
- enabled: true
- description: Test floating IP and router assoc coexistence
- image_name: sdnvpn-image
+ enabled: true
+ order: 8
+ description: Test floating IP and router assoc coexistence
+ image_name: sdnvpn-image
+ instance_1_name: sdnvpn-8-1
+ instance_2_name: sdnvpn-8-2
+ net_1_name: sdnvpn-8-1
+ subnet_1_name: sdnvpn-8-1-subnet
+ subnet_1_cidr: 10.10.10.0/24
+ router_1_name: sdnvpn-8-1-router
+ net_2_name: sdnvpn-8-2
+ subnet_2_name: sdnvpn-8-2-subnet
+ subnet_2_cidr: 10.10.20.0/24
+ router_2_name: sdnvpn-8-2-router
+ secgroup_name: sdnvpn-sg
+ secgroup_descr: Security group for SDNVPN test cases
+ targets: '88:88'
+ route_distinguishers: '18:18'
+
+ sdnvpn.test.functest.testcase_8bis:
+ enabled: true
+ order: 21
+ description: "Test floating IP and router assoc coexistence \
+ same as test case 8"
+ image_name: sdnvpn-image
+ stack_name: stack-8bis
+ hot_file_name: artifacts/testcase_8bis.yaml
+ hot_update_file_name: artifacts/testcase_8bis_upd.yaml
+ heat_parameters:
instance_1_name: sdnvpn-8-1
instance_2_name: sdnvpn-8-2
net_1_name: sdnvpn-8-1
@@ -140,81 +261,88 @@ testcases:
net_2_name: sdnvpn-8-2
subnet_2_name: sdnvpn-8-2-subnet
subnet_2_cidr: 10.10.20.0/24
- router_2_name: sdnvpn-8-2-router
secgroup_name: sdnvpn-sg
secgroup_descr: Security group for SDNVPN test cases
- targets: '88:88'
- route_distinguishers: '18:18'
+ targets: '88:88'
+ route_distinguishers: '18:18'
sdnvpn.test.functest.testcase_9:
- enabled: true
- description: Verify that all OpenStack nodes OVS br-int have fail_mode set to secure.
+ enabled: true
+ order: 9
+ description: "Verify that all OpenStack nodes OVS br-int have fail_mode \
+ set to secure."
sdnvpn.test.functest.testcase_10:
- enabled: true
- description: Test if interupts occure during ping, when removing and adding instances
- instance_1_name: sdnvpn-10-1
- instance_2_name: sdnvpn-10-2
- instance_3_name: sdnvpn-10-3
- instance_4_name: sdnvpn-10-4
- image_name: sdnvpn-image
- net_1_name: sdnvpn-10-1-net
- subnet_1_name: sdnvpn-10-1-subnet
- subnet_1_cidr: 10.10.10.0/24
- router_1_name: sdnvpn-10-1-router
- secgroup_name: sdnvpn-sg
- secgroup_descr: Security group for SDNVPN test cases
+ enabled: true
+ order: 10
+ description: "Test if interupts occure during ping, when removing and \
+ adding instances"
+ instance_1_name: sdnvpn-10-1
+ instance_2_name: sdnvpn-10-2
+ instance_3_name: sdnvpn-10-3
+ instance_4_name: sdnvpn-10-4
+ image_name: sdnvpn-image
+ net_1_name: sdnvpn-10-1-net
+ subnet_1_name: sdnvpn-10-1-subnet
+ subnet_1_cidr: 10.10.10.0/24
+ router_1_name: sdnvpn-10-1-router
+ secgroup_name: sdnvpn-sg
+ secgroup_descr: Security group for SDNVPN test cases
sdnvpn.test.functest.testcase_11:
- enabled: true
- description: Check relevant OVS groups are removed upon deletion of OpenStack topology
- instance_1_name: sdnvpn-11-1
- instance_2_name: sdnvpn-11-2
- image_name: sdnvpn-image
- net_1_name: sdnvpn-11-1-net
- subnet_1_name: sdnvpn-11-1-subnet
- subnet_1_cidr: 10.10.10.0/24
- router_1_name: sdnvpn-11-1-router
- secgroup_name: sdnvpn-sg
- secgroup_descr: Security group for SDNVPN test cases
+ enabled: true
+ order: 11
+ description: "Check relevant OVS groups are removed upon deletion of \
+ OpenStack topology"
+ instance_1_name: sdnvpn-11-1
+ instance_2_name: sdnvpn-11-2
+ image_name: sdnvpn-image
+ net_1_name: sdnvpn-11-1-net
+ subnet_1_name: sdnvpn-11-1-subnet
+ subnet_1_cidr: 10.10.10.0/24
+ router_1_name: sdnvpn-11-1-router
+ secgroup_name: sdnvpn-sg
+ secgroup_descr: Security group for SDNVPN test cases
sdnvpn.test.functest.testcase_12:
- enabled: true
- description: Check Flows and Groups are reprogrammed after OVS reconnect
- instance_1_name: sdnvpn-12-1
- instance_2_name: sdnvpn-12-2
- image_name: sdnvpn-image
- net_1_name: sdnvpn-12-1-net
- subnet_1_name: sdnvpn-12-1-subnet
- subnet_1_cidr: 10.10.10.0/24
- secgroup_name: sdnvpn-sg
- secgroup_descr: Security group for SDNVPN test cases
+ enabled: true
+ order: 12
+ description: Check Flows and Groups are reprogrammed after OVS reconnect
+ instance_1_name: sdnvpn-12-1
+ instance_2_name: sdnvpn-12-2
+ image_name: sdnvpn-image
+ net_1_name: sdnvpn-12-1-net
+ subnet_1_name: sdnvpn-12-1-subnet
+ subnet_1_cidr: 10.10.10.0/24
+ secgroup_name: sdnvpn-sg
+ secgroup_descr: Security group for SDNVPN test cases
sdnvpn.test.functest.testcase_13:
- enabled: true
- description: Testing extra route ECMP for intra-data center scenario
- instance_1_name: sdnvpn-13-1
- instance_2_name: sdnvpn-13-2
- instance_3_name: sdnvpn-13-3
- image_name: sdnvpn-image
- net_1_name: sdnvpn-13-1-net
- subnet_1_name: sdnvpn-13-1-subnet
- subnet_1_cidr: 10.10.10.0/24
- router_1_name: sdnvpn-13-1-router
- net_2_name: sdnvpn-13-2-net
- subnet_2_name: sdnvpn-13-2-subnet
- subnet_2_cidr: 10.10.11.0/24
- router_2_name: sdnvpn-13-2-router
- interface_name: lo
- interface_number: 1
- extra_route_cidr: 179.24.1.12/32
- extra_route_ip: 179.24.1.12
- extra_route_subnet_mask: 255.255.255.255
- extra_route_name: sdnvpn_extra_route_13
- secgroup_name: sdnvpn-sg
- secgroup_descr: Security group for SDNVPN test cases
- targets1: '88:88'
- targets2: '88:88'
- route_distinguishers:
- - '12:12'
- - '13:13'
+ enabled: true
+ order: 13
+ description: Testing extra route ECMP for intra-data center scenario
+ instance_1_name: sdnvpn-13-1
+ instance_2_name: sdnvpn-13-2
+ instance_3_name: sdnvpn-13-3
+ image_name: sdnvpn-image
+ net_1_name: sdnvpn-13-1-net
+ subnet_1_name: sdnvpn-13-1-subnet
+ subnet_1_cidr: 10.10.10.0/24
+ router_1_name: sdnvpn-13-1-router
+ net_2_name: sdnvpn-13-2-net
+ subnet_2_name: sdnvpn-13-2-subnet
+ subnet_2_cidr: 10.10.11.0/24
+ router_2_name: sdnvpn-13-2-router
+ interface_name: lo
+ interface_number: 1
+ extra_route_cidr: 179.24.1.12/32
+ extra_route_ip: 179.24.1.12
+ extra_route_subnet_mask: 255.255.255.255
+ extra_route_name: sdnvpn_extra_route_13
+ secgroup_name: sdnvpn-sg
+ secgroup_descr: Security group for SDNVPN test cases
+ targets1: '88:88'
+ targets2: '88:88'
+ route_distinguishers:
+ - '12:12'
+ - '13:13'
diff --git a/sdnvpn/test/functest/run_sdnvpn_tests.py b/sdnvpn/test/functest/run_sdnvpn_tests.py
index 211269e..b1b242e 100644
--- a/sdnvpn/test/functest/run_sdnvpn_tests.py
+++ b/sdnvpn/test/functest/run_sdnvpn_tests.py
@@ -15,12 +15,14 @@ import sys
import traceback
import yaml
+from collections import OrderedDict
from xtesting.core import feature
from sdnvpn.lib import config as sdnvpn_config
from sdnvpn.lib import openstack_utils as os_utils
from sdnvpn.lib.gather_logs import gather_logs
from sdnvpn.lib import utils as test_utils
+logger = logging.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
@@ -29,23 +31,23 @@ class SdnvpnFunctest(feature.Feature):
def execute(self):
- nova_client = os_utils.get_nova_client()
- neutron_client = os_utils.get_neutron_client()
+ cloud = os_utils.get_os_cloud()
+ conn = os_utils.get_os_connection()
tenant_id = os_utils.get_tenant_id(os_utils.get_keystone_client(),
os.environ['OS_PROJECT_NAME'])
- neutron_quota = test_utils.get_neutron_quota(neutron_client, tenant_id)
+ neutron_quota = test_utils.get_neutron_quota(conn, tenant_id)
(neutron_nw_quota, neutron_subnet_quota, neutron_port_quota,
neutron_router_quota) = (
- neutron_quota['network'], neutron_quota['subnet'],
- neutron_quota['port'], neutron_quota['router'])
- instances_quota = test_utils.get_nova_instances_quota(nova_client)
+ neutron_quota.networks, neutron_quota.subnets,
+ neutron_quota.ports, neutron_quota.routers)
+ instances_quota = test_utils.get_nova_instances_quota(cloud)
- self.logger.info("Setting net/subnet/port/router "
- "quota to unlimited")
+ logger.info("Setting net/subnet/port/router "
+ "quota to unlimited")
test_utils.update_nw_subnet_port_quota(
- neutron_client,
+ conn,
tenant_id,
COMMON_CONFIG.neutron_nw_quota,
COMMON_CONFIG.neutron_subnet_quota,
@@ -55,75 +57,96 @@ class SdnvpnFunctest(feature.Feature):
# Workaround for
# https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-115
- self.logger.info("Setting instances quota class to unlimited")
+ logger.info("Setting instances quota class to unlimited")
test_utils.update_instance_quota_class(
- nova_client,
- COMMON_CONFIG.nova_instances_quota_class)
+ cloud, COMMON_CONFIG.nova_instances_quota_class)
+
+ # Clean up the stale floating ip's so that required
+ # ip addresses are available for sdnvpn testcases
+ logger.info("Cleaning up the Floating IP Addresses")
+ floating_ips = os_utils.get_floating_ips(conn)
+ for floating_ip in floating_ips:
+ os_utils.delete_floating_ip(conn, floating_ip.id)
+
+ # Workaround for
+ # https://jira.opnfv.org/browse/SNAPS-318
+ # Clean up the stale routers
+ logger.info("Cleaning up the stale routers")
+ ports = os_utils.get_port_list(conn)
+ for port in ports:
+ if port.device_owner == 'network:router_interface':
+ os_utils.delete_neutron_port(conn, port.id)
+ routers = os_utils.get_router_list(conn)
+ for router in routers:
+ os_utils.remove_gateway_router(conn, router.id)
+ os_utils.delete_neutron_router(conn, router.id)
with open(COMMON_CONFIG.config_file) as f:
config_yaml = yaml.safe_load(f)
testcases = config_yaml.get("testcases")
+ testcases_ordered = OrderedDict(sorted(testcases.items(),
+ key=lambda x: x[1]['order']))
overall_status = "PASS"
- for tc in testcases:
- if testcases[tc]['enabled']:
+ for tc, test_sdnvpn in testcases_ordered.items():
+ if test_sdnvpn['enabled']:
test_name = tc
test_descr = testcases[tc]['description']
title = ("Running '%s - %s'" %
(test_name, test_descr))
- self.logger.info(title)
- self.logger.info("%s\n" % ("=" * len(title)))
+ logger.info(title)
+ logger.info("%s\n" % ("=" * len(title)))
try:
- self.logger.info("Importing the testcase %s" % test_name)
+ logger.info("Importing the testcase %s" % test_name)
t = importlib.import_module(test_name, package=None)
- self.logger.info("Calling the testcase %s main method"
- % test_name)
+ logger.info("Calling the testcase %s main method"
+ % test_name)
result = t.main()
- self.logger.info("Execution is complete for the"
- " testcase %s" % test_name)
+ logger.info("Execution is complete for the"
+ " testcase %s" % test_name)
except Exception as ex:
result = -1
- self.logger.info("Caught Exception in %s: %s Trace: %s"
- % (test_name, ex,
- traceback.format_exc()))
+ logger.info("Caught Exception in %s: %s Trace: %s"
+ % (test_name, ex,
+ traceback.format_exc()))
if result < 0:
status = "FAIL"
overall_status = "FAIL"
- self.logger.info("Testcase %s failed" % test_name)
+ logger.info("Testcase %s failed" % test_name)
else:
status = result.get("status")
self.details.update(
{test_name: {'status': status,
'details': result.get("details")}})
- self.logger.info("Results of test case '%s - %s':\n%s\n"
- % (test_name, test_descr, result))
+ logger.info("Results of test case '%s - %s':\n%s\n"
+ % (test_name, test_descr, result))
if status == "FAIL":
overall_status = "FAIL"
- self.logger.info("Resetting subnet/net/port quota")
- test_utils.update_nw_subnet_port_quota(neutron_client,
+ logger.info("Resetting subnet/net/port quota")
+ test_utils.update_nw_subnet_port_quota(conn,
tenant_id,
neutron_nw_quota,
neutron_subnet_quota,
neutron_port_quota,
neutron_router_quota)
- self.logger.info("Resetting instances quota class")
- test_utils.update_instance_quota_class(nova_client, instances_quota)
+ logger.info("Resetting instances quota class")
+ test_utils.update_instance_quota_class(cloud, instances_quota)
try:
installer_type = str(os.environ['INSTALLER_TYPE'].lower())
if installer_type in ["fuel", "apex"]:
gather_logs('overall')
else:
- self.logger.info("Skipping log gathering because installer"
- "type %s is neither fuel nor apex" %
- installer_type)
+ logger.info("Skipping log gathering because installer"
+ "type %s is neither fuel nor apex" %
+ installer_type)
except Exception as ex:
- self.logger.error(('Something went wrong in the Log gathering.'
- 'Ex: %s, Trace: %s')
- % (ex, traceback.format_exc()))
+ logger.error(('Something went wrong in the Log gathering.'
+ 'Ex: %s, Trace: %s')
+ % (ex, traceback.format_exc()))
if overall_status == "PASS":
self.result = 100
diff --git a/sdnvpn/test/functest/run_tempest.py b/sdnvpn/test/functest/run_tempest.py
deleted file mode 100644
index 801a889..0000000
--- a/sdnvpn/test/functest/run_tempest.py
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2017 All rights reserved
-# This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-#
-import ConfigParser
-import os
-import re
-import shutil
-
-import functest.opnfv_tests.openstack.tempest.conf_utils as tempest_utils
-from sdnvpn.lib import logutil
-
-logger = logutil.getLogger('sdnvpn-tempest')
-
-
-def main():
- verifier_id = tempest_utils.get_verifier_id()
- verifier_repo_dir = tempest_utils.get_verifier_repo_dir(
- verifier_id)
- deployment_id = tempest_utils.get_verifier_deployment_id()
- src_tempest_dir = tempest_utils.get_verifier_deployment_dir(
- verifier_id, deployment_id)
-
- if not src_tempest_dir:
- logger.error("Rally deployment not found.")
- exit(-1)
-
- tempest_utils.configure_verifier(src_tempest_dir)
-
- src_tempest_conf = os.path.join(src_tempest_dir, 'tempest.conf')
- bgpvpn_tempest_conf = os.path.join(src_tempest_dir, 'bgpvpn_tempest.conf')
- bgpvpn_tempest_list = os.path.join(src_tempest_dir, 'tempest_list.txt')
-
- if not os.path.isfile(src_tempest_conf):
- logger.error("tempest.conf not found in %s." % src_tempest_conf)
- exit(-1)
- shutil.copy(src_tempest_conf, bgpvpn_tempest_conf)
-
- logger.info("Copying tempest.conf to %s." % bgpvpn_tempest_conf)
- config = ConfigParser.RawConfigParser()
- config.read(bgpvpn_tempest_conf)
- config.set('service_available', 'bgpvpn', 'True')
- logger.debug("Updating %s with bgpvpn=True" % bgpvpn_tempest_conf)
- with open(bgpvpn_tempest_conf, 'wb') as tempest_conf:
- config.write(tempest_conf)
-
- cmd = ("cd {0};"
- "testr list-tests networking_bgpvpn_tempest > {1};"
- "cd -;".format(verifier_repo_dir, bgpvpn_tempest_list))
- logger.info("Generating bgpvpn tempest list: %s" % cmd)
- os.popen(cmd)
- # TODO: Though --config-file parameter is set during the tempest run,
- # it looks for tempest.conf at /etc/tempest/ directory. so applying
- # the following workaround. Will remove it when the root cause is found.
- cmd = ("mkdir /etc/tempest;"
- "cp {0} /etc/tempest/tempest.conf".format(bgpvpn_tempest_conf))
- logger.info("Configuring default tempest conf file")
- os.popen(cmd)
-
- cmd_line = ("tempest run --config-file {0} -t --whitelist-file {1}"
- .format(bgpvpn_tempest_conf, bgpvpn_tempest_list))
- logger.info("Executing: %s" % cmd_line)
- cmd = os.popen(cmd_line)
- output = cmd.read()
- logger.debug(output)
-
- # Results parsing
- error_logs = ""
- duration = 0
- failed = 0
- try:
- # Look For errors
- error_logs = ""
- for match in re.findall('(.*?)[. ]*FAILED', output):
- error_logs += match
- # look for duration
- m = re.search('tests in(.*)sec', output)
- duration = m.group(1)
- # Look for num tests run
- m = re.search('Ran:(.*)tests', output)
- num_tests = m.group(1)
- # Look for tests failed
- m = re.search('- Failed:(.*)', output)
- failed = m.group(1)
- # Look for name of the tests
- testcases = re.findall("\{0\} (.*)", output)
-
- results = {"duration": duration,
- "num_tests": num_tests, "failed": failed,
- "tests": testcases}
- if int(failed) == 0:
- status = "PASS"
- else:
- status = "FAIL"
-
- return {"status": status, "details": results}
- except Exception as e:
- logger.error("Problem when parsing the results: %s", e)
-
-
-if __name__ == '__main__':
- main()
diff --git a/sdnvpn/test/functest/testcase_1.py b/sdnvpn/test/functest/testcase_1.py
index b1f3dae..b524abf 100644
--- a/sdnvpn/test/functest/testcase_1.py
+++ b/sdnvpn/test/functest/testcase_1.py
@@ -8,6 +8,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
+import logging
import sys
from random import randint
@@ -15,9 +16,8 @@ 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
-from sdnvpn.lib import logutil
-logger = logutil.getLogger(__name__)
+logger = logging.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
@@ -25,37 +25,36 @@ 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()
(floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
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)
- network_2_id = test_utils.create_net(neutron_client,
+ network_2_id = test_utils.create_net(conn,
TESTCASE_CONFIG.net_2_name)
- subnet_2_id = test_utils.create_subnet(neutron_client,
+ subnet_2_id = test_utils.create_subnet(conn,
TESTCASE_CONFIG.subnet_2_name,
TESTCASE_CONFIG.subnet_2_cidr,
network_2_id)
@@ -63,49 +62,49 @@ def main():
subnet_ids.extend([subnet_1_id, subnet_2_id])
sg_id = os_utils.create_security_group_full(
- neutron_client, TESTCASE_CONFIG.secgroup_name,
+ conn, TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
- compute_nodes = test_utils.assert_and_get_compute_nodes(nova_client)
+ compute_nodes = test_utils.assert_and_get_compute_nodes(conn)
av_zone_1 = "nova:" + compute_nodes[0]
av_zone_2 = "nova:" + compute_nodes[1]
# boot INTANCES
vm_2 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_2_name,
image_id,
network_1_id,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1)
- vm_2_ip = test_utils.get_instance_ip(vm_2)
+ vm_2_ip = test_utils.get_instance_ip(conn, vm_2)
vm_3 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_3_name,
image_id,
network_1_id,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_2)
- vm_3_ip = test_utils.get_instance_ip(vm_3)
+ vm_3_ip = test_utils.get_instance_ip(conn, vm_3)
vm_5 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_5_name,
image_id,
network_2_id,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_2)
- vm_5_ip = test_utils.get_instance_ip(vm_5)
+ vm_5_ip = test_utils.get_instance_ip(conn, vm_5)
# We boot vm5 first because we need vm5_ip for vm4 userdata
u4 = test_utils.generate_ping_userdata([vm_5_ip])
vm_4 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_4_name,
image_id,
network_2_id,
@@ -113,7 +112,7 @@ def main():
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1,
userdata=u4)
- vm_4_ip = test_utils.get_instance_ip(vm_4)
+ vm_4_ip = test_utils.get_instance_ip(conn, vm_4)
# We boot VM1 at the end because we need to get the IPs first
# to generate the userdata
@@ -122,7 +121,7 @@ def main():
vm_4_ip,
vm_5_ip])
vm_1 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_1_name,
image_id,
network_1_id,
@@ -244,9 +243,9 @@ def main():
logger.error("exception occurred while executing testcase_1: %s", e)
raise
finally:
- test_utils.cleanup_nova(nova_client, instance_ids)
- test_utils.cleanup_glance(glance_client, image_ids)
- test_utils.cleanup_neutron(neutron_client, floatingip_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)
diff --git a/sdnvpn/test/functest/testcase_10.py b/sdnvpn/test/functest/testcase_10.py
index f776ecf..3ba93a9 100644
--- a/sdnvpn/test/functest/testcase_10.py
+++ b/sdnvpn/test/functest/testcase_10.py
@@ -8,6 +8,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
+import logging
import re
import sys
import time
@@ -17,10 +18,8 @@ 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
-from sdnvpn.lib import logutil
-
-logger = logutil.getLogger('__name__')
+logger = logging.getLogger('__name__')
std_out_lock = Lock()
@@ -29,14 +28,15 @@ TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
'sdnvpn.test.functest.testcase_10')
-def monitor(in_data, out_data, vm):
+def monitor(conn, in_data, out_data, vm):
# At the beginning of ping we might have some
# failures, so we ignore the first 10 pings
lines_offset = 20
while in_data["stop_thread"] is False:
try:
time.sleep(1)
- vm_console_out_lines = vm.get_console_output().split('\n')
+ vm_console_out_lines = conn.compute.\
+ get_server_console_output(vm)['output'].split('\n')
if lines_offset < len(vm_console_out_lines):
for console_line in vm_console_out_lines[lines_offset:-1]:
is_ping_error = re.match(r'ping.*KO', console_line)
@@ -55,7 +55,7 @@ def monitor(in_data, out_data, vm):
logger.info("Ping from instance {}: {}".
format(vm.name, console_line))
lines_offset = len(vm_console_out_lines)
- except:
+ except Exception:
# Atomic write to std out
with std_out_lock:
logger.error("Failure in monitor_thread of instance {}".
@@ -65,19 +65,18 @@ def monitor(in_data, out_data, vm):
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()
(floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
- image_id = os_utils.create_glance_image(glance_client,
+ image_id = os_utils.create_glance_image(conn,
TESTCASE_CONFIG.image_name,
COMMON_CONFIG.image_path,
disk=COMMON_CONFIG.image_format,
@@ -85,9 +84,9 @@ def main():
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)
@@ -95,28 +94,28 @@ def main():
network_ids.append(network_1_id)
subnet_ids.append(subnet_1_id)
- sg_id = os_utils.create_security_group_full(neutron_client,
+ sg_id = os_utils.create_security_group_full(conn,
TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
- compute_nodes = test_utils.assert_and_get_compute_nodes(nova_client)
+ compute_nodes = test_utils.assert_and_get_compute_nodes(conn)
av_zone_1 = "nova:" + compute_nodes[0]
av_zone_2 = "nova:" + compute_nodes[1]
# boot INSTANCES
vm_2 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_2_name,
image_id,
network_1_id,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1)
- vm2_ip = test_utils.get_instance_ip(vm_2)
+ vm2_ip = test_utils.get_instance_ip(conn, vm_2)
u1 = test_utils.generate_ping_userdata([vm2_ip])
vm_1 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_1_name,
image_id,
network_1_id,
@@ -124,11 +123,11 @@ def main():
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1,
userdata=u1)
- vm1_ip = test_utils.get_instance_ip(vm_1)
+ vm1_ip = test_utils.get_instance_ip(conn, vm_1)
u3 = test_utils.generate_ping_userdata([vm1_ip, vm2_ip])
vm_3 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_3_name,
image_id,
network_1_id,
@@ -136,7 +135,7 @@ def main():
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_2,
userdata=u3)
- vm3_ip = test_utils.get_instance_ip(vm_3)
+ vm3_ip = test_utils.get_instance_ip(conn, vm_3)
# We do not put vm_2 id in instance_ids table because we will
# delete the current instance during the testing process
instance_ids.extend([vm_1.id, vm_3.id])
@@ -154,19 +153,19 @@ def main():
monitor_output1 = m.dict()
monitor_input1["stop_thread"] = False
monitor_output1["error_msg"] = ""
- monitor_thread1 = Process(target=monitor, args=(monitor_input1,
+ monitor_thread1 = Process(target=monitor, args=(conn, monitor_input1,
monitor_output1, vm_1,))
monitor_input2 = m.dict()
monitor_output2 = m.dict()
monitor_input2["stop_thread"] = False
monitor_output2["error_msg"] = ""
- monitor_thread2 = Process(target=monitor, args=(monitor_input2,
+ monitor_thread2 = Process(target=monitor, args=(conn, monitor_input2,
monitor_output2, vm_2,))
monitor_input3 = m.dict()
monitor_output3 = m.dict()
monitor_input3["stop_thread"] = False
monitor_output3["error_msg"] = ""
- monitor_thread3 = Process(target=monitor, args=(monitor_input3,
+ monitor_thread3 = Process(target=monitor, args=(conn, monitor_input3,
monitor_output3, vm_3,))
# Lists of all monitor threads and their inputs and outputs.
threads = [monitor_thread1, monitor_thread2, monitor_thread3]
@@ -192,7 +191,7 @@ def main():
results.add_failure(monitor_err_msg)
# Stop monitor thread 2 and delete instance vm_2
thread_inputs[1]["stop_thread"] = True
- if not os_utils.delete_instance(nova_client, vm_2.id):
+ if not os_utils.delete_instance(conn, vm_2.id):
logger.error("Fail to delete vm_2 instance during "
"testing process")
raise Exception("Fail to delete instance vm_2.")
@@ -206,7 +205,7 @@ def main():
# Create a new vm (vm_4) on compute 1 node
u4 = test_utils.generate_ping_userdata([vm1_ip, vm3_ip])
vm_4 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_4_name,
image_id,
network_1_id,
@@ -226,7 +225,7 @@ def main():
monitor_output4 = m.dict()
monitor_input4["stop_thread"] = False
monitor_output4["error_msg"] = ""
- monitor_thread4 = Process(target=monitor, args=(monitor_input4,
+ monitor_thread4 = Process(target=monitor, args=(conn, monitor_input4,
monitor_output4,
vm_4,))
threads.append(monitor_thread4)
@@ -260,11 +259,11 @@ def main():
for thread in threads:
thread.join()
- 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()
diff --git a/sdnvpn/test/functest/testcase_11.py b/sdnvpn/test/functest/testcase_11.py
index 9c3dcaa..fd2c74a 100644
--- a/sdnvpn/test/functest/testcase_11.py
+++ b/sdnvpn/test/functest/testcase_11.py
@@ -8,15 +8,15 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
+import logging
import sys
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
-from sdnvpn.lib import logutil
-logger = logutil.getLogger(__name__)
+logger = logging.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
@@ -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()]
@@ -74,7 +72,7 @@ def main():
# boot INSTANCES
vm_2 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_2_name,
image_id,
network_1_id,
@@ -83,7 +81,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,
@@ -128,11 +126,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)
# Connect again OVS to Controller
for compute_node in compute_nodes:
compute_node.run_cmd("sudo ovs-vsctl set-controller {} {}".
diff --git a/sdnvpn/test/functest/testcase_12.py b/sdnvpn/test/functest/testcase_12.py
index 5c91775..6bb8140 100644
--- a/sdnvpn/test/functest/testcase_12.py
+++ b/sdnvpn/test/functest/testcase_12.py
@@ -8,15 +8,15 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
+import logging
import sys
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
-from sdnvpn.lib import logutil
-logger = logutil.getLogger(__name__)
+logger = logging.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
@@ -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,
@@ -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()
diff --git a/sdnvpn/test/functest/testcase_13.py b/sdnvpn/test/functest/testcase_13.py
index 1c1f985..e15c8f1 100644
--- a/sdnvpn/test/functest/testcase_13.py
+++ b/sdnvpn/test/functest/testcase_13.py
@@ -8,6 +8,8 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
+import logging
+import os
import sys
from random import randint
@@ -15,9 +17,8 @@ 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
-from sdnvpn.lib import logutil
-logger = logutil.getLogger(__name__)
+logger = logging.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
@@ -25,22 +26,32 @@ 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()
+ if not os.path.isfile(COMMON_CONFIG.ubuntu_image_path):
+ logger.info("Downloading image")
+ image_dest_path = '/'.join(
+ COMMON_CONFIG.ubuntu_image_path.split('/')[:-1])
+ os_utils.download_url(
+ "http://artifacts.opnfv.org/sdnvpn/"
+ "ubuntu-16.04-server-cloudimg-amd64-disk1.img",
+ image_dest_path)
+ else:
+ logger.info("Using old image")
+
neutron_client = os_utils.get_neutron_client()
- glance_client = os_utils.get_glance_client()
(floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
subnet_ids, interfaces, bgpvpn_ids, flavor_ids) = ([] for i in range(9))
try:
image_id = os_utils.create_glance_image(
- glance_client,
+ conn,
COMMON_CONFIG.ubuntu_image_name,
COMMON_CONFIG.ubuntu_image_path,
disk="qcow2",
@@ -52,7 +63,7 @@ def main():
flavor_ids.append(flavor_id)
network_1_id, subnet_1_id, router_1_id = test_utils.create_network(
- neutron_client,
+ conn,
TESTCASE_CONFIG.net_1_name,
TESTCASE_CONFIG.subnet_1_name,
TESTCASE_CONFIG.subnet_1_cidr,
@@ -64,10 +75,10 @@ def main():
router_ids.extend([router_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)
- compute_nodes = test_utils.assert_and_get_compute_nodes(nova_client)
+ compute_nodes = test_utils.assert_and_get_compute_nodes(conn)
av_zone_1 = "nova:" + compute_nodes[0]
av_zone_2 = "nova:" + compute_nodes[1]
@@ -79,7 +90,7 @@ def main():
TESTCASE_CONFIG.extra_route_subnet_mask)
# boot INTANCES
vm_1 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_1_name,
image_id,
network_1_id,
@@ -88,18 +99,18 @@ def main():
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1,
userdata=u1)
- vm_1_ip = test_utils.get_instance_ip(vm_1)
+ vm_1_ip = test_utils.get_instance_ip(conn, vm_1)
- vm1_port = test_utils.get_port(neutron_client, vm_1.id)
+ vm1_port = test_utils.get_port(conn, vm_1.id)
test_utils.update_port_allowed_address_pairs(
- neutron_client,
- vm1_port['id'],
+ conn,
+ vm1_port.id,
[test_utils.AllowedAddressPair(
TESTCASE_CONFIG.extra_route_cidr,
- vm1_port['mac_address'])])
+ vm1_port.mac_address)])
vm_2 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_2_name,
image_id,
network_1_id,
@@ -108,20 +119,20 @@ def main():
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1,
userdata=u1)
- vm_2_ip = test_utils.get_instance_ip(vm_2)
+ vm_2_ip = test_utils.get_instance_ip(conn, vm_2)
- vm2_port = test_utils.get_port(neutron_client, vm_2.id)
+ vm2_port = test_utils.get_port(conn, vm_2.id)
test_utils.update_port_allowed_address_pairs(
- neutron_client,
- vm2_port['id'],
+ conn,
+ vm2_port.id,
[test_utils.AllowedAddressPair(
TESTCASE_CONFIG.extra_route_cidr,
- vm2_port['mac_address'])])
+ vm2_port.mac_address)])
test_utils.async_Wait_for_instances([vm_1, vm_2])
image_2_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_2_id)
@@ -132,7 +143,7 @@ def main():
u3 = test_utils.generate_ping_userdata(
[TESTCASE_CONFIG.extra_route_ip])
vm_3 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_3_name,
image_2_id,
network_1_id,
@@ -172,7 +183,7 @@ def main():
neutron_client, bgpvpn_id, router_1_id)
test_utils.update_router_extra_route(
- neutron_client, router_1_id,
+ conn, router_1_id,
[test_utils.ExtraRoute(TESTCASE_CONFIG.extra_route_cidr,
vm_1_ip),
test_utils.ExtraRoute(TESTCASE_CONFIG.extra_route_cidr,
@@ -195,10 +206,10 @@ def main():
logger.error("exception occurred while executing testcase_13: %s", e)
raise
finally:
- test_utils.update_router_no_extra_route(neutron_client, router_ids)
- test_utils.cleanup_nova(nova_client, instance_ids, flavor_ids)
- test_utils.cleanup_glance(glance_client, image_ids)
- test_utils.cleanup_neutron(neutron_client, floatingip_ids,
+ test_utils.update_router_no_extra_route(conn, router_ids)
+ test_utils.cleanup_nova(conn, instance_ids, flavor_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)
diff --git a/sdnvpn/test/functest/testcase_1bis.py b/sdnvpn/test/functest/testcase_1bis.py
new file mode 100644
index 0000000..30a0abf
--- /dev/null
+++ b/sdnvpn/test/functest/testcase_1bis.py
@@ -0,0 +1,209 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2018 All rights reserved
+# This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+import logging
+import sys
+import pkg_resources
+
+from random import randint
+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
+
+logger = logging.getLogger(__name__)
+
+COMMON_CONFIG = sdnvpn_config.CommonConfig()
+TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
+ 'sdnvpn.test.functest.testcase_1bis')
+
+
+def main():
+ 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, "=")
+
+ conn = os_utils.get_os_connection()
+ # neutron client is needed as long as bgpvpn heat module
+ # is not yet installed by default in apex (APEX-618)
+ neutron_client = os_utils.get_neutron_client()
+
+ image_ids = []
+ bgpvpn_ids = []
+
+ try:
+ # image created outside HOT (OS::Glance::Image deprecated since ocata)
+ image_id = os_utils.create_glance_image(
+ conn, TESTCASE_CONFIG.image_name,
+ COMMON_CONFIG.image_path, disk=COMMON_CONFIG.image_format,
+ container="bare", public='public')
+ image_ids = [image_id]
+
+ compute_nodes = test_utils.assert_and_get_compute_nodes(conn)
+ az_1 = "nova:" + compute_nodes[0]
+ az_2 = "nova:" + compute_nodes[1]
+
+ file_path = pkg_resources.resource_filename(
+ 'sdnvpn', TESTCASE_CONFIG.hot_file_name)
+ templ = open(file_path, 'r').read()
+ logger.debug("Template is read: '%s'" % templ)
+ env = test_utils.get_heat_environment(TESTCASE_CONFIG, COMMON_CONFIG)
+ logger.debug("Environment is read: '%s'" % env)
+
+ env['name'] = TESTCASE_CONFIG.stack_name
+ env['template'] = templ
+ env['parameters']['image_n'] = TESTCASE_CONFIG.image_name
+ env['parameters']['av_zone_1'] = az_1
+ env['parameters']['av_zone_2'] = az_2
+
+ stack_id = os_utils.create_stack(conn, **env)
+ if stack_id is None:
+ logger.error("Stack create start failed")
+ raise SystemError("Stack create start failed")
+
+ test_utils.wait_stack_for_status(conn, stack_id, 'CREATE_COMPLETE')
+
+ net_1_output = os_utils.get_output(conn, stack_id, 'net_1_o')
+ network_1_id = net_1_output['output_value']
+ net_2_output = os_utils.get_output(conn, stack_id, 'net_2_o')
+ network_2_id = net_2_output['output_value']
+
+ vm_stack_output_keys = ['vm1_o', 'vm2_o', 'vm3_o', 'vm4_o', 'vm5_o']
+ vms = test_utils.get_vms_from_stack_outputs(conn,
+ stack_id,
+ vm_stack_output_keys)
+
+ logger.debug("Entering base test case with stack '%s'" % stack_id)
+
+ msg = ("Create VPN with eRT<>iRT")
+ results.record_action(msg)
+ vpn_name = "sdnvpn-" + str(randint(100000, 999999))
+ kwargs = {
+ "import_targets": TESTCASE_CONFIG.targets1,
+ "export_targets": TESTCASE_CONFIG.targets2,
+ "route_distinguishers": TESTCASE_CONFIG.route_distinguishers,
+ "name": vpn_name
+ }
+ bgpvpn = test_utils.create_bgpvpn(neutron_client, **kwargs)
+ bgpvpn_id = bgpvpn['bgpvpn']['id']
+ logger.debug("VPN created details: %s" % bgpvpn)
+ bgpvpn_ids.append(bgpvpn_id)
+
+ msg = ("Associate network '%s' to the VPN." %
+ TESTCASE_CONFIG.heat_parameters['net_1_name'])
+ results.record_action(msg)
+ results.add_to_summary(0, "-")
+
+ test_utils.create_network_association(
+ neutron_client, bgpvpn_id, network_1_id)
+
+ # Remember: vms[X] is former vm_X+1
+
+ results.get_ping_status(vms[0], vms[1], expected="PASS", timeout=200)
+ results.get_ping_status(vms[0], vms[2], expected="PASS", timeout=30)
+ results.get_ping_status(vms[0], vms[3], expected="FAIL", timeout=30)
+
+ msg = ("Associate network '%s' to the VPN." %
+ TESTCASE_CONFIG.heat_parameters['net_2_name'])
+ results.add_to_summary(0, "-")
+ results.record_action(msg)
+ results.add_to_summary(0, "-")
+
+ test_utils.create_network_association(
+ neutron_client, bgpvpn_id, network_2_id)
+
+ test_utils.wait_for_bgp_net_assocs(neutron_client,
+ bgpvpn_id,
+ network_1_id,
+ network_2_id)
+
+ logger.info("Waiting for the VMs to connect to each other using the"
+ " updated network configuration")
+ test_utils.wait_before_subtest()
+
+ results.get_ping_status(vms[3], vms[4], expected="PASS", timeout=30)
+ # TODO enable again when isolation in VPN with iRT != eRT works
+ # results.get_ping_status(vms[0], vms[3], expected="FAIL", timeout=30)
+ # results.get_ping_status(vms[0], vms[4], expected="FAIL", timeout=30)
+
+ msg = ("Update VPN with eRT=iRT ...")
+ results.add_to_summary(0, "-")
+ results.record_action(msg)
+ results.add_to_summary(0, "-")
+
+ # use bgpvpn-create instead of update till NETVIRT-1067 bug is fixed
+ # kwargs = {"import_targets": TESTCASE_CONFIG.targets1,
+ # "export_targets": TESTCASE_CONFIG.targets1,
+ # "name": vpn_name}
+ # bgpvpn = test_utils.update_bgpvpn(neutron_client,
+ # bgpvpn_id, **kwargs)
+
+ test_utils.delete_bgpvpn(neutron_client, bgpvpn_id)
+ bgpvpn_ids.remove(bgpvpn_id)
+ kwargs = {
+ "import_targets": TESTCASE_CONFIG.targets1,
+ "export_targets": TESTCASE_CONFIG.targets1,
+ "route_distinguishers": TESTCASE_CONFIG.route_distinguishers,
+ "name": vpn_name
+ }
+
+ test_utils.wait_before_subtest()
+
+ bgpvpn = test_utils.create_bgpvpn(neutron_client, **kwargs)
+ bgpvpn_id = bgpvpn['bgpvpn']['id']
+ logger.debug("VPN re-created details: %s" % bgpvpn)
+ bgpvpn_ids.append(bgpvpn_id)
+
+ msg = ("Associate network '%s' to the VPN." %
+ TESTCASE_CONFIG.heat_parameters['net_1_name'])
+ results.record_action(msg)
+ results.add_to_summary(0, "-")
+
+ test_utils.create_network_association(
+ neutron_client, bgpvpn_id, network_1_id)
+
+ test_utils.create_network_association(
+ neutron_client, bgpvpn_id, network_2_id)
+
+ test_utils.wait_for_bgp_net_assocs(neutron_client,
+ bgpvpn_id,
+ network_1_id,
+ network_2_id)
+ # The above code has to be removed after re-enabling bgpvpn-update
+
+ logger.info("Waiting for the VMs to connect to each other using the"
+ " updated network configuration")
+ test_utils.wait_before_subtest()
+
+ results.get_ping_status(vms[0], vms[3], expected="PASS", timeout=30)
+ results.get_ping_status(vms[0], vms[4], expected="PASS", timeout=30)
+
+ except Exception as e:
+ logger.error("exception occurred while executing testcase_1bis: %s", e)
+ raise
+ finally:
+ test_utils.cleanup_glance(conn, image_ids)
+ test_utils.cleanup_neutron(conn, neutron_client, [], bgpvpn_ids,
+ [], [], [], [])
+
+ try:
+ test_utils.delete_stack_and_wait(conn, stack_id)
+ except Exception as e:
+ logger.error(
+ "exception occurred while executing testcase_1bis: %s", e)
+
+ return results.compile_summary()
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/sdnvpn/test/functest/testcase_2.py b/sdnvpn/test/functest/testcase_2.py
index 250ac4f..b4f05b2 100644
--- a/sdnvpn/test/functest/testcase_2.py
+++ b/sdnvpn/test/functest/testcase_2.py
@@ -8,6 +8,8 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
+import base64
+import logging
import sys
from random import randint
@@ -15,9 +17,8 @@ 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
-from sdnvpn.lib import logutil
-logger = logutil.getLogger(__name__)
+logger = logging.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
@@ -25,15 +26,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()
(floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
@@ -44,40 +44,41 @@ def main():
keyfile = open(COMMON_CONFIG.keyfile_path, 'r')
key = keyfile.read()
keyfile.close()
- files = {"/home/cirros/id_rsa": key}
+ files = [{'path': '/home/cirros/id_rsa',
+ 'contents': base64.b64encode(key)}]
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,
+ conn,
TESTCASE_CONFIG.net_1_name)
subnet_1a_id = test_utils.create_subnet(
- neutron_client,
+ conn,
TESTCASE_CONFIG.subnet_1a_name,
TESTCASE_CONFIG.subnet_1a_cidr,
network_1_id)
# TODO: uncomment the commented lines once ODL has
# support for mulitple subnets under same neutron network
# subnet_1b_id = test_utils.create_subnet(
- # neutron_client,
+ # conn,
# TESTCASE_CONFIG.subnet_1b_name,
# TESTCASE_CONFIG.subnet_1b_cidr,
# network_1_id)
network_2_id = test_utils.create_net(
- neutron_client,
+ conn,
TESTCASE_CONFIG.net_2_name)
# subnet_2a_id = test_utils.create_subnet(
- # neutron_client,
+ # conn,
# TESTCASE_CONFIG.subnet_2a_name,
# TESTCASE_CONFIG.subnet_2a_cidr,
# network_2_id)
subnet_2b_id = test_utils.create_subnet(
- neutron_client,
+ conn,
TESTCASE_CONFIG.subnet_2b_name,
TESTCASE_CONFIG.subnet_2b_cidr,
network_2_id)
@@ -88,10 +89,10 @@ def main():
subnet_2b_id])
sg_id = os_utils.create_security_group_full(
- neutron_client, TESTCASE_CONFIG.secgroup_name,
+ conn, TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
- compute_nodes = test_utils.assert_and_get_compute_nodes(nova_client)
+ compute_nodes = test_utils.assert_and_get_compute_nodes(conn)
av_zone_1 = "nova:" + compute_nodes[0]
# av_zone_2 = "nova:" + compute_nodes[1]
@@ -99,7 +100,7 @@ def main():
# boot INTANCES
userdata_common = test_utils.generate_userdata_common()
vm_2 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_2_name,
image_id,
network_1_id,
@@ -111,7 +112,7 @@ def main():
# vm_3 = test_utils.create_instance(
-# nova_client,
+# conn,
# TESTCASE_CONFIG.instance_3_name,
# image_id,
# network_1_id,
@@ -122,7 +123,7 @@ def main():
# userdata=userdata_common)
#
# vm_5 = test_utils.create_instance(
-# nova_client,
+# conn,
# TESTCASE_CONFIG.instance_5_name,
# image_id,
# network_2_id,
@@ -139,7 +140,7 @@ def main():
# TESTCASE_CONFIG.instance_5_ip
])
vm_4 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_4_name,
image_id,
network_2_id,
@@ -159,7 +160,7 @@ def main():
# TESTCASE_CONFIG.instance_5_ip
])
vm_1 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_1_name,
image_id,
network_1_id,
@@ -267,9 +268,9 @@ def main():
logger.error("exception occurred while executing testcase_2: %s", e)
raise
finally:
- test_utils.cleanup_nova(nova_client, instance_ids)
- test_utils.cleanup_glance(glance_client, image_ids)
- test_utils.cleanup_neutron(neutron_client, floatingip_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)
diff --git a/sdnvpn/test/functest/testcase_2bis.py b/sdnvpn/test/functest/testcase_2bis.py
new file mode 100644
index 0000000..3736c0c
--- /dev/null
+++ b/sdnvpn/test/functest/testcase_2bis.py
@@ -0,0 +1,188 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2018 All rights reserved
+# This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+import base64
+import logging
+import sys
+import pkg_resources
+
+from random import randint
+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
+
+logger = logging.getLogger(__name__)
+
+COMMON_CONFIG = sdnvpn_config.CommonConfig()
+TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
+ 'sdnvpn.test.functest.testcase_2bis')
+
+
+def main():
+ 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, '=')
+
+ conn = os_utils.get_os_connection()
+ # neutron client is needed as long as bgpvpn heat module
+ # is not yet installed by default in apex (APEX-618)
+ neutron_client = os_utils.get_neutron_client()
+
+ image_ids = []
+ bgpvpn_ids = []
+
+ try:
+ logger.debug("Using private key %s injected to the VMs."
+ % COMMON_CONFIG.keyfile_path)
+ keyfile = open(COMMON_CONFIG.keyfile_path, 'r')
+ key_buf = keyfile.read()
+ keyfile.close()
+ key = base64.b64encode(key_buf)
+
+ # image created outside HOT (OS::Glance::Image deprecated since ocata)
+ image_id = os_utils.create_glance_image(
+ conn, TESTCASE_CONFIG.image_name,
+ COMMON_CONFIG.image_path, disk=COMMON_CONFIG.image_format,
+ container='bare', public='public')
+ image_ids = [image_id]
+
+ compute_nodes = test_utils.assert_and_get_compute_nodes(conn)
+
+ az_1 = 'nova:' + compute_nodes[0]
+ # av_zone_2 = "nova:" + compute_nodes[1]
+
+ file_path = pkg_resources.resource_filename(
+ 'sdnvpn', TESTCASE_CONFIG.hot_file_name)
+ templ = open(file_path, 'r').read()
+ logger.debug("Template is read: '%s'" % templ)
+ env = test_utils.get_heat_environment(TESTCASE_CONFIG, COMMON_CONFIG)
+ logger.debug("Environment is read: '%s'" % env)
+
+ env['name'] = TESTCASE_CONFIG.stack_name
+ env['template'] = templ
+ env['parameters']['image_n'] = TESTCASE_CONFIG.image_name
+ env['parameters']['av_zone_1'] = az_1
+ env['parameters']['id_rsa_key'] = key
+
+ stack_id = os_utils.create_stack(conn, **env)
+ if stack_id is None:
+ logger.error('Stack create start failed')
+ raise SystemError('Stack create start failed')
+
+ test_utils.wait_stack_for_status(conn, stack_id, 'CREATE_COMPLETE')
+
+ net_1_output = os_utils.get_output(conn, stack_id, 'net_1_o')
+ network_1_id = net_1_output['output_value']
+ net_2_output = os_utils.get_output(conn, stack_id, 'net_2_o')
+ network_2_id = net_2_output['output_value']
+
+ vm_stack_output_keys = ['vm1_o', 'vm2_o', 'vm3_o', 'vm4_o', 'vm5_o']
+ vms = test_utils.get_vms_from_stack_outputs(conn,
+ stack_id,
+ vm_stack_output_keys)
+
+ logger.debug("Entering base test case with stack '%s'" % stack_id)
+
+ msg = ('Create VPN1 with eRT=iRT')
+ results.record_action(msg)
+ vpn1_name = 'sdnvpn-1-' + str(randint(100000, 999999))
+ kwargs = {
+ 'import_targets': TESTCASE_CONFIG.targets2,
+ 'export_targets': TESTCASE_CONFIG.targets2,
+ 'route_targets': TESTCASE_CONFIG.targets2,
+ 'route_distinguishers': TESTCASE_CONFIG.route_distinguishers1,
+ 'name': vpn1_name
+ }
+ bgpvpn1 = test_utils.create_bgpvpn(neutron_client, **kwargs)
+ bgpvpn1_id = bgpvpn1['bgpvpn']['id']
+ logger.debug("VPN1 created details: %s" % bgpvpn1)
+ bgpvpn_ids.append(bgpvpn1_id)
+
+ msg = ("Associate network '%s' to the VPN." %
+ TESTCASE_CONFIG.heat_parameters['net_1_name'])
+ results.record_action(msg)
+ results.add_to_summary(0, '-')
+
+ test_utils.create_network_association(
+ neutron_client, bgpvpn1_id, network_1_id)
+
+ logger.info('Waiting for the VMs to connect to each other using the'
+ ' updated network configuration for VPN1')
+ test_utils.wait_before_subtest()
+
+ # Remember: vms[X] has instance_X+1_name
+
+ # 10.10.10.12 should return sdnvpn-2 to sdnvpn-1
+ results.check_ssh_output(
+ vms[0], vms[1],
+ expected=TESTCASE_CONFIG.heat_parameters['instance_2_name'],
+ timeout=200)
+
+ results.add_to_summary(0, '-')
+ msg = ('Create VPN2 with eRT=iRT')
+ results.record_action(msg)
+ vpn2_name = 'sdnvpn-2-' + str(randint(100000, 999999))
+ kwargs = {
+ 'import_targets': TESTCASE_CONFIG.targets1,
+ 'export_targets': TESTCASE_CONFIG.targets1,
+ 'route_targets': TESTCASE_CONFIG.targets1,
+ 'route_distinguishers': TESTCASE_CONFIG.route_distinguishers2,
+ 'name': vpn2_name
+ }
+ bgpvpn2 = test_utils.create_bgpvpn(neutron_client, **kwargs)
+ bgpvpn2_id = bgpvpn2['bgpvpn']['id']
+ logger.debug("VPN created details: %s" % bgpvpn2)
+ bgpvpn_ids.append(bgpvpn2_id)
+
+ msg = ("Associate network '%s' to the VPN2." %
+ TESTCASE_CONFIG.heat_parameters['net_2_name'])
+ results.record_action(msg)
+ results.add_to_summary(0, '-')
+
+ test_utils.create_network_association(
+ neutron_client, bgpvpn2_id, network_2_id)
+
+ test_utils.wait_for_bgp_net_assoc(neutron_client,
+ bgpvpn1_id, network_1_id)
+ test_utils.wait_for_bgp_net_assoc(neutron_client,
+ bgpvpn2_id, network_2_id)
+
+ logger.info('Waiting for the VMs to connect to each other using the'
+ ' updated network configuration for VPN2')
+ test_utils.wait_before_subtest()
+
+ # 10.10.10.11 should return 'not reachable' to sdnvpn-4
+ results.check_ssh_output(vms[3], vms[0],
+ expected='not reachable',
+ timeout=30)
+
+ except Exception as e:
+ logger.error("exception occurred while executing testcase_2bis: %s", e)
+ raise
+ finally:
+ test_utils.cleanup_glance(conn, image_ids)
+ test_utils.cleanup_neutron(conn, neutron_client, [], bgpvpn_ids,
+ [], [], [], [])
+
+ try:
+ test_utils.delete_stack_and_wait(conn, stack_id)
+ except Exception as e:
+ logger.error(
+ "exception occurred while executing testcase_2bis: %s", e)
+
+ return results.compile_summary()
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/sdnvpn/test/functest/testcase_3.py b/sdnvpn/test/functest/testcase_3.py
index 4475fb8..48024cb 100644
--- a/sdnvpn/test/functest/testcase_3.py
+++ b/sdnvpn/test/functest/testcase_3.py
@@ -14,18 +14,19 @@
# - Add the functest Quagga as a neighbor
# - Verify that the OpenDaylight and gateway Quagga peer
+import logging
import os
import sys
+import time
from sdnvpn.lib import quagga
from sdnvpn.lib import openstack_utils as os_utils
from sdnvpn.lib import utils as test_utils
from sdnvpn.lib import config as sdnvpn_config
from sdnvpn.lib.results import Results
-from sdnvpn.lib import logutil
-logger = logutil.getLogger(__name__)
+logger = logging.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
@@ -33,84 +34,120 @@ 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, "=")
openstack_nodes = test_utils.get_nodes()
+ installer_type = str(os.environ['INSTALLER_TYPE'].lower())
# node.is_odl() doesn't work in Apex
# https://jira.opnfv.org/browse/RELENG-192
- controllers = [node for node in openstack_nodes
- if "running" in
- node.run_cmd("sudo systemctl status opendaylight")]
+ fuel_cmd = "sudo systemctl status opendaylight"
+ apex_cmd = "sudo docker exec opendaylight_api " \
+ "/opt/opendaylight/bin/status"
+ health_cmd = "sudo docker ps -f name=opendaylight_api -f " \
+ "health=healthy -q"
+ if installer_type in ["fuel"]:
+ odl_nodes = [node for node in openstack_nodes
+ if "running" in node.run_cmd(fuel_cmd)]
+ elif installer_type in ["apex"]:
+ odl_nodes = [node for node in openstack_nodes
+ if node.run_cmd(health_cmd)
+ if "Running" in node.run_cmd(apex_cmd)]
+ else:
+ logger.error("Incompatible installer type")
+
computes = [node for node in openstack_nodes if node.is_compute()]
msg = ("Verify that OpenDaylight can start/communicate with zrpcd/Quagga")
results.record_action(msg)
results.add_to_summary(0, "-")
- if not controllers:
- msg = ("Controller (ODL) list is empty. Skipping rest of tests.")
+ if not odl_nodes:
+ msg = ("ODL node list is empty. Skipping rest of tests.")
logger.info(msg)
results.add_failure(msg)
return results.compile_summary()
else:
- msg = ("Controller (ODL) list is ready")
+ msg = ("ODL node list is ready")
logger.info(msg)
results.add_success(msg)
- controller = controllers[0] # We don't handle HA well
- get_ext_ip_cmd = "sudo ip a | grep br-ex | grep inet | awk '{print $2}'"
- ext_net_cidr = controller.run_cmd(get_ext_ip_cmd).strip().split('\n')
- ext_net_mask = ext_net_cidr[0].split('/')[1]
- controller_ext_ip = ext_net_cidr[0].split('/')[0]
-
- logger.info("Starting bgp speaker of controller at IP %s "
- % controller_ext_ip)
logger.info("Checking if zrpcd is "
- "running on the controller node")
-
- output_zrpcd = controller.run_cmd("ps --no-headers -C "
- "zrpcd -o state")
- states = output_zrpcd.split()
- running = any([s != 'Z' for s in states])
+ "running on the opendaylight nodes")
+
+ for odl_node in odl_nodes:
+ output_zrpcd = odl_node.run_cmd("ps --no-headers -C "
+ "zrpcd -o state")
+ states = output_zrpcd.split()
+ running = any([s != 'Z' for s in states])
+ msg = ("zrpcd is running in {name}".format(name=odl_node.name))
+
+ if not running:
+ logger.info("zrpcd is not running on the opendaylight node {name}"
+ .format(name=odl_node.name))
+ results.add_failure(msg)
+ else:
+ logger.info("zrpcd is running on the opendaylight node {name}"
+ .format(name=odl_node.name))
+ results.add_success(msg)
- msg = ("zrpcd is running")
+ results.add_to_summary(0, "-")
- if not running:
- logger.info("zrpcd is not running on the controller node")
+ # Find the BGP entity owner in ODL because of this bug:
+ # https://jira.opendaylight.org/browse/NETVIRT-1308
+ msg = ("Found BGP entity owner")
+ odl_node = test_utils.get_odl_bgp_entity_owner(odl_nodes)
+ if odl_node is None:
+ logger.error("Failed to find the BGP entity owner")
results.add_failure(msg)
else:
- logger.info("zrpcd is running on the controller node")
+ logger.info('BGP entity owner is {name}'
+ .format(name=odl_node.name))
results.add_success(msg)
-
results.add_to_summary(0, "-")
+ installer_type = str(os.environ['INSTALLER_TYPE'].lower())
+ if installer_type in ['apex']:
+ odl_interface = 'br-ex'
+ elif installer_type in ['fuel']:
+ odl_interface = 'br-ext'
+ else:
+ logger.error("Incompatible installer type")
+ odl_ip, odl_netmask = test_utils.get_node_ip_and_netmask(
+ odl_node, odl_interface)
+
+ logger.info("Starting bgp speaker of opendaylight node at IP %s "
+ % odl_ip)
+
# Ensure that ZRPCD ip & port are well configured within ODL
add_client_conn_to_bgp = "bgp-connect -p 7644 -h 127.0.0.1 add"
- test_utils.run_odl_cmd(controller, add_client_conn_to_bgp)
+ test_utils.run_odl_cmd(odl_node, add_client_conn_to_bgp)
# Start bgp daemon
start_quagga = "odl:configure-bgp -op start-bgp-server " \
- "--as-num 100 --router-id {0}".format(controller_ext_ip)
- test_utils.run_odl_cmd(controller, start_quagga)
+ "--as-num 100 --router-id {0}".format(odl_ip)
+ test_utils.run_odl_cmd(odl_node, start_quagga)
+
+ # we need to wait a bit until the bgpd is up
+ time.sleep(5)
- logger.info("Checking if bgpd is running"
- " on the controller node")
+ logger.info("Checking if bgpd is running on the opendaylight node")
# Check if there is a non-zombie bgpd process
- output_bgpd = controller.run_cmd("ps --no-headers -C "
- "bgpd -o state")
+ output_bgpd = odl_node.run_cmd("ps --no-headers -C "
+ "bgpd -o state")
states = output_bgpd.split()
running = any([s != 'Z' for s in states])
msg = ("bgpd is running")
if not running:
- logger.info("bgpd is not running on the controller node")
+ logger.info("bgpd is not running on the opendaylight node")
results.add_failure(msg)
else:
- logger.info("bgpd is running on the controller node")
+ logger.info("bgpd is running on the opendaylight node")
results.add_success(msg)
results.add_to_summary(0, "-")
@@ -119,54 +156,63 @@ def main():
# but the test is disabled because of buggy upstream
# https://github.com/6WIND/zrpcd/issues/15
# stop_quagga = 'odl:configure-bgp -op stop-bgp-server'
- # test_utils.run_odl_cmd(controller, stop_quagga)
+ # test_utils.run_odl_cmd(odl_node, stop_quagga)
# logger.info("Checking if bgpd is still running"
- # " on the controller node")
+ # " on the opendaylight node")
- # output_bgpd = controller.run_cmd("ps --no-headers -C " \
- # "bgpd -o state")
+ # output_bgpd = odl_node.run_cmd("ps --no-headers -C " \
+ # "bgpd -o state")
# states = output_bgpd.split()
# running = any([s != 'Z' for s in states])
# msg = ("bgpd is stopped")
# if not running:
- # logger.info("bgpd is not running on the controller node")
+ # logger.info("bgpd is not running on the opendaylight node")
# results.add_success(msg)
# else:
- # logger.info("bgpd is still running on the controller node")
+ # logger.info("bgpd is still running on the opendaylight node")
# results.add_failure(msg)
# Taken from the sfc tests
if not os.path.isfile(COMMON_CONFIG.ubuntu_image_path):
logger.info("Downloading image")
+ image_dest_path = '/'.join(
+ COMMON_CONFIG.ubuntu_image_path.split('/')[:-1])
os_utils.download_url(
"http://artifacts.opnfv.org/sdnvpn/"
"ubuntu-16.04-server-cloudimg-amd64-disk1.img",
- "/home/opnfv/functest/data/")
+ image_dest_path)
else:
logger.info("Using old image")
- glance_client = os_utils.get_glance_client()
- nova_client = os_utils.get_nova_client()
neutron_client = os_utils.get_neutron_client()
(floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
subnet_ids, interfaces, bgpvpn_ids, flavor_ids) = ([] for i in range(9))
+ quagga_vm = None
+ fake_fip = None
try:
_, flavor_id = test_utils.create_custom_flavor()
flavor_ids.append(flavor_id)
sg_id = os_utils.create_security_group_full(
- neutron_client, TESTCASE_CONFIG.secgroup_name,
+ conn, TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
- test_utils.open_icmp(neutron_client, sg_id)
- test_utils.open_http_port(neutron_client, sg_id)
+ test_utils.open_icmp(conn, sg_id)
+ test_utils.open_http_port(conn, sg_id)
+
+ test_utils.open_bgp_port(conn, sg_id)
- test_utils.open_bgp_port(neutron_client, sg_id)
- net_id, subnet_1_id, router_1_id = test_utils.create_network(
- neutron_client,
+ image_id = os_utils.create_glance_image(
+ conn, TESTCASE_CONFIG.image_name,
+ COMMON_CONFIG.image_path, disk=COMMON_CONFIG.image_format,
+ container="bare", public='public')
+ image_ids.append(image_id)
+
+ net_1_id, subnet_1_id, router_1_id = test_utils.create_network(
+ conn,
TESTCASE_CONFIG.net_1_name,
TESTCASE_CONFIG.subnet_1_name,
TESTCASE_CONFIG.subnet_1_cidr,
@@ -174,7 +220,7 @@ def main():
quagga_net_id, subnet_quagga_id, \
router_quagga_id = test_utils.create_network(
- neutron_client,
+ conn,
TESTCASE_CONFIG.quagga_net_name,
TESTCASE_CONFIG.quagga_subnet_name,
TESTCASE_CONFIG.quagga_subnet_cidr,
@@ -182,7 +228,7 @@ def main():
interfaces.append(tuple((router_1_id, subnet_1_id)))
interfaces.append(tuple((router_quagga_id, subnet_quagga_id)))
- network_ids.extend([net_id, quagga_net_id])
+ network_ids.extend([net_1_id, quagga_net_id])
router_ids.extend([router_1_id, router_quagga_id])
subnet_ids.extend([subnet_1_id, subnet_quagga_id])
@@ -195,7 +241,7 @@ def main():
logger.error("Incompatible installer type")
ubuntu_image_id = os_utils.create_glance_image(
- glance_client,
+ conn,
COMMON_CONFIG.ubuntu_image_name,
COMMON_CONFIG.ubuntu_image_path,
disk,
@@ -213,15 +259,14 @@ def main():
# this to work.
# We also create the FIP first because it is used in the
# cloud-init script.
- fip = os_utils.create_floating_ip(neutron_client)
# fake_fip is needed to bypass NAT
# see below for the reason why.
- fake_fip = os_utils.create_floating_ip(neutron_client)
-
- floatingip_ids.extend([fip['fip_id'], fake_fip['fip_id']])
+ fake_fip = os_utils.create_floating_ip(conn)
# pin quagga to some compute
- compute_node = nova_client.hypervisors.list()[0]
- quagga_compute_node = "nova:" + compute_node.hypervisor_hostname
+ floatingip_ids.append(fake_fip['fip_id'])
+ compute_node = conn.compute.hypervisors().next()
+ compute_node = conn.compute.get_hypervisor(compute_node)
+ quagga_compute_node = "nova:" + compute_node.name
# Map the hypervisor used above to a compute handle
# returned by releng's manager
for comp in computes:
@@ -229,12 +274,16 @@ def main():
compute = comp
break
quagga_bootstrap_script = quagga.gen_quagga_setup_script(
- controller_ext_ip,
+ odl_ip,
fake_fip['fip_addr'],
- ext_net_mask)
+ odl_netmask,
+ TESTCASE_CONFIG.external_network_ip_prefix,
+ TESTCASE_CONFIG.route_distinguishers,
+ TESTCASE_CONFIG.import_targets,
+ TESTCASE_CONFIG.export_targets)
quagga_vm = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.quagga_instance_name,
ubuntu_image_id,
quagga_net_id,
@@ -244,55 +293,142 @@ def main():
userdata=quagga_bootstrap_script,
compute_node=quagga_compute_node)
- instance_ids.append(quagga_vm)
+ instance_ids.append(quagga_vm.id)
- fip_added = os_utils.add_floating_ip(nova_client,
- quagga_vm.id,
- fip['fip_addr'])
+ quagga_vm_port = test_utils.get_port(conn,
+ quagga_vm.id)
+ fip_added = os_utils.attach_floating_ip(conn,
+ quagga_vm_port.id)
msg = ("Assign a Floating IP to %s " %
TESTCASE_CONFIG.quagga_instance_name)
if fip_added:
results.add_success(msg)
+ floatingip_ids.append(fip_added.id)
else:
results.add_failure(msg)
+
test_utils.attach_instance_to_ext_br(quagga_vm, compute)
- try:
- testcase = "Bootstrap quagga inside an OpenStack instance"
- cloud_init_success = test_utils.wait_for_cloud_init(quagga_vm)
- if cloud_init_success:
- results.add_success(testcase)
- else:
- results.add_failure(testcase)
- results.add_to_summary(0, "=")
-
- results.add_to_summary(0, '-')
- results.add_to_summary(1, "Peer Quagga with OpenDaylight")
- results.add_to_summary(0, '-')
-
- neighbor = quagga.odl_add_neighbor(fake_fip['fip_addr'],
- controller_ext_ip,
- controller)
- peer = quagga.check_for_peering(controller)
-
- finally:
- test_utils.detach_instance_from_ext_br(quagga_vm, compute)
+ testcase = "Bootstrap quagga inside an OpenStack instance"
+ cloud_init_success = test_utils.wait_for_cloud_init(conn, quagga_vm)
+ if cloud_init_success:
+ results.add_success(testcase)
+ else:
+ results.add_failure(testcase)
+ results.add_to_summary(0, "=")
+
+ results.add_to_summary(0, '-')
+ results.add_to_summary(1, "Peer Quagga with OpenDaylight")
+ results.add_to_summary(0, '-')
+
+ neighbor = quagga.odl_add_neighbor(fake_fip['fip_addr'],
+ odl_ip,
+ odl_node)
+ peer = quagga.check_for_peering(odl_node)
if neighbor and peer:
results.add_success("Peering with quagga")
else:
results.add_failure("Peering with quagga")
+ test_utils.add_quagga_external_gre_end_point(odl_nodes,
+ fake_fip['fip_addr'])
+ test_utils.wait_before_subtest()
+
+ msg = ("Create VPN to define a VRF")
+ results.record_action(msg)
+ vpn_name = vpn_name = "sdnvpn-3"
+ kwargs = {
+ "import_targets": TESTCASE_CONFIG.import_targets,
+ "export_targets": TESTCASE_CONFIG.export_targets,
+ "route_targets": TESTCASE_CONFIG.route_targets,
+ "route_distinguishers": TESTCASE_CONFIG.route_distinguishers,
+ "name": vpn_name
+ }
+ bgpvpn = test_utils.create_bgpvpn(neutron_client, **kwargs)
+ bgpvpn_id = bgpvpn['bgpvpn']['id']
+ logger.debug("VPN1 created details: %s" % bgpvpn)
+ bgpvpn_ids.append(bgpvpn_id)
+
+ msg = ("Associate network '%s' to the VPN." %
+ TESTCASE_CONFIG.net_1_name)
+ results.record_action(msg)
+ results.add_to_summary(0, "-")
+
+ # create a vm and connect it with network1,
+ # which is going to be bgpvpn associated
+ userdata_common = test_utils.generate_ping_userdata(
+ [TESTCASE_CONFIG.external_network_ip])
+
+ compute_node = conn.compute.hypervisors().next()
+ av_zone_1 = "nova:" + compute_node.name
+ vm_bgpvpn = test_utils.create_instance(
+ conn,
+ TESTCASE_CONFIG.instance_1_name,
+ image_id,
+ net_1_id,
+ sg_id,
+ fixed_ip=TESTCASE_CONFIG.instance_1_ip,
+ secgroup_name=TESTCASE_CONFIG.secgroup_name,
+ compute_node=av_zone_1,
+ userdata=userdata_common)
+ instance_ids.append(vm_bgpvpn.id)
+
+ # wait for VM to get IP
+ instance_up = test_utils.wait_for_instances_get_dhcp(vm_bgpvpn)
+ if not instance_up:
+ logger.error("One or more instances are down")
+
+ test_utils.create_network_association(
+ neutron_client, bgpvpn_id, net_1_id)
+
+ test_utils.wait_before_subtest()
+
+ msg = ("External IP prefix %s is exchanged with ODL"
+ % TESTCASE_CONFIG.external_network_ip_prefix)
+ fib_added = test_utils.is_fib_entry_present_on_odl(
+ odl_nodes,
+ TESTCASE_CONFIG.external_network_ip_prefix,
+ TESTCASE_CONFIG.route_distinguishers)
+ if fib_added:
+ results.add_success(msg)
+ else:
+ results.add_failure(msg)
+
+ # TODO: uncomment the following once OVS is installed with > 2.8.3 and
+ # underlay connectivity is established between vxlan overlay and
+ # external network.
+ # results.get_ping_status_target_ip(
+ # vm_bgpvpn,
+ # TESTCASE_CONFIG.external_network_name,
+ # TESTCASE_CONFIG.external_network_ip,
+ # expected="PASS",
+ # timeout=300)
+
+ results.add_to_summary(0, "=")
+ logger.info("\n%s" % results.summary)
+
except Exception as e:
logger.error("exception occurred while executing testcase_3: %s", e)
raise
finally:
- test_utils.cleanup_nova(nova_client, instance_ids, flavor_ids)
- test_utils.cleanup_glance(glance_client, image_ids)
- test_utils.cleanup_neutron(neutron_client, floatingip_ids,
+ if quagga_vm is not None:
+ test_utils.detach_instance_from_ext_br(quagga_vm, compute)
+ test_utils.cleanup_nova(conn, instance_ids, flavor_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)
+ if fake_fip is not None:
+ bgp_nbr_disconnect_cmd = ("bgp-nbr -i %s -a 200 del"
+ % fake_fip['fip_addr'])
+ test_utils.run_odl_cmd(odl_node, bgp_nbr_disconnect_cmd)
+ bgp_server_stop_cmd = ("bgp-rtr -r %s -a 100 del"
+ % odl_ip)
+ odl_zrpc_disconnect_cmd = "bgp-connect -p 7644 -h 127.0.0.1 del"
+ test_utils.run_odl_cmd(odl_node, bgp_server_stop_cmd)
+ test_utils.run_odl_cmd(odl_node, odl_zrpc_disconnect_cmd)
return results.compile_summary()
diff --git a/sdnvpn/test/functest/testcase_4.py b/sdnvpn/test/functest/testcase_4.py
index c0100ce..650a88a 100644
--- a/sdnvpn/test/functest/testcase_4.py
+++ b/sdnvpn/test/functest/testcase_4.py
@@ -8,6 +8,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
+import logging
import sys
from random import randint
@@ -15,10 +16,9 @@ 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
-from sdnvpn.lib import logutil
-logger = logutil.getLogger(__name__)
+logger = logging.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
@@ -26,39 +26,38 @@ 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()
(floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
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, subnet_1_id, router_1_id = test_utils.create_network(
- neutron_client,
+ conn,
TESTCASE_CONFIG.net_1_name,
TESTCASE_CONFIG.subnet_1_name,
TESTCASE_CONFIG.subnet_1_cidr,
TESTCASE_CONFIG.router_1_name)
network_2_id = test_utils.create_net(
- neutron_client,
+ conn,
TESTCASE_CONFIG.net_2_name)
subnet_2_id = test_utils.create_subnet(
- neutron_client,
+ conn,
TESTCASE_CONFIG.subnet_2_name,
TESTCASE_CONFIG.subnet_2_cidr,
network_2_id)
@@ -68,50 +67,50 @@ def main():
subnet_ids.extend([subnet_1_id, subnet_2_id])
sg_id = os_utils.create_security_group_full(
- neutron_client,
+ conn,
TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
- compute_nodes = test_utils.assert_and_get_compute_nodes(nova_client)
+ compute_nodes = test_utils.assert_and_get_compute_nodes(conn)
av_zone_1 = "nova:" + compute_nodes[0]
av_zone_2 = "nova:" + compute_nodes[1]
# boot INTANCES
vm_2 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_2_name,
image_id,
network_1_id,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1)
- vm_2_ip = test_utils.get_instance_ip(vm_2)
+ vm_2_ip = test_utils.get_instance_ip(conn, vm_2)
vm_3 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_3_name,
image_id,
network_1_id,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_2)
- vm_3_ip = test_utils.get_instance_ip(vm_3)
+ vm_3_ip = test_utils.get_instance_ip(conn, vm_3)
vm_5 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_5_name,
image_id,
network_2_id,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_2)
- vm_5_ip = test_utils.get_instance_ip(vm_5)
+ vm_5_ip = test_utils.get_instance_ip(conn, vm_5)
# We boot vm5 first because we need vm5_ip for vm4 userdata
u4 = test_utils.generate_ping_userdata([vm_5_ip])
vm_4 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_4_name,
image_id,
network_2_id,
@@ -119,7 +118,7 @@ def main():
secgroup_name=TESTCASE_CONFIG.secgroup_name,
compute_node=av_zone_1,
userdata=u4)
- vm_4_ip = test_utils.get_instance_ip(vm_4)
+ vm_4_ip = test_utils.get_instance_ip(conn, vm_4)
# We boot VM1 at the end because we need to get the IPs
# first to generate the userdata
@@ -128,7 +127,7 @@ def main():
vm_4_ip,
vm_5_ip])
vm_1 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_1_name,
image_id,
network_1_id,
@@ -258,9 +257,9 @@ def main():
logger.error("exception occurred while executing testcase_4: %s", e)
raise
finally:
- test_utils.cleanup_nova(nova_client, instance_ids)
- test_utils.cleanup_glance(glance_client, image_ids)
- test_utils.cleanup_neutron(neutron_client, floatingip_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)
diff --git a/sdnvpn/test/functest/testcase_4bis.py b/sdnvpn/test/functest/testcase_4bis.py
new file mode 100644
index 0000000..6245f7c
--- /dev/null
+++ b/sdnvpn/test/functest/testcase_4bis.py
@@ -0,0 +1,215 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2018 All rights reserved
+# This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+import logging
+import sys
+import pkg_resources
+
+from random import randint
+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
+
+logger = logging.getLogger(__name__)
+
+COMMON_CONFIG = sdnvpn_config.CommonConfig()
+TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
+ 'sdnvpn.test.functest.testcase_4bis')
+
+
+def main():
+ 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, '=')
+
+ conn = os_utils.get_os_connection()
+ # neutron client is needed as long as bgpvpn heat module
+ # is not yet installed by default in apex (APEX-618)
+ neutron_client = os_utils.get_neutron_client()
+
+ image_ids = []
+ bgpvpn_ids = []
+
+ try:
+ image_id = os_utils.create_glance_image(
+ conn, TESTCASE_CONFIG.image_name,
+ COMMON_CONFIG.image_path, disk=COMMON_CONFIG.image_format,
+ container='bare', public='public')
+ image_ids = [image_id]
+
+ compute_nodes = test_utils.assert_and_get_compute_nodes(conn)
+ az_1 = 'nova:' + compute_nodes[0]
+ az_2 = 'nova:' + compute_nodes[1]
+
+ file_path = pkg_resources.resource_filename(
+ 'sdnvpn', TESTCASE_CONFIG.hot_file_name)
+ templ = open(file_path, 'r').read()
+ logger.debug("Template is read: '%s'" % templ)
+ env = test_utils.get_heat_environment(TESTCASE_CONFIG, COMMON_CONFIG)
+ logger.debug("Environment is read: '%s'" % env)
+
+ env['name'] = TESTCASE_CONFIG.stack_name
+ env['template'] = templ
+ env['parameters']['image_n'] = TESTCASE_CONFIG.image_name
+ env['parameters']['av_zone_1'] = az_1
+ env['parameters']['av_zone_2'] = az_2
+
+ stack_id = os_utils.create_stack(conn, **env)
+ if stack_id is None:
+ logger.error('Stack create start failed')
+ raise SystemError('Stack create start failed')
+
+ test_utils.wait_stack_for_status(conn, stack_id, 'CREATE_COMPLETE')
+
+ router_1_output = os_utils.get_output(conn, stack_id, 'router_1_o')
+ router_1_id = router_1_output['output_value']
+ net_2_output = os_utils.get_output(conn, stack_id, 'net_2_o')
+ network_2_id = net_2_output['output_value']
+
+ vm_stack_output_keys = ['vm1_o', 'vm2_o', 'vm3_o', 'vm4_o', 'vm5_o']
+ vms = test_utils.get_vms_from_stack_outputs(conn,
+ stack_id,
+ vm_stack_output_keys)
+
+ logger.debug("Entering base test case with stack '%s'" % stack_id)
+
+ msg = ('Create VPN with eRT<>iRT')
+ results.record_action(msg)
+ vpn_name = 'sdnvpn-' + str(randint(100000, 999999))
+ kwargs = {
+ 'import_targets': TESTCASE_CONFIG.targets1,
+ 'export_targets': TESTCASE_CONFIG.targets2,
+ 'route_distinguishers': TESTCASE_CONFIG.route_distinguishers,
+ 'name': vpn_name
+ }
+ bgpvpn = test_utils.create_bgpvpn(neutron_client, **kwargs)
+ bgpvpn_id = bgpvpn['bgpvpn']['id']
+ logger.debug("VPN created details: %s" % bgpvpn)
+ bgpvpn_ids.append(bgpvpn_id)
+
+ msg = ("Associate router '%s' to the VPN." %
+ TESTCASE_CONFIG.heat_parameters['router_1_name'])
+ results.record_action(msg)
+ results.add_to_summary(0, '-')
+
+ test_utils.create_router_association(
+ neutron_client, bgpvpn_id, router_1_id)
+
+ # Remember: vms[X] is former vm_X+1
+
+ results.get_ping_status(vms[0], vms[1], expected='PASS', timeout=200)
+ results.get_ping_status(vms[0], vms[2], expected='PASS', timeout=30)
+ results.get_ping_status(vms[0], vms[3], expected='FAIL', timeout=30)
+
+ msg = ("Associate network '%s' to the VPN." %
+ TESTCASE_CONFIG.heat_parameters['net_2_name'])
+ results.add_to_summary(0, '-')
+ results.record_action(msg)
+ results.add_to_summary(0, '-')
+
+ test_utils.create_network_association(
+ neutron_client, bgpvpn_id, network_2_id)
+
+ test_utils.wait_for_bgp_router_assoc(
+ neutron_client, bgpvpn_id, router_1_id)
+ test_utils.wait_for_bgp_net_assocs(
+ neutron_client, bgpvpn_id, network_2_id)
+
+ logger.info('Waiting for the VMs to connect to each other using the'
+ ' updated network configuration')
+ test_utils.wait_before_subtest()
+
+ results.get_ping_status(vms[3], vms[4], expected='PASS', timeout=30)
+ # TODO enable again when isolation in VPN with iRT != eRT works
+ # results.get_ping_status(vms[0], vms[3], expected="FAIL", timeout=30)
+ # results.get_ping_status(vms[0], vms[4], expected="FAIL", timeout=30)
+
+ msg = ('Update VPN with eRT=iRT ...')
+ results.add_to_summary(0, "-")
+ results.record_action(msg)
+ results.add_to_summary(0, "-")
+
+ # use bgpvpn-create instead of update till NETVIRT-1067 bug is fixed
+ # kwargs = {"import_targets": TESTCASE_CONFIG.targets1,
+ # "export_targets": TESTCASE_CONFIG.targets1,
+ # "name": vpn_name}
+ # bgpvpn = test_utils.update_bgpvpn(neutron_client,
+ # bgpvpn_id, **kwargs)
+
+ test_utils.delete_bgpvpn(neutron_client, bgpvpn_id)
+ bgpvpn_ids.remove(bgpvpn_id)
+ kwargs = {
+ 'import_targets': TESTCASE_CONFIG.targets1,
+ 'export_targets': TESTCASE_CONFIG.targets1,
+ 'route_distinguishers': TESTCASE_CONFIG.route_distinguishers,
+ 'name': vpn_name
+ }
+
+ test_utils.wait_before_subtest()
+
+ bgpvpn = test_utils.create_bgpvpn(neutron_client, **kwargs)
+ bgpvpn_id = bgpvpn['bgpvpn']['id']
+ logger.debug("VPN re-created details: %s" % bgpvpn)
+ bgpvpn_ids.append(bgpvpn_id)
+
+ msg = ("Associate again network '%s' and router '%s 'to the VPN."
+ % (TESTCASE_CONFIG.heat_parameters['net_2_name'],
+ TESTCASE_CONFIG.heat_parameters['router_1_name']))
+ results.add_to_summary(0, '-')
+ results.record_action(msg)
+ results.add_to_summary(0, '-')
+
+ test_utils.create_router_association(
+ neutron_client, bgpvpn_id, router_1_id)
+
+ test_utils.create_network_association(
+ neutron_client, bgpvpn_id, network_2_id)
+
+ test_utils.wait_for_bgp_router_assoc(
+ neutron_client, bgpvpn_id, router_1_id)
+ test_utils.wait_for_bgp_net_assoc(
+ neutron_client, bgpvpn_id, network_2_id)
+ # The above code has to be removed after re-enabling bgpvpn-update
+
+ logger.info('Waiting for the VMs to connect to each other using the'
+ ' updated network configuration')
+ test_utils.wait_before_subtest()
+
+ # TODO: uncomment the following once ODL netvirt fixes the following
+ # bug: https://jira.opendaylight.org/browse/NETVIRT-932
+ # results.get_ping_status(vms[0], vms[3], expected="PASS", timeout=30)
+ # results.get_ping_status(vms[0], vms[4], expected="PASS", timeout=30)
+
+ results.add_to_summary(0, '=')
+ logger.info("\n%s" % results.summary)
+
+ except Exception as e:
+ logger.error("exception occurred while executing testcase_4bis: %s", e)
+ raise
+ finally:
+ test_utils.cleanup_glance(conn, image_ids)
+ test_utils.cleanup_neutron(conn, neutron_client, [], bgpvpn_ids,
+ [], [], [], [])
+
+ try:
+ test_utils.delete_stack_and_wait(conn, stack_id)
+ except Exception as e:
+ logger.error(
+ "exception occurred while executing testcase_4bis: %s", e)
+
+ return results.compile_summary()
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/sdnvpn/test/functest/testcase_7.py b/sdnvpn/test/functest/testcase_7.py
index 6594045..e588b14 100644
--- a/sdnvpn/test/functest/testcase_7.py
+++ b/sdnvpn/test/functest/testcase_7.py
@@ -18,16 +18,16 @@ network associated:
- Assign a floating IP to a VM
- Ping it
"""
+import logging
import sys
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
-from sdnvpn.lib import logutil
-logger = logutil.getLogger(__name__)
+logger = logging.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
@@ -35,35 +35,34 @@ 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()
(floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
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, subnet_1_id, router_1_id = test_utils.create_network(
- neutron_client,
+ conn,
TESTCASE_CONFIG.net_1_name,
TESTCASE_CONFIG.subnet_1_name,
TESTCASE_CONFIG.subnet_1_cidr,
TESTCASE_CONFIG.router_1_name)
network_2_id, subnet_2_id, router_2_id = test_utils.create_network(
- neutron_client,
+ conn,
TESTCASE_CONFIG.net_2_name,
TESTCASE_CONFIG.subnet_2_name,
TESTCASE_CONFIG.subnet_2_cidr,
@@ -76,23 +75,23 @@ def main():
subnet_ids.extend([subnet_1_id, subnet_2_id])
sg_id = os_utils.create_security_group_full(
- neutron_client, TESTCASE_CONFIG.secgroup_name,
+ conn, TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
- test_utils.open_icmp(neutron_client, sg_id)
- test_utils.open_http_port(neutron_client, sg_id)
+ test_utils.open_icmp(conn, sg_id)
+ test_utils.open_http_port(conn, sg_id)
vm_2 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_2_name,
image_id,
network_2_id,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name)
- vm_2_ip = test_utils.get_instance_ip(vm_2)
+ vm_2_ip = test_utils.get_instance_ip(conn, vm_2)
u1 = test_utils.generate_ping_userdata([vm_2_ip])
vm_1 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_1_name,
image_id,
network_1_id,
@@ -151,25 +150,24 @@ def main():
results.record_action(msg)
results.add_to_summary(0, '-')
- fip = os_utils.create_floating_ip(neutron_client)
- fip_added = os_utils.add_floating_ip(nova_client, vm_2.id,
- fip['fip_addr'])
+ vm2_port = test_utils.get_port(conn, vm_2.id)
+ fip_added = os_utils.attach_floating_ip(conn, vm2_port.id)
if fip_added:
results.add_success(msg)
else:
results.add_failure(msg)
- results.ping_ip_test(fip['fip_addr'])
+ results.ping_ip_test(fip_added.floating_ip_address)
- floatingip_ids.append(fip['fip_id'])
+ floatingip_ids.append(fip_added.id)
except Exception as e:
logger.error("exception occurred while executing testcase_7: %s", e)
raise
finally:
- test_utils.cleanup_nova(nova_client, instance_ids)
- test_utils.cleanup_glance(glance_client, image_ids)
- test_utils.cleanup_neutron(neutron_client, floatingip_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)
diff --git a/sdnvpn/test/functest/testcase_8.py b/sdnvpn/test/functest/testcase_8.py
index 10c0653..26d1f35 100644
--- a/sdnvpn/test/functest/testcase_8.py
+++ b/sdnvpn/test/functest/testcase_8.py
@@ -16,16 +16,16 @@
# - Try to ping from one VM to the other
# - Assign a floating IP to the VM in the router assoc network
# - Ping it the floating ip
+import logging
import sys
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
-from sdnvpn.lib import logutil
-logger = logutil.getLogger(__name__)
+logger = logging.getLogger(__name__)
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
@@ -33,101 +33,107 @@ 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()
(floatingip_ids, instance_ids, router_ids, network_ids, image_ids,
subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8))
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, subnet_1_id, router_1_id = test_utils.create_network(
- neutron_client,
+ conn,
TESTCASE_CONFIG.net_1_name,
TESTCASE_CONFIG.subnet_1_name,
TESTCASE_CONFIG.subnet_1_cidr,
TESTCASE_CONFIG.router_1_name)
- network_2_id = test_utils.create_net(
- neutron_client,
- TESTCASE_CONFIG.net_2_name)
- subnet_2_id = test_utils.create_subnet(
- neutron_client,
+ network_2_id, subnet_2_id, router_1_id = test_utils.create_network(
+ conn,
+ TESTCASE_CONFIG.net_2_name,
TESTCASE_CONFIG.subnet_2_name,
TESTCASE_CONFIG.subnet_2_cidr,
- network_2_id)
+ TESTCASE_CONFIG.router_1_name)
interfaces.append(tuple((router_1_id, subnet_1_id)))
+ interfaces.append(tuple((router_1_id, subnet_2_id)))
network_ids.extend([network_1_id, network_2_id])
router_ids.append(router_1_id)
subnet_ids.extend([subnet_1_id, subnet_2_id])
sg_id = os_utils.create_security_group_full(
- neutron_client, TESTCASE_CONFIG.secgroup_name,
+ conn, TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
- test_utils.open_icmp(neutron_client, sg_id)
- test_utils.open_http_port(neutron_client, sg_id)
-
+ test_utils.open_icmp(conn, sg_id)
+ test_utils.open_http_port(conn, sg_id)
+
+ compute_nodes = test_utils.assert_and_get_compute_nodes(conn)
+ av_zone_1 = "nova:" + compute_nodes[0]
+ # spawning the VMs on the same compute because fib flow (21) entries
+ # are not created properly if vm1 and vm2 are attached to two
+ # different computes
vm_2 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_2_name,
image_id,
network_2_id,
sg_id,
- secgroup_name=TESTCASE_CONFIG.secgroup_name)
- vm_2_ip = test_utils.get_instance_ip(vm_2)
+ secgroup_name=TESTCASE_CONFIG.secgroup_name,
+ compute_node=av_zone_1)
+ vm_2_ip = test_utils.get_instance_ip(conn, vm_2)
u1 = test_utils.generate_ping_userdata([vm_2_ip])
vm_1 = test_utils.create_instance(
- nova_client,
+ conn,
TESTCASE_CONFIG.instance_1_name,
image_id,
network_1_id,
sg_id,
secgroup_name=TESTCASE_CONFIG.secgroup_name,
+ compute_node=av_zone_1,
userdata=u1)
instance_ids.extend([vm_1.id, vm_2.id])
-
- results.record_action("Create VPN with eRT==iRT")
- vpn_name = "sdnvpn-8"
- kwargs = {
- "import_targets": TESTCASE_CONFIG.targets,
- "export_targets": TESTCASE_CONFIG.targets,
- "route_distinguishers": TESTCASE_CONFIG.route_distinguishers,
- "name": vpn_name
- }
- bgpvpn = test_utils.create_bgpvpn(neutron_client, **kwargs)
- bgpvpn_id = bgpvpn['bgpvpn']['id']
- logger.debug("VPN created details: %s" % bgpvpn)
- bgpvpn_ids.append(bgpvpn_id)
-
- msg = ("Associate router '%s' and net '%s' to the VPN."
- % (TESTCASE_CONFIG.router_1_name,
- TESTCASE_CONFIG.net_2_name))
- results.record_action(msg)
- results.add_to_summary(0, "-")
-
- test_utils.create_router_association(
- neutron_client, bgpvpn_id, router_1_id)
- test_utils.create_network_association(
- neutron_client, bgpvpn_id, network_2_id)
-
- test_utils.wait_for_bgp_router_assoc(
- neutron_client, bgpvpn_id, router_1_id)
- test_utils.wait_for_bgp_net_assoc(
- neutron_client, bgpvpn_id, network_2_id)
+ # TODO: uncomment the lines 107-134 once ODL fixes
+ # the bug https://jira.opendaylight.org/browse/NETVIRT-932
+ # results.record_action("Create VPN with eRT==iRT")
+ # vpn_name = "sdnvpn-8"
+ # kwargs = {
+ # "import_targets": TESTCASE_CONFIG.targets,
+ # "export_targets": TESTCASE_CONFIG.targets,
+ # "route_distinguishers": TESTCASE_CONFIG.route_distinguishers,
+ # "name": vpn_name
+ # }
+ # bgpvpn = test_utils.create_bgpvpn(neutron_client, **kwargs)
+ # bgpvpn_id = bgpvpn['bgpvpn']['id']
+ # logger.debug("VPN created details: %s" % bgpvpn)
+ # bgpvpn_ids.append(bgpvpn_id)
+
+ # msg = ("Associate router '%s' and net '%s' to the VPN."
+ # % (TESTCASE_CONFIG.router_1_name,
+ # TESTCASE_CONFIG.net_2_name))
+ # results.record_action(msg)
+ # results.add_to_summary(0, "-")
+
+ # test_utils.create_router_association(
+ # neutron_client, bgpvpn_id, router_1_id)
+ # test_utils.create_network_association(
+ # neutron_client, bgpvpn_id, network_2_id)
+
+ # test_utils.wait_for_bgp_router_assoc(
+ # neutron_client, bgpvpn_id, router_1_id)
+ # test_utils.wait_for_bgp_net_assoc(
+ # neutron_client, bgpvpn_id, network_2_id)
# Wait for VMs to get ips.
instances_up = test_utils.wait_for_instances_up(vm_2)
@@ -147,29 +153,30 @@ def main():
msg = "Assign a Floating IP to %s" % vm_1.name
results.record_action(msg)
- fip = os_utils.create_floating_ip(neutron_client)
+ vm1_port = test_utils.get_port(conn, vm_1.id)
+ fip_added = os_utils.attach_floating_ip(conn, vm1_port.id)
- fip_added = os_utils.add_floating_ip(nova_client,
- vm_1.id, fip['fip_addr'])
if fip_added:
results.add_success(msg)
else:
results.add_failure(msg)
+ fip = fip_added.floating_ip_address
+
results.add_to_summary(0, "=")
results.record_action("Ping %s via Floating IP" % vm_1.name)
results.add_to_summary(0, "-")
- results.ping_ip_test(fip['fip_addr'])
+ results.ping_ip_test(fip)
- floatingip_ids.append(fip['fip_id'])
+ floatingip_ids.append(fip_added.id)
except Exception as e:
logger.error("exception occurred while executing testcase_8: %s", e)
raise
finally:
- test_utils.cleanup_nova(nova_client, instance_ids)
- test_utils.cleanup_glance(glance_client, image_ids)
- test_utils.cleanup_neutron(neutron_client, floatingip_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)
diff --git a/sdnvpn/test/functest/testcase_8bis.py b/sdnvpn/test/functest/testcase_8bis.py
new file mode 100644
index 0000000..d850020
--- /dev/null
+++ b/sdnvpn/test/functest/testcase_8bis.py
@@ -0,0 +1,176 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2017 All rights reserved
+# This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Test whether router assoc can coexist with floating IP
+# - Create VM1 in net1 with a subnet which is connected to a router
+# which is connected with the gateway
+# - Create VM2 in net2 with a subnet without a router attached.
+# - Create bgpvpn with iRT=eRT
+# - Assoc the router of net1 with bgpvpn and assoc net 2 with the bgpvpn
+# - Try to ping from one VM to the other
+# - Assign a floating IP to the VM in the router assoc network
+# - Ping it the floating ip
+
+import logging
+import sys
+import pkg_resources
+
+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
+
+
+logger = logging.getLogger(__name__)
+
+COMMON_CONFIG = sdnvpn_config.CommonConfig()
+TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
+ 'sdnvpn.test.functest.testcase_8bis')
+
+
+def main():
+ 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, "=")
+
+ # neutron client is needed as long as bgpvpn heat module
+ # is not yet installed by default in apex (APEX-618)
+ neutron_client = os_utils.get_neutron_client()
+
+ image_ids = []
+ bgpvpn_ids = []
+
+ try:
+ image_id = os_utils.create_glance_image(
+ conn, TESTCASE_CONFIG.image_name,
+ COMMON_CONFIG.image_path, disk=COMMON_CONFIG.image_format,
+ container='bare', public='public')
+ image_ids = [image_id]
+
+ compute_nodes = test_utils.assert_and_get_compute_nodes(conn)
+ az_1 = "nova:" + compute_nodes[0]
+ # spawning the VMs on the same compute because fib flow (21) entries
+ # are not created properly if vm1 and vm2 are attached to two
+ # different computes
+
+ file_path = pkg_resources.resource_filename(
+ 'sdnvpn', TESTCASE_CONFIG.hot_file_name)
+ templ = open(file_path, 'r').read()
+ logger.debug("Template is read: '%s'" % templ)
+ env = test_utils.get_heat_environment(TESTCASE_CONFIG, COMMON_CONFIG)
+ logger.debug("Environment is read: '%s'" % env)
+
+ env['name'] = TESTCASE_CONFIG.stack_name
+ env['parameters']['external_nw'] = os_utils.get_external_net(conn)
+ env['template'] = templ
+ env['parameters']['image_n'] = TESTCASE_CONFIG.image_name
+ env['parameters']['av_zone_1'] = az_1
+
+ stack_id = os_utils.create_stack(conn, **env)
+ if stack_id is None:
+ logger.error('Stack create start failed')
+ raise SystemError('Stack create start failed')
+
+ test_utils.wait_stack_for_status(conn, stack_id, 'CREATE_COMPLETE')
+
+ router_1_output = os_utils.get_output(conn, stack_id, 'router_1_o')
+ router_1_id = router_1_output['output_value']
+ net_2_output = os_utils.get_output(conn, stack_id, 'net_2_o')
+ network_2_id = net_2_output['output_value']
+
+ vm_stack_output_keys = ['vm1_o', 'vm2_o']
+ vms = test_utils.get_vms_from_stack_outputs(conn,
+ stack_id,
+ vm_stack_output_keys)
+
+ logger.debug("Entering base test case with stack '%s'" % stack_id)
+
+ # TODO: check if ODL fixed bug
+ # https://jira.opendaylight.org/browse/NETVIRT-932
+ results.record_action('Create VPN with eRT==iRT')
+ vpn_name = 'sdnvpn-8'
+ kwargs = {
+ 'import_targets': TESTCASE_CONFIG.targets,
+ 'export_targets': TESTCASE_CONFIG.targets,
+ 'route_distinguishers': TESTCASE_CONFIG.route_distinguishers,
+ 'name': vpn_name
+ }
+ bgpvpn = test_utils.create_bgpvpn(neutron_client, **kwargs)
+ bgpvpn_id = bgpvpn['bgpvpn']['id']
+ logger.debug("VPN created details: %s" % bgpvpn)
+ bgpvpn_ids.append(bgpvpn_id)
+
+ msg = ("Associate router '%s' and net '%s' to the VPN."
+ % (TESTCASE_CONFIG.heat_parameters['router_1_name'],
+ TESTCASE_CONFIG.heat_parameters['net_2_name']))
+ results.record_action(msg)
+ results.add_to_summary(0, "-")
+
+ test_utils.create_router_association(
+ neutron_client, bgpvpn_id, router_1_id)
+ test_utils.create_network_association(
+ neutron_client, bgpvpn_id, network_2_id)
+
+ test_utils.wait_for_bgp_router_assoc(
+ neutron_client, bgpvpn_id, router_1_id)
+ test_utils.wait_for_bgp_net_assoc(
+ neutron_client, bgpvpn_id, network_2_id)
+
+ results.get_ping_status(vms[0], vms[1], expected="PASS", timeout=200)
+ results.add_to_summary(0, "=")
+
+ msg = "Assign a Floating IP to %s - using stack update" % vms[0].name
+ results.record_action(msg)
+
+ file_path = pkg_resources.resource_filename(
+ 'sdnvpn', TESTCASE_CONFIG.hot_update_file_name)
+ templ_update = open(file_path, 'r').read()
+ logger.debug("Update template is read: '%s'" % templ_update)
+ templ = test_utils.merge_yaml(templ, templ_update)
+
+ env['name'] = TESTCASE_CONFIG.stack_name
+ env['parameters']['external_nw'] = os_utils.get_external_net(conn)
+ env['template'] = templ
+ env['parameters']['image_n'] = TESTCASE_CONFIG.image_name
+ env['parameters']['av_zone_1'] = az_1
+
+ os_utils.update_stack(conn, stack_id, **env)
+
+ test_utils.wait_stack_for_status(conn, stack_id, 'UPDATE_COMPLETE')
+
+ fip_1_output = os_utils.get_output(conn, stack_id, 'fip_1_o')
+ fip = fip_1_output['output_value']
+
+ results.add_to_summary(0, "=")
+ results.record_action("Ping %s via Floating IP" % vms[0].name)
+ results.add_to_summary(0, "-")
+ results.ping_ip_test(fip)
+
+ except Exception as e:
+ logger.error("exception occurred while executing testcase_8bis: %s", e)
+ raise
+ finally:
+ test_utils.cleanup_glance(conn, image_ids)
+ test_utils.cleanup_neutron(conn, neutron_client, [], bgpvpn_ids,
+ [], [], [], [])
+
+ try:
+ test_utils.delete_stack_and_wait(conn, stack_id)
+ except Exception as e:
+ logger.error(
+ "exception occurred while executing testcase_8bis: %s", e)
+
+ return results.compile_summary()
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/sdnvpn/test/functest/testcase_9.py b/sdnvpn/test/functest/testcase_9.py
index a4cfa5a..c74ceb5 100644
--- a/sdnvpn/test/functest/testcase_9.py
+++ b/sdnvpn/test/functest/testcase_9.py
@@ -13,18 +13,19 @@
# - Start a BGP router with OpenDaylight
# - Add the functest Quagga as a neighbor
# - Verify that the OpenDaylight and gateway Quagga peer
+import logging
import sys
+import os
from sdnvpn.lib import config as sdnvpn_config
from sdnvpn.lib import utils as test_utils
from sdnvpn.lib.results import Results
-from sdnvpn.lib import logutil
COMMON_CONFIG = sdnvpn_config.CommonConfig()
TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
"sdnvpn.test.functest.testcase_9")
-logger = logutil.getLogger('__name__')
+logger = logging.getLogger('__name__')
def main():
@@ -34,12 +35,21 @@ def main():
results.add_to_summary(0, "=")
openstack_nodes = test_utils.get_nodes()
-
+ installer_type = str(os.environ['INSTALLER_TYPE'].lower())
# node.is_odl() doesn't work in Apex
# https://jira.opnfv.org/browse/RELENG-192
- controllers = [node for node in openstack_nodes
- if "running" in
- node.run_cmd("sudo systemctl status opendaylight")]
+ fuel_cmd = "sudo systemctl status opendaylight"
+ apex_cmd = "sudo docker exec opendaylight_api " \
+ "/opt/opendaylight/bin/status"
+ health_cmd = "sudo docker ps -f name=opendaylight_api -f " \
+ "health=healthy -q"
+ if installer_type in ["fuel"]:
+ controllers = [node for node in openstack_nodes
+ if "running" in node.run_cmd(fuel_cmd)]
+ elif installer_type in ["apex"]:
+ controllers = [node for node in openstack_nodes
+ if node.run_cmd(health_cmd)
+ if "Running" in node.run_cmd(apex_cmd)]
msg = ("Verify that all OpenStack nodes OVS br-int have "
"fail_mode set to secure")