diff --git a/tobiko/openstack/stacks/__init__.py b/tobiko/openstack/stacks/__init__.py index eff5305d9..6cfa2bb36 100644 --- a/tobiko/openstack/stacks/__init__.py +++ b/tobiko/openstack/stacks/__init__.py @@ -18,7 +18,7 @@ from __future__ import absolute_import from tobiko.openstack.stacks import _neutron from tobiko.openstack.stacks import _nova -NovaKeyPairStackFixture = _nova.NovaKeyPairStackFixture +KeyPairStackFixture = _nova.KeyPairStackFixture -NeutronNetworkStackFixture = _neutron.NeutronNetworkStackFixture -NeutronServerStackFixture = _neutron.NeutronServerStackFixture +NetworkStackFixture = _neutron.NetworkStackFixture +FloatingIpServerStackFixture = _neutron.FloatingIpServerStackFixture diff --git a/tobiko/openstack/stacks/_neutron.py b/tobiko/openstack/stacks/_neutron.py index cc9a52952..1dd168b66 100644 --- a/tobiko/openstack/stacks/_neutron.py +++ b/tobiko/openstack/stacks/_neutron.py @@ -27,7 +27,7 @@ from tobiko.shell import ssh CONF = config.CONF -class NeutronNetworkStackFixture(heat.HeatStackFixture): +class NetworkStackFixture(heat.HeatStackFixture): """Heat stack for creating internal network with a router to external """ @@ -57,14 +57,14 @@ class NeutronNetworkStackFixture(heat.HeatStackFixture): return bool(self.gateway_network) -class NeutronServerStackFixture(heat.HeatStackFixture): +class FloatingIpServerStackFixture(heat.HeatStackFixture): #: Heat template file template = _hot.heat_template_file('neutron/server.yaml') key_pair_stack = tobiko.required_setup_fixture( - _nova.NovaKeyPairStackFixture) - network_stack = tobiko.required_setup_fixture(NeutronNetworkStackFixture) + _nova.KeyPairStackFixture) + network_stack = tobiko.required_setup_fixture(NetworkStackFixture) #: Glance image used to create a Nova server instance image = CONF.tobiko.nova.image diff --git a/tobiko/openstack/stacks/_nova.py b/tobiko/openstack/stacks/_nova.py index 6574eebbb..682954ced 100644 --- a/tobiko/openstack/stacks/_nova.py +++ b/tobiko/openstack/stacks/_nova.py @@ -27,7 +27,7 @@ from tobiko.openstack.stacks import _hot CONF = config.CONF -class NovaKeyPairStackFixture(heat.HeatStackFixture): +class KeyPairStackFixture(heat.HeatStackFixture): template = _hot.heat_template_file('nova/key_pair.yaml') key_file = os.path.expanduser(CONF.tobiko.nova.key_file) public_key = None @@ -35,7 +35,7 @@ class NovaKeyPairStackFixture(heat.HeatStackFixture): def setup_fixture(self): self.read_keys() - super(NovaKeyPairStackFixture, self).setup_fixture() + super(KeyPairStackFixture, self).setup_fixture() def read_keys(self): with open(self.key_file, 'r') as fd: diff --git a/tobiko/shell/sh/_execute.py b/tobiko/shell/sh/_execute.py index 22baca0be..de958bc60 100644 --- a/tobiko/shell/sh/_execute.py +++ b/tobiko/shell/sh/_execute.py @@ -299,10 +299,6 @@ class StdinSSHChannelFile(SSHChannelFile): def write_ready(self): return self.channel.send_ready() - def write(self, data): - super(StdinSSHChannelFile, self).write(data) - return len(data) - class StdoutSSHChannelFile(SSHChannelFile): diff --git a/tobiko/shell/sh/_io.py b/tobiko/shell/sh/_io.py index 91ee3a1da..8d83bbf9c 100644 --- a/tobiko/shell/sh/_io.py +++ b/tobiko/shell/sh/_io.py @@ -109,9 +109,11 @@ class ShellWritable(ShellIOBase): def writable(self): return True - def write(self, chunk): - witten_bytes = self.delegate.write(chunk) - self._data_chunks.append(chunk) + def write(self, data): + witten_bytes = self.delegate.write(data) + if witten_bytes is None: + witten_bytes = len(data) + self._data_chunks.append(data) return witten_bytes @property diff --git a/tobiko/tests/functional/openstack/__init__.py b/tobiko/tests/functional/openstack/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tobiko/tests/functional/openstack/test_stacks.py b/tobiko/tests/functional/openstack/test_stacks.py new file mode 100644 index 000000000..e303a6044 --- /dev/null +++ b/tobiko/tests/functional/openstack/test_stacks.py @@ -0,0 +1,38 @@ +# 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 + + +class FloatingIPTest(testtools.TestCase): + """Tests connectivity to Nova instances via floating IPs""" + + floating_ip_stack = tobiko.required_setup_fixture( + stacks.FloatingIpServerStackFixture) + + @property + def floating_ip_address(self): + """Floating IP address""" + return self.floating_ip_stack.outputs.floating_ip_address + + def test_ping(self): + """Test connectivity to floating IP address""" + ping.ping_until_received(self.floating_ip_address).assert_replied() diff --git a/tobiko/tests/functional/shell/test_sh.py b/tobiko/tests/functional/shell/test_sh.py index 64ff8dcb2..9f4d60f87 100644 --- a/tobiko/tests/functional/shell/test_sh.py +++ b/tobiko/tests/functional/shell/test_sh.py @@ -158,7 +158,7 @@ class LocalExecuteTest(ExecuteTest): class SSHExecuteTest(ExecuteTest): server_stack = tobiko.required_setup_fixture( - stacks.NeutronServerStackFixture) + stacks.FloatingIpServerStackFixture) @property def ssh_client(self): @@ -172,7 +172,7 @@ class SSHExecuteTest(ExecuteTest): class ExecuteWithSSHCommandTest(ExecuteTest): server_stack = tobiko.required_setup_fixture( - stacks.NeutronServerStackFixture) + stacks.FloatingIpServerStackFixture) @property def shell(self): diff --git a/tobiko/tests/scenario/neutron/test_floating_ip.py b/tobiko/tests/scenario/neutron/test_floating_ip.py index d7b2d1b86..405114dd6 100644 --- a/tobiko/tests/scenario/neutron/test_floating_ip.py +++ b/tobiko/tests/scenario/neutron/test_floating_ip.py @@ -65,7 +65,7 @@ class FloatingIPFixture(heat.HeatStackFixture): # --- class parameters --- #: Whenever port security on internal network is enable key_pair_stack = tobiko.required_setup_fixture( - stacks.NovaKeyPairStackFixture) + stacks.KeyPairStackFixture) port_security_enabled = False #: Security groups to be associated to network ports