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
This commit is contained in:
Slawek Kaplonski 2020-02-03 11:48:34 +01:00
parent de952714e2
commit 2a71a89664
1 changed files with 11 additions and 4 deletions

View File

@ -15,6 +15,7 @@
import netaddr import netaddr
from neutron_lib import constants
from tempest.common import compute from tempest.common import compute
from tempest.common import utils from tempest.common import utils
from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import data_utils
@ -185,10 +186,16 @@ class NetworkConnectivityTest(base.BaseTempestTestCase):
Test ensures that both 10.1.0.1 and 10.1.0.x IP addresses are Test ensures that both 10.1.0.1 and 10.1.0.x IP addresses are
reachable from VM. reachable from VM.
""" """
ext_network = self.safe_client.show_network(self.external_network_id) ext_network = self.client.show_network(self.external_network_id)
ext_subnet_id = ext_network['network']['subnets'][0]['id'] for ext_subnetid in ext_network['network']['subnets']:
ext_subnet = self.safe_client.show_subnet(ext_subnet_id) ext_subnet = self.os_admin.network_client.show_subnet(ext_subnetid)
ext_cidr = ext_subnet['subnet']['cidr'] 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) subnet_cidr = ip_utils.find_valid_cidr(used_cidr=ext_cidr)
gw_ip = netaddr.IPAddress(subnet_cidr.first + 1) gw_ip = netaddr.IPAddress(subnet_cidr.first + 1)