Add logging of servers console in scenario test_port_forwardings
In case when ssh to one of servers in test test_port_forwardings
will fail it is useful to have consile log from servers used in
test.
This patch adds logging of such console output in this test.
Change-Id: I597d2c13544d668f88d78016ff4545e164e97a3e
diff --git a/neutron_tempest_plugin/scenario/test_port_forwardings.py b/neutron_tempest_plugin/scenario/test_port_forwardings.py
index e366d8f..1d1fe94 100644
--- a/neutron_tempest_plugin/scenario/test_port_forwardings.py
+++ b/neutron_tempest_plugin/scenario/test_port_forwardings.py
@@ -13,8 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_log import log
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
+from tempest.lib import exceptions as lib_exc
from neutron_tempest_plugin.common import ssh
from neutron_tempest_plugin import config
@@ -22,6 +24,8 @@
CONF = config.CONF
+LOG = log.getLogger(__name__)
+
class PortForwardingTestJSON(base.BaseTempestTestCase):
@@ -66,10 +70,19 @@
protocol="tcp")
servers.append(server)
- for server in servers:
- ssh_client = ssh.Client(
- self.fip['floating_ip_address'],
- CONF.validation.image_ssh_user,
- pkey=self.keypair['private_key'],
- port=server['port_forwarding']['external_port'])
- self.assertIn(server['name'], ssh_client.exec_command('hostname'))
+ try:
+ for server in servers:
+ ssh_client = ssh.Client(
+ self.fip['floating_ip_address'],
+ CONF.validation.image_ssh_user,
+ pkey=self.keypair['private_key'],
+ port=server['port_forwarding']['external_port'])
+ self.assertIn(server['name'],
+ ssh_client.exec_command('hostname'))
+ except lib_exc.SSHTimeout as ssh_e:
+ LOG.debug(ssh_e)
+ self._log_console_output(servers)
+ raise
+ except AssertionError:
+ self._log_console_output(servers)
+ raise