Change-Id: I13f5c13d1e04e90c550551e535dc5ce0404d8744changes/23/670823/2
parent
5acbc53823
commit
581f4ed338
@ -0,0 +1,49 @@
|
||||
# Copyright 2019 Red Hat
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from __future__ import absolute_import
|
||||
|
||||
import tobiko
|
||||
from tobiko import config
|
||||
from tobiko.openstack import glance
|
||||
from tobiko.openstack.stacks import _nova
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
CIRROS_IMAGE_URL = \
|
||||
'http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img'
|
||||
|
||||
|
||||
class CirrosImageFixture(glance.URLGlanceImageFixture):
|
||||
|
||||
image_url = CONF.tobiko.cirros.image_url or CIRROS_IMAGE_URL
|
||||
image_name = CONF.tobiko.cirros.image_name
|
||||
image_file = CONF.tobiko.cirros.image_file
|
||||
container_format = CONF.tobiko.cirros.container_format or "bare"
|
||||
disk_format = CONF.tobiko.cirros.disk_format or "raw"
|
||||
username = CONF.tobiko.cirros.username or 'cirros'
|
||||
password = CONF.tobiko.cirros.password or 'gocubsgo'
|
||||
|
||||
|
||||
class CirrosFlavorStackFixture(_nova.FlavorStackFixture):
|
||||
ram = 128
|
||||
|
||||
|
||||
class CirrosServerStackFixture(_nova.ServerStackFixture):
|
||||
|
||||
#: Glance image used to create a Nova server instance
|
||||
image_fixture = tobiko.required_setup_fixture(CirrosImageFixture)
|
||||
|
||||
#: Glance image used to create a Nova server instance
|
||||
flavor_stack = tobiko.required_setup_fixture(CirrosFlavorStackFixture)
|
@ -0,0 +1,51 @@
|
||||
# Copyright (c) 2019 Red Hat, Inc.
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from __future__ import absolute_import
|
||||
|
||||
import testtools
|
||||
|
||||
import tobiko
|
||||
from tobiko.openstack import stacks
|
||||
from tobiko.shell import ping
|
||||
from tobiko.shell import sh
|
||||
|
||||
|
||||
class CirrosServerStackTest(testtools.TestCase):
|
||||
"""Tests connectivity to Nova instances via floating IPs"""
|
||||
|
||||
#: Stack of resources with a server attached to a floating IP
|
||||
stack = tobiko.required_setup_fixture(stacks.CirrosServerStackFixture)
|
||||
|
||||
def test_ping(self):
|
||||
"""Test connectivity to floating IP address"""
|
||||
ping.ping_until_received(
|
||||
self.stack.floating_ip_address).assert_replied()
|
||||
|
||||
def test_ssh_connect(self):
|
||||
"""Test SSH connectivity via Paramiko SSHClient"""
|
||||
self.stack.ssh_client.connect()
|
||||
|
||||
def test_ssh_command(self):
|
||||
"""Test SSH connectivity via OpenSSH client"""
|
||||
sh.execute('true', shell=self.stack.ssh_command)
|
||||
|
||||
def test_hostname(self):
|
||||
"""Test that hostname of instance server matches Nova server name"""
|
||||
self.stack.ssh_client.connect()
|
||||
|
||||
hostname, = sh.execute(
|
||||
'hostname', ssh_client=self.stack.ssh_client).stdout.splitlines()
|
||||
self.assertEqual(hostname, self.stack.server_name)
|
Loading…
Reference in new issue