Fix test_connectivity_dvr_and_no_dvr_routers_in_same_subnet test
This patch fixes couple of issues in scenario test from
test_connectivity module.
1. Replace safe_client with client object
In class NetworkConnectivityTest there was used safe_client
but there is no such attribute in this class. Object "client"
should be used instead.
2. It also fixes in the same test how external network's subnet
ID is get from the network's info.
3. Change to use admin_client to get details of external
network's subnet as this subnet don't belongs to tenant user
so regular client gets 404 error while doing subnet_show
command.
4. Check the subnets IP version to retrieve only an IPv4 one.
Change-Id: Ibebb20b29dd6ae902d194fd26ba1ea728a976286
Closes-bug: #1861670
diff --git a/neutron_tempest_plugin/scenario/test_connectivity.py b/neutron_tempest_plugin/scenario/test_connectivity.py
index 7d72832..5aa8f73 100644
--- a/neutron_tempest_plugin/scenario/test_connectivity.py
+++ b/neutron_tempest_plugin/scenario/test_connectivity.py
@@ -15,6 +15,7 @@
import netaddr
+from neutron_lib import constants
from tempest.common import compute
from tempest.common import utils
from tempest.lib.common.utils import data_utils
@@ -185,10 +186,16 @@
Test ensures that both 10.1.0.1 and 10.1.0.x IP addresses are
reachable from VM.
"""
- ext_network = self.safe_client.show_network(self.external_network_id)
- ext_subnet_id = ext_network['network']['subnets'][0]['id']
- ext_subnet = self.safe_client.show_subnet(ext_subnet_id)
- ext_cidr = ext_subnet['subnet']['cidr']
+ ext_network = self.client.show_network(self.external_network_id)
+ for ext_subnetid in ext_network['network']['subnets']:
+ ext_subnet = self.os_admin.network_client.show_subnet(ext_subnetid)
+ ext_cidr = ext_subnet['subnet']['cidr']
+ if ext_subnet['subnet']['ip_version'] == constants.IP_VERSION_4:
+ break
+ else:
+ self.fail('No IPv4 subnet was found in external network %s' %
+ ext_network['network']['id'])
+
subnet_cidr = ip_utils.find_valid_cidr(used_cidr=ext_cidr)
gw_ip = netaddr.IPAddress(subnet_cidr.first + 1)