Use shared floating ip server stack in test_floating_ip

Change-Id: I8fc25482f2c654f7342150b0010c25aee5e73024
This commit is contained in:
Federico Ressi 2019-06-07 10:32:19 +02:00
parent 96065e0c2a
commit d5fe4ed5e6
4 changed files with 10 additions and 132 deletions

View File

@ -60,10 +60,13 @@ class NetworkStackFixture(heat.HeatStackFixture):
class FloatingIpServerStackFixture(heat.HeatStackFixture):
#: Heat template file
template = _hot.heat_template_file('neutron/server.yaml')
template = _hot.heat_template_file('neutron/floating_ip_server.yaml')
#: stack with the key pair for the server instance
key_pair_stack = tobiko.required_setup_fixture(
_nova.KeyPairStackFixture)
#: stack with the internal where the server port is created
network_stack = tobiko.required_setup_fixture(NetworkStackFixture)
#: Glance image used to create a Nova server instance

View File

@ -1,81 +0,0 @@
heat_template_version: newton
description: |
Stack of resources used to test floating IP
parameters:
key_name:
type: string
flavor:
type: string
image:
type: string
floating_network:
type: string
internal_network:
type: string
port_security_enabled:
type: boolean
default: false
security_groups:
type: comma_delimited_list
default: []
resources:
port:
type: OS::Neutron::Port
properties:
network: {get_param: internal_network}
port_security_enabled: {get_param: port_security_enabled}
security_groups: {get_param: security_groups}
server_name:
type: OS::Heat::RandomString
properties:
character_classes: [{'class': 'lowercase', 'min': 1}]
length: 8
server:
type: OS::Nova::Server
properties:
name: {get_attr: [server_name, value]}
key_name: {get_param: key_name}
image: {get_param: image}
flavor: {get_param: flavor}
networks:
- port: {get_resource: port}
floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network: {get_param: floating_network}
floating_ip_association:
type: OS::Neutron::FloatingIPAssociation
properties:
floatingip_id: {get_resource: floating_ip}
port_id: {get_resource: port}
outputs:
floating_ip_address:
value: {get_attr: [floating_ip, floating_ip_address]}
port_security_enabled:
value: {get_attr: [port, port_security_enabled]}
security_groups:
value: {get_attr: [port, security_groups]}
server_name:
value: {get_attr: [server, name]}

View File

@ -17,9 +17,7 @@ from __future__ import absolute_import
import tobiko
from tobiko import config
from tobiko.shell import ping
from tobiko.shell import ssh
from tobiko.shell import sh
from tobiko.openstack import heat
from tobiko.openstack import neutron
from tobiko.openstack import stacks
from tobiko.tests import base
@ -29,43 +27,15 @@ from tobiko.tests.scenario.neutron import _stacks
CONF = config.CONF
class FloatingIPFixture(heat.HeatStackFixture):
class FloatingIPFixture(stacks.FloatingIpServerStackFixture):
"""Heat stack for testing a floating IP instance
"""
#: Heat template file
template = _stacks.heat_template_file('floating_ip.yaml')
#: Floating IP network where the Neutron floating IP is created
floating_network = CONF.tobiko.neutron.floating_network
#: Glance image used to create a Nova server instance
image = CONF.tobiko.nova.image
#: Nova flavor used to create a Nova server instance
flavor = CONF.tobiko.nova.flavor
#: Username used to login to Nova server instance
username = CONF.tobiko.nova.username
@property
def internal_network(self):
"""Internal network where the Nova server instance is connected
"""
return self.internal_network_stack.outputs.network_id
# --- required fixtures ---
#: Heat stack for creating internal network with a router to floating
#: network
internal_network_stack = tobiko.required_setup_fixture(
#: stack with the internal where the server port is created
network_stack = tobiko.required_setup_fixture(
_stacks.InternalNetworkFixture)
# --- class parameters ---
#: Whenever port security on internal network is enable
key_pair_stack = tobiko.required_setup_fixture(
stacks.KeyPairStackFixture)
port_security_enabled = False
#: Security groups to be associated to network ports
@ -88,10 +58,6 @@ class FloatingIPFixture(heat.HeatStackFixture):
port_security_enabled=self.port_security_enabled,
security_groups=self.security_groups or [])
@property
def key_name(self):
return self.key_pair_stack.outputs.key_name
@property
def server_name(self):
return self.outputs.server_name
@ -100,16 +66,6 @@ class FloatingIPFixture(heat.HeatStackFixture):
def floating_ip_address(self):
return self.outputs.floating_ip_address
@property
def ssh_client(self):
return ssh.ssh_client(host=self.floating_ip_address,
username=self.username)
@property
def ssh_command(self):
return ssh.ssh_command(host=self.floating_ip_address,
username=self.username)
class FloatingIPTest(base.TobikoTest):
"""Tests connectivity to Nova instances via floating IPs"""
@ -212,12 +168,12 @@ class FloatingIPTest(base.TobikoTest):
@property
def expected_net_mtu(self):
"""Expected MTU value for internal network"""
return self.floating_ip_stack.internal_network_stack.mtu
return self.floating_ip_stack.network_stack.mtu
@property
def observed_net_mtu(self):
"""Actual MTU value for internal network"""
return self.floating_ip_stack.internal_network_stack.outputs.mtu
return self.floating_ip_stack.network_stack.outputs.mtu
@neutron.skip_if_missing_networking_extensions('port-security')
@ -311,7 +267,7 @@ class FloatingIPWithNetMtuWritableFixture(FloatingIPFixture):
"""
#: Heat stack for creating internal network with custom MTU value
internal_network_stack = tobiko.required_setup_fixture(
network_stack = tobiko.required_setup_fixture(
_stacks.InternalNetworkWithNetMtuWritableFixture)