From 7fc44d5c4e45756ec66fd347e3e0bec06bf54a7d Mon Sep 17 00:00:00 2001 From: Andrey Pavlov Date: Thu, 29 Oct 2015 12:24:29 +0300 Subject: [PATCH] functional tests: add 'run_ssh' parameter to config and switch it off for nova-network. because nova-network is very unstable in this. Change-Id: I4e1e3c642ec77a9cfa4b1249da0a980336698a08 --- config.py | 3 +++ scenario/base.py | 13 ------------- scenario/test_instance_restart.py | 2 ++ scenario/test_instances.py | 3 +++ scenario/test_instances_in_vpc.py | 3 +++ scenario/test_vpn.py | 1 + 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/config.py b/config.py index ba23a84..29665c2 100644 --- a/config.py +++ b/config.py @@ -87,6 +87,9 @@ AWSGroup = [ cfg.StrOpt('ami_image_location', default=None, help="S3 URL with manifest of AMI Machine Image."), + cfg.BoolOpt('run_ssh', + default=True, + help='Can block all tests that wants to ssh into instance.'), ] diff --git a/scenario/base.py b/scenario/base.py index 095cd79..10d6783 100644 --- a/scenario/base.py +++ b/scenario/base.py @@ -17,7 +17,6 @@ import time from oslo_log import log from tempest_lib.common.utils import data_utils -from tempest_lib import exceptions from ec2api.tests.functional import base from ec2api.tests.functional import config @@ -130,15 +129,3 @@ class BaseScenarioTest(base.EC2TestCase): self.get_network_interface_waiter().wait_available(ni_id) return ni_id - - def correct_ns_if_needed(self, ssh_client): - try: - ssh_client.exec_command("host www.com") - except exceptions.SSHExecCommandFailed: - LOG.exception('Can`t resolve www.com. Fixing resolv.conf') - LOG.warning(ssh_client.exec_command("cat /etc/resolv.conf")) - LOG.warning(ssh_client.exec_command("ping -c 1 8.8.8.8 1>&2")) - # NOTE(apavlov) update nameservers (mandatory for local devstack) - ssh_client.exec_command("sudo su -c 'echo nameserver 8.8.8.8 " - "> /etc/resolv.conf'") - ssh_client.exec_command("host www.com") diff --git a/scenario/test_instance_restart.py b/scenario/test_instance_restart.py index 613639a..e40e3f3 100644 --- a/scenario/test_instance_restart.py +++ b/scenario/test_instance_restart.py @@ -28,6 +28,7 @@ LOG = log.getLogger(__name__) class InstanceRestartTest(scenario_base.BaseScenarioTest): + @testtools.skipUnless(CONF.aws.run_ssh, 'SSH tests are disabled.') @testtools.skipUnless(CONF.aws.run_long_tests, 'Slow test has skipped.') @testtools.skipUnless(CONF.aws.image_id_ubuntu, "ubuntu image id is not defined") @@ -59,6 +60,7 @@ class InstanceRestartTest(scenario_base.BaseScenarioTest): data = ssh_client.exec_command('last -x') self.assertIn("shutdown", data) + @testtools.skipUnless(CONF.aws.run_ssh, 'SSH tests are disabled.') @testtools.skipUnless(CONF.aws.run_long_tests, 'Slow test has skipped.') @testtools.skipUnless(CONF.aws.image_id_ubuntu, "ubuntu image id is not defined") diff --git a/scenario/test_instances.py b/scenario/test_instances.py index ebe491f..fe69570 100644 --- a/scenario/test_instances.py +++ b/scenario/test_instances.py @@ -71,6 +71,7 @@ PUBLIC_KEY_MATERIAL = ( class InstancesTest(scenario_base.BaseScenarioTest): + @testtools.skipUnless(CONF.aws.run_ssh, 'SSH tests are disabled.') @testtools.skipUnless(CONF.aws.image_id, "image id is not defined") def test_metadata(self): key_name = data_utils.rand_name('testkey') @@ -107,6 +108,7 @@ class InstancesTest(scenario_base.BaseScenarioTest): 'curl %s/latest/meta-data/public-keys/0/openssh-key' % url) self.assertEqual(PUBLIC_KEY_MATERIAL, data) + @testtools.skipUnless(CONF.aws.run_ssh, 'SSH tests are disabled.') @testtools.skipUnless(CONF.aws.image_id, "image id is not defined") def test_compare_console_output(self): key_name = data_utils.rand_name('testkey') @@ -134,6 +136,7 @@ class InstancesTest(scenario_base.BaseScenarioTest): waiter = base.EC2Waiter(_compare_console_output) waiter.wait_no_exception() + @testtools.skipUnless(CONF.aws.run_ssh, 'SSH tests are disabled.') @testtools.skipUnless(CONF.aws.ami_image_location, "Image is absent in S3") def test_run_and_ping_registered_image(self): image_name = data_utils.rand_name("ami-name") diff --git a/scenario/test_instances_in_vpc.py b/scenario/test_instances_in_vpc.py index 4d9ee64..7853234 100644 --- a/scenario/test_instances_in_vpc.py +++ b/scenario/test_instances_in_vpc.py @@ -59,16 +59,19 @@ class InstancesInVPCTest(scenario_base.BaseScenarioTest): waiter.wait_no_exception('ping %s -c 1' % last_ip) @base.skip_without_vpc() + @testtools.skipUnless(CONF.aws.run_ssh, 'SSH tests are disabled.') @testtools.skipUnless(CONF.aws.image_id, "image id is not defined") def test_instances_in_min_subnet(self): self._test_instances(28) @base.skip_without_vpc() + @testtools.skipUnless(CONF.aws.run_ssh, 'SSH tests are disabled.') @testtools.skipUnless(CONF.aws.image_id, "image id is not defined") def test_instances_in_max_subnet(self): self._test_instances(16) @base.skip_without_vpc() + @testtools.skipUnless(CONF.aws.run_ssh, 'SSH tests are disabled.') @testtools.skipUnless(CONF.aws.image_id, "image id is not defined") def test_default_gateway(self): novpc_group = self.create_standard_security_group() diff --git a/scenario/test_vpn.py b/scenario/test_vpn.py index 5f81db8..ed205e0 100644 --- a/scenario/test_vpn.py +++ b/scenario/test_vpn.py @@ -65,6 +65,7 @@ class VpnTest(scenario_base.BaseScenarioTest): self.assertEqual('active', route['State']) self.assertEqual('EnableVgwRoutePropagation', route['Origin']) + @testtools.skipUnless(CONF.aws.run_ssh, 'SSH tests are disabled.') @testtools.skipUnless(CONF.aws.run_long_tests, 'Slow test has skipped.') @testtools.skipUnless(CONF.aws.image_id_ubuntu, "ubuntu image id is not defined")