Fix tests when having multiple floating pools

Compute API and scenario test fail even though
'floating_network_name' is specified. This patch provides
floating_network_name from tempest.conf as pool, when
create_floating_ip is used.

Change-Id: I2fc7fe59e5e90fb2739dc7eaa3432e7acb967013
Closes-Bug: #1475143
Co-Authored-By: Tom Patzig <tom.patzig@sap.com>
This commit is contained in:
Marc Koderer 2016-03-22 15:23:31 +01:00 committed by Tom Patzig
parent e6b66b6415
commit 3b57d805eb
5 changed files with 23 additions and 7 deletions

View File

@ -16,9 +16,12 @@
from tempest.api.compute.floating_ips import base
from tempest.common.utils import data_utils
from tempest.common import waiters
from tempest import config
from tempest.lib import exceptions as lib_exc
from tempest import test
CONF = config.CONF
class FloatingIPsTestJSON(base.BaseFloatingIPsTest):
server_id = None
@ -38,7 +41,8 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest):
server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
# Floating IP creation
body = cls.client.create_floating_ip()['floating_ip']
body = cls.client.create_floating_ip(
pool=CONF.network.floating_network_name)['floating_ip']
cls.floating_ip_id = body['id']
cls.floating_ip = body['ip']
@ -62,7 +66,8 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest):
def test_allocate_floating_ip(self):
# Positive test:Allocation of a new floating IP to a project
# should be successful
body = self.client.create_floating_ip()['floating_ip']
body = self.client.create_floating_ip(
pool=CONF.network.floating_network_name)['floating_ip']
floating_ip_id_allocated = body['id']
self.addCleanup(self.client.delete_floating_ip,
floating_ip_id_allocated)
@ -78,7 +83,8 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest):
# Positive test:Deletion of valid floating IP from project
# should be successful
# Creating the floating IP that is to be deleted in this method
floating_ip_body = self.client.create_floating_ip()['floating_ip']
floating_ip_body = self.client.create_floating_ip(
pool=CONF.network.floating_network_name)['floating_ip']
self.addCleanup(self._try_delete_floating_ip, floating_ip_body['id'])
# Deleting the floating IP from the project
self.client.delete_floating_ip(floating_ip_body['id'])

View File

@ -14,8 +14,11 @@
# under the License.
from tempest.api.compute import base
from tempest import config
from tempest import test
CONF = config.CONF
class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest):
@ -31,7 +34,8 @@ class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest):
cls.floating_ip = []
cls.floating_ip_id = []
for i in range(3):
body = cls.client.create_floating_ip()['floating_ip']
body = cls.client.create_floating_ip(
pool=CONF.network.floating_network_name)['floating_ip']
cls.floating_ip.append(body)
cls.floating_ip_id.append(body['id'])
@ -57,7 +61,8 @@ class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest):
def test_get_floating_ip_details(self):
# Positive test:Should be able to GET the details of floatingIP
# Creating a floating IP for which details are to be checked
body = self.client.create_floating_ip()['floating_ip']
body = self.client.create_floating_ip(
pool=CONF.network.floating_network_name)['floating_ip']
floating_ip_id = body['id']
self.addCleanup(self.client.delete_floating_ip,
floating_ip_id)

View File

@ -41,7 +41,8 @@ class ServerRescueTestJSON(base.BaseV2ComputeTest):
super(ServerRescueTestJSON, cls).resource_setup()
# Floating IP creation
body = cls.floating_ips_client.create_floating_ip()['floating_ip']
body = cls.floating_ips_client.create_floating_ip(
pool=CONF.network.floating_network_name)['floating_ip']
cls.floating_ip_id = str(body['id']).strip()
cls.floating_ip = str(body['ip']).strip()

View File

@ -59,7 +59,9 @@ def create_validation_resources(os, validation_resources=None):
create_ssh_security_group(os, add_rule)
if validation_resources['floating_ip']:
floating_client = os.compute_floating_ips_client
validation_data.update(floating_client.create_floating_ip())
validation_data.update(
floating_client.create_floating_ip(
pool=CONF.network.floating_network_name))
return validation_data

View File

@ -600,6 +600,8 @@ class ScenarioTest(tempest.test.BaseTestCase):
def create_floating_ip(self, thing, pool_name=None):
"""Create a floating IP and associates to a server on Nova"""
if not pool_name:
pool_name = CONF.network.floating_network_name
floating_ip = (self.compute_floating_ips_client.
create_floating_ip(pool=pool_name)['floating_ip'])
self.addCleanup(self.delete_wrapper,