Tempest: add tempest test for server floatingip association/disassociation
Change-Id: I9570834e15b0182d8eaf5991053608f2e60825e5 Partial-Bug: #1697813
This commit is contained in:
parent
260361c5f4
commit
393f8c5412
|
@ -48,6 +48,8 @@ class BaseBaremetalComputeTest(tempest.test.BaseTestCase):
|
|||
cls.baremetal_compute_client = cls.os_admin.baremetal_compute_client
|
||||
cls.compute_networks_client = cls.os_admin.compute_networks_client
|
||||
cls.baremetal_node_client = cls.os_admin.baremetal_node_client
|
||||
cls.network_floatingip_client =\
|
||||
cls.os_admin.network_floatingip_client
|
||||
|
||||
@classmethod
|
||||
def _get_small_flavor(cls):
|
||||
|
@ -76,6 +78,7 @@ class BaseBaremetalComputeTest(tempest.test.BaseTestCase):
|
|||
cls.small_flavor = cls._get_small_flavor()
|
||||
cls.image_id = CONF.compute.image_ref
|
||||
cls.net_id = cls._get_net_id()
|
||||
cls.ext_net_id = CONF.network.public_network_id
|
||||
|
||||
@classmethod
|
||||
def create_server(cls, wait_until_active=True):
|
||||
|
|
|
@ -187,3 +187,16 @@ class BaremetalComputeAPIServersTest(base.BaseBaremetalComputeTest):
|
|||
fixed_ip = nic['fixed_ips'][0]
|
||||
self.assertIn('subnet_id', fixed_ip)
|
||||
self.assertIn('ip_address', fixed_ip)
|
||||
|
||||
def test_floatingip_association_disassociation(self):
|
||||
self._ensure_states_before_test()
|
||||
resp = self.network_floatingip_client.create_floatingip(
|
||||
floating_network_id=self.ext_net_id)
|
||||
floatingip = resp['floatingip']
|
||||
self.baremetal_compute_client.server_associate_floatingip(
|
||||
self.server_ids[0], floatingip['floating_ip_address'])
|
||||
# TODO(liusheng) for now we cannot query the server info including
|
||||
# floatingip, that maybe a bug and the future fix need also to
|
||||
# update this test.
|
||||
self.baremetal_compute_client.server_disassociate_floatingip(
|
||||
self.server_ids[0], floatingip['floating_ip_address'])
|
||||
|
|
|
@ -18,6 +18,7 @@ from tempest import config
|
|||
from tempest.lib.common import rest_client
|
||||
from tempest.lib.services.compute import networks_client as network_cli
|
||||
from tempest.lib.services.image.v2 import images_client as image_cli
|
||||
from tempest.lib.services.network import floating_ips_client as fip_cli
|
||||
from tempest import manager
|
||||
|
||||
CONF = config.CONF
|
||||
|
@ -201,6 +202,29 @@ class BaremetalComputeClient(rest_client.RestClient):
|
|||
body = self.deserialize(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def server_associate_floatingip(self, server_id, floatingip,
|
||||
fixed_ip=None):
|
||||
uri = '%s/servers/%s/networks/floatingips' % (
|
||||
self.uri_prefix, server_id)
|
||||
body = {"address": floatingip}
|
||||
if fixed_ip:
|
||||
body.update({'fixed_address': fixed_ip})
|
||||
body = self.serialize(body)
|
||||
resp, body = self.post(uri, body)
|
||||
self.expected_success(204, resp.status)
|
||||
if body:
|
||||
body = self.deserialize(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def server_disassociate_floatingip(self, server_id, floatingip):
|
||||
uri = '%s/servers/%s/networks/floatingips/%s' % (
|
||||
self.uri_prefix, server_id, floatingip)
|
||||
resp, body = self.delete(uri)
|
||||
self.expected_success(204, resp.status)
|
||||
if body:
|
||||
body = self.deserialize(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
|
||||
class BaremetalNodeClient(rest_client.RestClient):
|
||||
version = '1'
|
||||
|
@ -270,7 +294,8 @@ class Manager(manager.Manager):
|
|||
'baremetal_compute_client',
|
||||
'compute_networks_client',
|
||||
'image_client_v2',
|
||||
'baremetal_node_client'
|
||||
'baremetal_node_client',
|
||||
'network_floatingip_client'
|
||||
]
|
||||
|
||||
default_params = {
|
||||
|
@ -305,6 +330,15 @@ class Manager(manager.Manager):
|
|||
}
|
||||
image_params.update(default_params)
|
||||
|
||||
network_params = {
|
||||
'service': CONF.network.catalog_type,
|
||||
'region': CONF.network.region or CONF.identity.region,
|
||||
'endpoint_type': CONF.network.endpoint_type,
|
||||
'build_interval': CONF.network.build_interval,
|
||||
'build_timeout': CONF.network.build_timeout,
|
||||
}
|
||||
network_params.update(default_params)
|
||||
|
||||
baremetal_node_params = {
|
||||
'service': CONF.baremetal_node_plugin.catalog_type,
|
||||
'region': CONF.identity.region,
|
||||
|
@ -326,6 +360,11 @@ class Manager(manager.Manager):
|
|||
self.auth_provider,
|
||||
**self.compute_params)
|
||||
|
||||
def set_network_floatingip_client(self):
|
||||
self.network_floatingip_client = fip_cli.FloatingIPsClient(
|
||||
self.auth_provider,
|
||||
**self.network_params)
|
||||
|
||||
def set_image_client_v2(self):
|
||||
self.image_client_v2 = image_cli.ImagesClient(
|
||||
self.auth_provider,
|
||||
|
|
Loading…
Reference in New Issue