Update VM to VM conectivity test case
Change-Id: I8b6b431386eed5d1e63be78d4dba4e82ef0bdb82
This commit is contained in:
parent
2064da00bb
commit
9b9dec3bdb
@ -194,9 +194,11 @@ class PeerServerStackFixture(ServerStackFixture):
|
||||
|
||||
@property
|
||||
def ssh_command(self):
|
||||
proxy_command = self.peer_stack.ssh_command + [
|
||||
'nc', self.ip_address, '22']
|
||||
return ssh.ssh_command(host=self.ip_address,
|
||||
username=self.username,
|
||||
proxy_command=self.peer_stack.ssh_command)
|
||||
proxy_command=proxy_command)
|
||||
|
||||
|
||||
@nova.skip_if_missing_hypervisors(count=2, state='up', status='enabled')
|
||||
|
@ -15,6 +15,8 @@
|
||||
# under the License.
|
||||
from __future__ import absolute_import
|
||||
|
||||
import subprocess
|
||||
|
||||
import six
|
||||
|
||||
from tobiko.shell.ssh import _config
|
||||
@ -30,7 +32,8 @@ def ssh_login(hostname, username=None, port=None):
|
||||
|
||||
|
||||
def ssh_command(host, username=None, port=None, command=None,
|
||||
config_files=None, host_config=None, **options):
|
||||
config_files=None, host_config=None, proxy_command=None,
|
||||
**options):
|
||||
host_config = host_config or _config.ssh_host_config(
|
||||
host=host, config_files=config_files)
|
||||
|
||||
@ -49,16 +52,22 @@ def ssh_command(host, username=None, port=None, command=None,
|
||||
if port:
|
||||
command += ['-p', port]
|
||||
|
||||
if proxy_command:
|
||||
if not isinstance(proxy_command, six.string_types):
|
||||
proxy_command = subprocess.list2cmdline(proxy_command)
|
||||
options['ProxyCommand'] = proxy_command
|
||||
|
||||
for name, value in host_config.host_config.items():
|
||||
if name not in {'hostname', 'port', 'user'}:
|
||||
options.setdefault(name, value)
|
||||
options.setdefault('userknownhostsfile', '/dev/null')
|
||||
options.setdefault('stricthostkeychecking', 'no')
|
||||
options.setdefault('loglevel', 'quiet')
|
||||
options.setdefault('connecttimeout', int(host_config.timeout))
|
||||
options.setdefault('connectionattempts', host_config.connection_attempts)
|
||||
options.setdefault('UserKnownHostsFile', '/dev/null')
|
||||
options.setdefault('StrictHostKeyChecking', 'no')
|
||||
options.setdefault('LogLevel', 'quiet')
|
||||
options.setdefault('ConnectTimeout', int(host_config.timeout))
|
||||
options.setdefault('ConnectionAttempts', host_config.connection_attempts)
|
||||
if options:
|
||||
for name, value in sorted(options.items()):
|
||||
name = name.replace('_', '')
|
||||
command += ['-o', '{!s}={!s}'.format(name, value)]
|
||||
|
||||
return command
|
||||
|
@ -41,14 +41,14 @@ class FloatingIPTest(testtools.TestCase):
|
||||
def test_ssh(self):
|
||||
"""Test SSH connectivity to floating IP address"""
|
||||
result = sh.execute("hostname", ssh_client=self.stack.ssh_client)
|
||||
hostname, = str(result.stdout).splitlines()
|
||||
self.assertEqual(self.stack.server_name.lower(), hostname)
|
||||
self.assertEqual(self.stack.server_name.lower(),
|
||||
result.stdout.rstrip())
|
||||
|
||||
def test_ssh_from_cli(self):
|
||||
"""Test SSH connectivity to floating IP address from CLI"""
|
||||
result = sh.execute("hostname", shell=self.stack.ssh_command)
|
||||
hostname, = str(result.stdout).splitlines()
|
||||
self.assertEqual(self.stack.server_name.lower(), hostname)
|
||||
self.assertEqual(self.stack.server_name.lower(),
|
||||
result.stdout.rstrip())
|
||||
|
||||
def test_ping(self):
|
||||
"""Test ICMP connectivity to floating IP address"""
|
||||
|
@ -18,8 +18,10 @@ from __future__ import absolute_import
|
||||
import testtools
|
||||
|
||||
import tobiko
|
||||
from tobiko.openstack import neutron
|
||||
from tobiko.openstack import nova
|
||||
from tobiko.openstack import stacks
|
||||
from tobiko.shell import ping
|
||||
from tobiko.shell import sh
|
||||
|
||||
|
||||
@ -28,17 +30,42 @@ class NetworkTest(testtools.TestCase):
|
||||
#: Resources stack with Nova server to send messages to
|
||||
stack = tobiko.required_setup_fixture(stacks.CirrosPeerServerStackFixture)
|
||||
|
||||
def test_stack_create_complete(self):
|
||||
self.stack.key_pair_stack.wait_for_create_complete()
|
||||
self.stack.network_stack.wait_for_create_complete()
|
||||
self.stack.peer_stack.wait_for_create_complete()
|
||||
self.stack.wait_for_create_complete()
|
||||
|
||||
def test_ssh(self):
|
||||
"""Test SSH connectivity to floating IP address"""
|
||||
result = sh.execute("hostname",
|
||||
ssh_client=self.stack.ssh_client)
|
||||
hostname = result.stdout.rstrip()
|
||||
self.assertEqual(self.stack.server_name.lower(), hostname)
|
||||
result = sh.execute("hostname", ssh_client=self.stack.ssh_client)
|
||||
self.assertEqual(self.stack.server_name.lower(),
|
||||
result.stdout.rstrip())
|
||||
|
||||
def test_ssh_from_cli(self):
|
||||
"""Test SSH connectivity to floating IP address from CLI"""
|
||||
result = sh.execute("hostname", shell=self.stack.ssh_command)
|
||||
self.assertEqual(self.stack.server_name.lower(),
|
||||
result.stdout.rstrip())
|
||||
|
||||
def test_ping(self):
|
||||
"""Test ICMP connectivity to floating IP address"""
|
||||
ping.ping_until_received(
|
||||
self.stack.ip_address,
|
||||
ssh_client=self.stack.peer_stack.ssh_client).assert_replied()
|
||||
|
||||
# --- test l3_ha extension ------------------------------------------------
|
||||
|
||||
@neutron.skip_if_missing_networking_extensions('l3-ha')
|
||||
def test_l3_ha(self):
|
||||
"""Test 'mtu' network attribute"""
|
||||
gateway = self.stack.network_stack.gateway_details
|
||||
self.assertEqual(self.stack.network_stack.ha,
|
||||
gateway['ha'])
|
||||
|
||||
|
||||
# --- Same compute host VM to VM scenario -------------------------------------
|
||||
|
||||
|
||||
class SameHostNetworkTest(NetworkTest):
|
||||
|
||||
#: Resources stack with Nova server to send messages to
|
||||
@ -56,7 +83,6 @@ class SameHostNetworkTest(NetworkTest):
|
||||
|
||||
# --- Different compute host VM to VM scenario --------------------------------
|
||||
|
||||
|
||||
@nova.skip_if_missing_hypervisors(count=2, state='up', status='enabled')
|
||||
class DifferentHostNetworkTest(NetworkTest):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user