summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem@us.ibm.com>2017-01-09 22:09:22 -0500
committerMatt Riedemann <mriedem@us.ibm.com>2017-01-24 18:44:37 -0500
commitae699768023bb0a8d60798eca7f0cc8aebfe3355 (patch)
treef488dac48f461af5cf7c18f475a7ecc36bfcef96
parent16b5bd09e93bc2dc0b6e4955e8508c0299efd2e0 (diff)
downloadpython-novaclient-ae699768023bb0a8d60798eca7f0cc8aebfe3355.tar.gz
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
-rw-r--r--novaclient/tests/functional/base.py9
-rw-r--r--novaclient/tests/functional/v2/legacy/test_servers.py8
-rw-r--r--novaclient/tests/functional/v2/test_servers.py6
3 files changed, 20 insertions, 3 deletions
diff --git a/novaclient/tests/functional/base.py b/novaclient/tests/functional/base.py
index acc11013..f87298d4 100644
--- a/novaclient/tests/functional/base.py
+++ b/novaclient/tests/functional/base.py
@@ -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
diff --git a/novaclient/tests/functional/v2/legacy/test_servers.py b/novaclient/tests/functional/v2/legacy/test_servers.py
index cfc3939a..ad773f1a 100644
--- a/novaclient/tests/functional/v2/legacy/test_servers.py
+++ b/novaclient/tests/functional/v2/legacy/test_servers.py
@@ -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)
diff --git a/novaclient/tests/functional/v2/test_servers.py b/novaclient/tests/functional/v2/test_servers.py
index 31b2ae06..6adf1e05 100644
--- a/novaclient/tests/functional/v2/test_servers.py
+++ b/novaclient/tests/functional/v2/test_servers.py
@@ -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'),