Skip to content

Commit ae69976

Browse files
author
Matt Riedemann
committed
Fix functional tests to deal with multiple networks
There was a change in the openstacksdk 0.9.11 which python-openstackclient uses to create networks in a devstack run with Neutron. Because of this change, the admin tenant has access to both the 'public' and 'private' network setup in devstack which before used to just be the 'public' network, which exposed a bug in the novaclient functional testing where the admin user is attempting to create a server but not specify a specific network to use, but multiple networks are available to the admin (it can list multiple networks). In this case the networks are the standard public and private networks that are created in devstack. Since a network isn't specified when creating the server, the nova API fails with a 409 error because it can't determine which network to use. This patch fixes the testing in novaclient by checking to see if there are multiple networks available and if so, specifies one for the legacy BDM tests that weren't specifying a network ID (those tests don't really care about the networking). The auto-network test is skipped if there are multiple networks available because passing in a specific network would defeat the purpose of that test. Change-Id: I22ee148581a94b153cf7e733563cfafaa56b1ffd Closes-Bug: #1654806
1 parent 16b5bd0 commit ae69976

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

novaclient/tests/functional/base.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,17 @@ def setUp(self):
230230
self.client.api_version = proxy_api_version
231231
try:
232232
# TODO(mriedem): Get the networks from neutron if using neutron
233-
CACHE["network"] = pick_network(self.client.networks.list())
233+
networks = self.client.networks.list()
234+
# Keep track of whether or not there are multiple networks
235+
# available to the given tenant because if so, a specific
236+
# network ID has to be passed in on server create requests
237+
# otherwise the server POST will fail with a 409.
238+
CACHE['multiple_networks'] = len(networks) > 1
239+
CACHE["network"] = pick_network(networks)
234240
finally:
235241
self.client.api_version = tested_api_version
236242
self.network = CACHE["network"]
243+
self.multiple_networks = CACHE['multiple_networks']
237244

238245
# create a CLI client in case we'd like to do CLI
239246
# testing. tempest.lib does this really weird thing where it

novaclient/tests/functional/v2/legacy/test_servers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ def _boot_server_with_legacy_bdm(self, bdm_params=()):
3535
if bdm_params:
3636
bdm_params = ''.join((':', bdm_params))
3737

38-
server_info = self.nova("boot", params=(
38+
params = (
3939
"%(name)s --flavor %(flavor)s --poll "
4040
"--block-device-mapping vda=%(volume_id)s%(bdm_params)s" % {
4141
"name": uuidutils.generate_uuid(), "flavor":
4242
self.flavor.id,
4343
"volume_id": volume.id,
44-
"bdm_params": bdm_params}))
44+
"bdm_params": bdm_params})
45+
# check to see if we have to pass in a network id
46+
if self.multiple_networks:
47+
params += ' --nic net-id=%s' % self.network.id
48+
server_info = self.nova("boot", params=params)
4549
server_id = self._get_value_from_the_table(server_info, "id")
4650

4751
self.client.servers.delete(server_id)

novaclient/tests/functional/v2/test_servers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ def _find_network_in_table(self, table):
205205
def test_boot_server_with_auto_network(self):
206206
"""Tests that the CLI defaults to 'auto' when --nic isn't specified.
207207
"""
208+
# check to see if multiple networks are available because if so we
209+
# have to skip this test as auto will fail with a 409 conflict as it's
210+
# an ambiguous request and nova won't know which network to pick
211+
if self.multiple_networks:
212+
# we could potentially get around this by extending TenantTestBase
213+
self.skipTest('multiple networks available')
208214
server_info = self.nova('boot', params=(
209215
'%(name)s --flavor %(flavor)s --poll '
210216
'--image %(image)s ' % {'name': self.name_generate('server'),

0 commit comments

Comments
 (0)