diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample index 70c791b2e5..4a567e73f5 100644 --- a/etc/tempest.conf.sample +++ b/etc/tempest.conf.sample @@ -250,6 +250,19 @@ # Should the tests ssh to instances? (boolean value) #run_ssh=false +# Auth method used for authenticate to the instance. Valid +# choices are: keypair, configured, adminpass. keypair: start +# the servers with an ssh keypair. configured: use the +# configured user and password. adminpass: use the injected +# adminPass. disabled: avoid using ssh when it is an option. +# (string value) +#ssh_auth_method=keypair + +# How to connect to the instance? fixed: using the first ip +# belongs the fixed network floating: creating and using a +# floating ip (string value) +#ssh_connect_method=fixed + # User name used to authenticate to an instance. (string # value) #ssh_user=root diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py index d1bda833a4..7a3798cdac 100644 --- a/tempest/api/compute/base.py +++ b/tempest/api/compute/base.py @@ -203,6 +203,13 @@ class BaseComputeTest(tempest.test.BaseTestCase): LOG.warn("Unable to delete volume '%s' since it was not found. " "Maybe it was already deleted?" % volume_id) + @classmethod + def prepare_instance_network(cls): + if (CONF.compute.ssh_auth_method != 'disabled' and + CONF.compute.ssh_connect_method == 'floating'): + cls.set_network_resources(network=True, subnet=True, router=True, + dhcp=True) + class BaseV2ComputeTest(BaseComputeTest): diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py index f0a8c8d192..9d6a1c1749 100644 --- a/tempest/api/compute/servers/test_create_server.py +++ b/tempest/api/compute/servers/test_create_server.py @@ -32,6 +32,7 @@ class ServersTestJSON(base.BaseV2ComputeTest): @classmethod def setUpClass(cls): + cls.prepare_instance_network() super(ServersTestJSON, cls).setUpClass() cls.meta = {'hello': 'world'} cls.accessIPv4 = '1.1.1.1' @@ -114,6 +115,7 @@ class ServersWithSpecificFlavorTestJSON(base.BaseV2ComputeAdminTest): @classmethod def setUpClass(cls): + cls.prepare_instance_network() super(ServersWithSpecificFlavorTestJSON, cls).setUpClass() cls.meta = {'hello': 'world'} cls.accessIPv4 = '1.1.1.1' diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py index cc2d1ee507..1f2bca9d1d 100644 --- a/tempest/api/compute/servers/test_server_actions.py +++ b/tempest/api/compute/servers/test_server_actions.py @@ -44,6 +44,7 @@ class ServerActionsTestJSON(base.BaseV2ComputeTest): @classmethod def setUpClass(cls): + cls.prepare_instance_network() super(ServerActionsTestJSON, cls).setUpClass() cls.client = cls.servers_client cls.server_id = cls.rebuild_server(None) diff --git a/tempest/api/compute/v3/servers/test_attach_volume.py b/tempest/api/compute/v3/servers/test_attach_volume.py index 28d8517899..e994c7f2e9 100644 --- a/tempest/api/compute/v3/servers/test_attach_volume.py +++ b/tempest/api/compute/v3/servers/test_attach_volume.py @@ -33,6 +33,7 @@ class AttachVolumeV3Test(base.BaseV3ComputeTest): @classmethod def setUpClass(cls): + cls.prepare_instance_network() super(AttachVolumeV3Test, cls).setUpClass() cls.device = CONF.compute.volume_device_name if not CONF.service_available.cinder: diff --git a/tempest/api/compute/v3/servers/test_create_server.py b/tempest/api/compute/v3/servers/test_create_server.py index 80c40a264f..68b4b9df6d 100644 --- a/tempest/api/compute/v3/servers/test_create_server.py +++ b/tempest/api/compute/v3/servers/test_create_server.py @@ -32,6 +32,7 @@ class ServersV3Test(base.BaseV3ComputeTest): @classmethod def setUpClass(cls): + cls.prepare_instance_network() super(ServersV3Test, cls).setUpClass() cls.meta = {'hello': 'world'} cls.accessIPv4 = '1.1.1.1' @@ -115,6 +116,7 @@ class ServersWithSpecificFlavorV3Test(base.BaseV3ComputeAdminTest): @classmethod def setUpClass(cls): + cls.prepare_instance_network() super(ServersWithSpecificFlavorV3Test, cls).setUpClass() cls.meta = {'hello': 'world'} cls.accessIPv4 = '1.1.1.1' diff --git a/tempest/api/compute/v3/servers/test_server_actions.py b/tempest/api/compute/v3/servers/test_server_actions.py index c377c305f3..b6764a5689 100644 --- a/tempest/api/compute/v3/servers/test_server_actions.py +++ b/tempest/api/compute/v3/servers/test_server_actions.py @@ -41,6 +41,7 @@ class ServerActionsV3Test(base.BaseV3ComputeTest): @classmethod def setUpClass(cls): + cls.prepare_instance_network() super(ServerActionsV3Test, cls).setUpClass() cls.client = cls.servers_client cls.server_id = cls.rebuild_server(None) diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py index ab9d144ffd..458591293b 100644 --- a/tempest/api/compute/volumes/test_attach_volume.py +++ b/tempest/api/compute/volumes/test_attach_volume.py @@ -33,6 +33,7 @@ class AttachVolumeTestJSON(base.BaseV2ComputeTest): @classmethod def setUpClass(cls): + cls.prepare_instance_network() super(AttachVolumeTestJSON, cls).setUpClass() cls.device = CONF.compute.volume_device_name if not CONF.service_available.cinder: diff --git a/tempest/config.py b/tempest/config.py index b9fe5728bb..708476867d 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -159,6 +159,19 @@ ComputeGroup = [ cfg.BoolOpt('run_ssh', default=False, help="Should the tests ssh to instances?"), + cfg.StrOpt('ssh_auth_method', + default='keypair', + help="Auth method used for authenticate to the instance. " + "Valid choices are: keypair, configured, adminpass. " + "keypair: start the servers with an ssh keypair. " + "configured: use the configured user and password. " + "adminpass: use the injected adminPass. " + "disabled: avoid using ssh when it is an option."), + cfg.StrOpt('ssh_connect_method', + default='fixed', + help="How to connect to the instance? " + "fixed: using the first ip belongs the fixed network " + "floating: creating and using a floating ip"), cfg.StrOpt('ssh_user', default='root', help="User name used to authenticate to an instance."),