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
This commit is contained in:
parent
16b5bd09e9
commit
ae69976802
|
@ -230,10 +230,17 @@ class ClientTestBase(testtools.TestCase):
|
|||
self.client.api_version = proxy_api_version
|
||||
try:
|
||||
# TODO(mriedem): Get the networks from neutron if using neutron
|
||||
CACHE["network"] = pick_network(self.client.networks.list())
|
||||
networks = self.client.networks.list()
|
||||
# Keep track of whether or not there are multiple networks
|
||||
# available to the given tenant because if so, a specific
|
||||
# network ID has to be passed in on server create requests
|
||||
# otherwise the server POST will fail with a 409.
|
||||
CACHE['multiple_networks'] = len(networks) > 1
|
||||
CACHE["network"] = pick_network(networks)
|
||||
finally:
|
||||
self.client.api_version = tested_api_version
|
||||
self.network = CACHE["network"]
|
||||
self.multiple_networks = CACHE['multiple_networks']
|
||||
|
||||
# create a CLI client in case we'd like to do CLI
|
||||
# testing. tempest.lib does this really weird thing where it
|
||||
|
|
|
@ -35,13 +35,17 @@ class TestServersBootNovaClient(base.ClientTestBase):
|
|||
if bdm_params:
|
||||
bdm_params = ''.join((':', bdm_params))
|
||||
|
||||
server_info = self.nova("boot", params=(
|
||||
params = (
|
||||
"%(name)s --flavor %(flavor)s --poll "
|
||||
"--block-device-mapping vda=%(volume_id)s%(bdm_params)s" % {
|
||||
"name": uuidutils.generate_uuid(), "flavor":
|
||||
self.flavor.id,
|
||||
"volume_id": volume.id,
|
||||
"bdm_params": bdm_params}))
|
||||
"bdm_params": bdm_params})
|
||||
# check to see if we have to pass in a network id
|
||||
if self.multiple_networks:
|
||||
params += ' --nic net-id=%s' % self.network.id
|
||||
server_info = self.nova("boot", params=params)
|
||||
server_id = self._get_value_from_the_table(server_info, "id")
|
||||
|
||||
self.client.servers.delete(server_id)
|
||||
|
|
|
@ -205,6 +205,12 @@ class TestServersAutoAllocateNetworkCLI(base.ClientTestBase):
|
|||
def test_boot_server_with_auto_network(self):
|
||||
"""Tests that the CLI defaults to 'auto' when --nic isn't specified.
|
||||
"""
|
||||
# check to see if multiple networks are available because if so we
|
||||
# have to skip this test as auto will fail with a 409 conflict as it's
|
||||
# an ambiguous request and nova won't know which network to pick
|
||||
if self.multiple_networks:
|
||||
# we could potentially get around this by extending TenantTestBase
|
||||
self.skipTest('multiple networks available')
|
||||
server_info = self.nova('boot', params=(
|
||||
'%(name)s --flavor %(flavor)s --poll '
|
||||
'--image %(image)s ' % {'name': self.name_generate('server'),
|
||||
|
|
Loading…
Reference in New Issue