Share stack across tests
Less time is wasted on creating stacks for each separate test. Also, updated requirements. Change-Id: I99c998dd7706300de5f96ea84698098655785a22
This commit is contained in:
parent
a069de44fa
commit
0cf6dfb5c3
10
README.rst
10
README.rst
@ -2,10 +2,8 @@
|
|||||||
Tobiko
|
Tobiko
|
||||||
======
|
======
|
||||||
|
|
||||||
To run pre-upgrade tests:
|
Tempest plugin for testing upgrades
|
||||||
|
|
||||||
tempest run --regex pre
|
* Free software: Apache license
|
||||||
|
* Source: https://git.openstack.org/cgit/openstack/tobiko
|
||||||
To run post-upgrade tests:
|
* Bugs: https://bugs.launchpad.net/tobiko
|
||||||
|
|
||||||
tempest run --regex post
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
keystoneauth1
|
keystoneauth1>=3.4.0
|
||||||
oslo.config
|
oslo.config>=5.2.0
|
||||||
oslo.log
|
oslo.log>=3.36.0
|
||||||
python-heatclient
|
python-heatclient>=1.10.0
|
||||||
testscenarios
|
testscenarios>=0.4
|
||||||
testtools
|
testtools>=2.2.0
|
||||||
tempest
|
tempest>=17.1.0
|
||||||
|
@ -105,9 +105,6 @@ class ClientManager(object):
|
|||||||
{'user_domain_name': self.get_user_domain_name(),
|
{'user_domain_name': self.get_user_domain_name(),
|
||||||
'project_domain_name': self.get_project_domain_name()})
|
'project_domain_name': self.get_project_domain_name()})
|
||||||
|
|
||||||
with open('/tmp/stam', 'w+') as f:
|
|
||||||
f.write(str(kwargs))
|
|
||||||
|
|
||||||
loader = loading.get_plugin_loader('password')
|
loader = loading.get_plugin_loader('password')
|
||||||
auth = loader.load_from_options(**kwargs)
|
auth = loader.load_from_options(**kwargs)
|
||||||
return session.Session(auth=auth, verify=False)
|
return session.Session(auth=auth, verify=False)
|
||||||
|
@ -25,6 +25,9 @@ TobikoGroup = [
|
|||||||
help="Floating network name "),
|
help="Floating network name "),
|
||||||
cfg.StrOpt('admin_username',
|
cfg.StrOpt('admin_username',
|
||||||
help="Username to use for admin API requests."),
|
help="Username to use for admin API requests."),
|
||||||
|
cfg.StrOpt('user_domain_name',
|
||||||
|
default="Default",
|
||||||
|
help="User domain name")
|
||||||
]
|
]
|
||||||
|
|
||||||
tobiko_group = cfg.OptGroup(name="tobiko_plugin",
|
tobiko_group = cfg.OptGroup(name="tobiko_plugin",
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from tempest import config
|
from tempest import config
|
||||||
|
@ -12,10 +12,12 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from heatclient import exc
|
||||||
|
|
||||||
|
|
||||||
from tempest.common.utils import net_utils
|
from tempest.common.utils import net_utils
|
||||||
from tempest.lib.common.utils import test_utils
|
from tempest.lib.common.utils import test_utils
|
||||||
|
|
||||||
@ -35,6 +37,27 @@ class ScenarioTestsBase(base.TobikoTest):
|
|||||||
self.stackManager = stack.StackManager(self.clientManager,
|
self.stackManager = stack.StackManager(self.clientManager,
|
||||||
templates_dir)
|
templates_dir)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.stackManager.get_stack("scenario")
|
||||||
|
except exc.HTTPNotFound:
|
||||||
|
self.create_stack()
|
||||||
|
|
||||||
|
def create_stack(self):
|
||||||
|
"""Creates stack to be used by all scenario tests."""
|
||||||
|
|
||||||
|
# Defines parameters required by heat template
|
||||||
|
parameters = {'public_net': self.conf.network.floating_network_name,
|
||||||
|
'image': self.conf.compute.image_ref,
|
||||||
|
'flavor': "m1.micro"}
|
||||||
|
|
||||||
|
# creates stack and stores its ID
|
||||||
|
st = self.stackManager.create_stack(stack_name="scenario",
|
||||||
|
template_name="scenario.yaml",
|
||||||
|
parameters=parameters)
|
||||||
|
sid = st['stack']['id']
|
||||||
|
|
||||||
|
self.stackManager.wait_for_status_complete(sid, 'floating_ip')
|
||||||
|
|
||||||
def ping_ip_address(self, ip_address, should_succeed=True,
|
def ping_ip_address(self, ip_address, should_succeed=True,
|
||||||
ping_timeout=None, mtu=None):
|
ping_timeout=None, mtu=None):
|
||||||
|
|
||||||
|
85
tobiko/tests/scenario/templates/scenario.yaml
Normal file
85
tobiko/tests/scenario/templates/scenario.yaml
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
heat_template_version: 2013-05-23
|
||||||
|
|
||||||
|
description: |
|
||||||
|
Template to create an instance and check connectivity to it
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
flavor:
|
||||||
|
type: string
|
||||||
|
image:
|
||||||
|
type: string
|
||||||
|
subnet_cidr:
|
||||||
|
type: string
|
||||||
|
default: 190.40.2.0/24
|
||||||
|
public_net:
|
||||||
|
type: string
|
||||||
|
default: public
|
||||||
|
private_net:
|
||||||
|
type: string
|
||||||
|
default: heat-net
|
||||||
|
dns_servers:
|
||||||
|
type: comma_delimited_list
|
||||||
|
default: ["8.8.8.8", "8.8.4.4"]
|
||||||
|
|
||||||
|
resources:
|
||||||
|
sg:
|
||||||
|
type: OS::Neutron::SecurityGroup
|
||||||
|
properties:
|
||||||
|
name: sg
|
||||||
|
description: Security group to allow ICMP and SSH
|
||||||
|
rules:
|
||||||
|
- protocol: icmp
|
||||||
|
- protocol: tcp
|
||||||
|
port_range_min: 22
|
||||||
|
port_range_max: 22
|
||||||
|
|
||||||
|
floating_ip:
|
||||||
|
type: OS::Neutron::FloatingIP
|
||||||
|
properties:
|
||||||
|
floating_network: {get_param: public_net}
|
||||||
|
|
||||||
|
network:
|
||||||
|
type: OS::Neutron::Net
|
||||||
|
|
||||||
|
subnet:
|
||||||
|
type: OS::Neutron::Subnet
|
||||||
|
properties:
|
||||||
|
network: {get_resource: network}
|
||||||
|
ip_version: 4
|
||||||
|
cidr: {get_param: subnet_cidr}
|
||||||
|
dns_nameservers: {get_param: dns_servers}
|
||||||
|
|
||||||
|
router:
|
||||||
|
type: OS::Neutron::Router
|
||||||
|
properties:
|
||||||
|
external_gateway_info:
|
||||||
|
network: {get_param: public_net}
|
||||||
|
|
||||||
|
router_interface:
|
||||||
|
type: OS::Neutron::RouterInterface
|
||||||
|
properties:
|
||||||
|
router: {get_resource: router}
|
||||||
|
subnet: {get_resource: subnet}
|
||||||
|
|
||||||
|
wait_handle:
|
||||||
|
type: OS::Heat::WaitConditionHandle
|
||||||
|
|
||||||
|
server:
|
||||||
|
type: OS::Nova::Server
|
||||||
|
properties:
|
||||||
|
image: {get_param: image}
|
||||||
|
flavor: {get_param: flavor}
|
||||||
|
networks:
|
||||||
|
- subnet: {get_resource: subnet}
|
||||||
|
security_groups:
|
||||||
|
- {get_resource: sg}
|
||||||
|
|
||||||
|
server_floating_ip_assoc:
|
||||||
|
type: OS::Neutron::FloatingIPAssociation
|
||||||
|
properties:
|
||||||
|
floatingip_id: {get_resource: floating_ip}
|
||||||
|
port_id: {get_attr: [server, addresses, {get_resource: network}, 0, port]}
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
server_ip:
|
||||||
|
value: {get_attr: [floating_ip, floating_ip_address]}
|
@ -19,24 +19,10 @@ class FloatingIPTest(base.ScenarioTestsBase):
|
|||||||
"""Tests server connectivity"""
|
"""Tests server connectivity"""
|
||||||
|
|
||||||
def test_pre_fip(self):
|
def test_pre_fip(self):
|
||||||
"""Creates a server and checks it can reach it."""
|
"""Validates connectivity to a server created by another test."""
|
||||||
|
|
||||||
# Defines parameters required by heat template
|
|
||||||
parameters = {'public_net': self.conf.network.floating_network_name,
|
|
||||||
'image': self.conf.compute.image_ref,
|
|
||||||
'flavor': "m1.micro"}
|
|
||||||
|
|
||||||
# creates stack and stores its ID
|
|
||||||
st = self.stackManager.create_stack(stack_name="fip",
|
|
||||||
template_name="fip.yaml",
|
|
||||||
parameters=parameters)
|
|
||||||
sid = st['stack']['id']
|
|
||||||
|
|
||||||
# Before pinging the floating IP, ensure resource is ready
|
|
||||||
self.stackManager.wait_for_status_complete(sid, 'floating_ip')
|
|
||||||
|
|
||||||
# Get floating IP address
|
# Get floating IP address
|
||||||
stack = self.stackManager.client.stacks.get(sid)
|
stack = self.stackManager.get_stack(stack_name="scenario")
|
||||||
server_fip = stack.outputs[0]['output_value']
|
server_fip = stack.outputs[0]['output_value']
|
||||||
|
|
||||||
# Check if instance is reachable
|
# Check if instance is reachable
|
||||||
@ -44,9 +30,10 @@ class FloatingIPTest(base.ScenarioTestsBase):
|
|||||||
self.fail("IP address is not reachable: %s" % server_fip)
|
self.fail("IP address is not reachable: %s" % server_fip)
|
||||||
|
|
||||||
def test_post_fip(self):
|
def test_post_fip(self):
|
||||||
"""Validates connectivity to a server created by another test."""
|
"""Validates connectivity to a server post upgrade."""
|
||||||
|
|
||||||
stack = self.stackManager.get_stack(stack_name="fip")
|
# Get floating IP address
|
||||||
|
stack = self.stackManager.get_stack(stack_name="scenario")
|
||||||
server_fip = stack.outputs[0]['output_value']
|
server_fip = stack.outputs[0]['output_value']
|
||||||
|
|
||||||
# Check if instance is reachable
|
# Check if instance is reachable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user