Add tests for VMs booted from raw image type
Smoke:
- ServerActionsRawImageTestJSON.test_reboot_server_hard
- test_server_basic_ops_2_image_raw_ref
Full:
- ServerActionsRawImageTestJSON.test_stop_start_server
- ServerActionsRawImageTestJSON.test_shelve_unshelve_server
- test_shelve_instance_2_image_raw_ref
- test_cold_migration_2_image_raw_ref
- test_revert_cold_migration_2_image_raw_ref
- LiveMigrationTest.test_live_block_migration_2_image_raw_ref
- LiveAutoBlockMigrationV225Test.test_live_block_migration_2_image_raw_ref
Related-Prod: PRODX-40251
Change-Id: I2c5edbe5409f53dd969da702c705a7c74b50a315
diff --git a/requirements.txt b/requirements.txt
index 83410e2..abe25b5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,6 +3,7 @@
# process, which may cause wedges in the gate later.
pbr!=2.1.0,>=2.0.0 # Apache-2.0
cliff!=2.9.0,>=2.8.0 # Apache-2.0
+ddt>=1.6.0 # MIT
jsonschema>=3.2.0 # MIT
testtools>=2.2.0 # MIT
paramiko>=2.7.0 # LGPLv2.1+
diff --git a/tempest/api/compute/admin/test_live_migration.py b/tempest/api/compute/admin/test_live_migration.py
index 9db0b3d..cae9c06 100644
--- a/tempest/api/compute/admin/test_live_migration.py
+++ b/tempest/api/compute/admin/test_live_migration.py
@@ -15,6 +15,8 @@
import time
+import ddt
+
from oslo_log import log as logging
import testtools
@@ -95,6 +97,7 @@
msg)
+@ddt.ddt
class LiveMigrationTest(LiveMigrationTestBase):
max_microversion = '2.24'
block_migration = None
@@ -104,7 +107,8 @@
cls.prepare_instance_network()
super(LiveMigrationTest, cls).setup_credentials()
- def _test_live_migration(self, state='ACTIVE', volume_backed=False):
+ def _test_live_migration(
+ self, state='ACTIVE', volume_backed=False, image_id=None):
"""Tests live migration between two hosts.
Requires CONF.compute_feature_enabled.live_migration to be True.
@@ -117,7 +121,8 @@
"""
# Live migrate an instance to another host
server_id = self.create_test_server(wait_until="ACTIVE",
- volume_backed=volume_backed)['id']
+ volume_backed=volume_backed,
+ image_id=image_id)['id']
source_host = self.get_host_for_server(server_id)
if not CONF.compute_feature_enabled.can_migrate_between_any_hosts:
# not to specify a host so that the scheduler will pick one
@@ -145,9 +150,11 @@
@testtools.skipUnless(CONF.compute_feature_enabled.
block_migration_for_live_migration,
'Block Live migration not available')
- def test_live_block_migration(self):
+ @ddt.data('image_ref', 'image_raw_ref')
+ def test_live_block_migration(self, image):
"""Test live migrating an active server"""
- self._test_live_migration()
+ image_id = getattr(CONF.compute, image)
+ self._test_live_migration(image_id=image_id)
@decorators.attr(type='multinode')
@decorators.idempotent_id('1e107f21-61b2-4988-8f22-b196e938ab88')
diff --git a/tempest/api/compute/admin/test_migrations.py b/tempest/api/compute/admin/test_migrations.py
index 91b15fb..551ea9d 100644
--- a/tempest/api/compute/admin/test_migrations.py
+++ b/tempest/api/compute/admin/test_migrations.py
@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import ddt
import testtools
from tempest.api.compute import base
@@ -24,6 +25,7 @@
CONF = config.CONF
+@ddt.ddt
class MigrationsAdminTest(base.BaseV2ComputeAdminTest):
"""Test migration operations supported by admin user"""
@@ -135,12 +137,13 @@
'flavor!' % key)
self.assertEqual(pre_flavor[key], server['flavor'][key], msg)
- def _test_cold_migrate_server(self, revert=False):
+ def _test_cold_migrate_server(self, revert=False, image_id=None):
if CONF.compute.min_compute_nodes < 2:
msg = "Less than 2 compute nodes, skipping multinode tests."
raise self.skipException(msg)
- server = self.create_test_server(wait_until="ACTIVE")
+ server = self.create_test_server(image_id=image_id,
+ wait_until="ACTIVE")
src_host = self.get_host_for_server(server['id'])
self.admin_servers_client.migrate_server(server['id'])
@@ -164,14 +167,18 @@
@decorators.idempotent_id('4bf0be52-3b6f-4746-9a27-3143636fe30d')
@testtools.skipUnless(CONF.compute_feature_enabled.cold_migration,
'Cold migration not available.')
- def test_cold_migration(self):
+ @ddt.data('image_ref', 'image_raw_ref')
+ def test_cold_migration(self, image):
"""Test cold migrating server and then confirm the migration"""
- self._test_cold_migrate_server(revert=False)
+ image_id = getattr(CONF.compute, image)
+ self._test_cold_migrate_server(revert=False, image_id=image_id)
@decorators.attr(type='multinode')
@decorators.idempotent_id('caa1aa8b-f4ef-4374-be0d-95f001c2ac2d')
@testtools.skipUnless(CONF.compute_feature_enabled.cold_migration,
'Cold migration not available.')
- def test_revert_cold_migration(self):
+ @ddt.data('image_ref', 'image_raw_ref')
+ def test_revert_cold_migration(self, image):
"""Test cold migrating server and then revert the migration"""
- self._test_cold_migrate_server(revert=True)
+ image_id = getattr(CONF.compute, image)
+ self._test_cold_migrate_server(revert=True, image_id=image_id)
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 5678a3f..f87e353 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -34,14 +34,14 @@
LOG = logging.getLogger(__name__)
-class ServerActionsTestJSON(base.BaseV2ComputeTest):
- """Test server actions"""
+class ServerActionsBaseTestJSON(base.BaseV2ComputeTest):
+ image_id = None
if CONF.compute_feature_enabled.volume_multiattach:
min_microversion = '2.60'
def setUp(self):
- super(ServerActionsTestJSON, self).setUp()
+ super(ServerActionsBaseTestJSON, self).setUp()
# Instead of reusing an instance which had been created before a new
# instance is created in favour of increasing stability of tests.
self.validation_resources = self.get_test_validation_resources(
@@ -49,46 +49,21 @@
server = self.create_test_server(
validatable=True,
validation_resources=self.validation_resources,
- wait_until='SSHABLE')
+ wait_until='SSHABLE',
+ image_id=self.image_id)
self.server_id = server['id']
self.addCleanup(self.delete_server, self.server_id)
@classmethod
def setup_credentials(cls):
cls.prepare_instance_network()
- super(ServerActionsTestJSON, cls).setup_credentials()
+ super(ServerActionsBaseTestJSON, cls).setup_credentials()
@classmethod
def setup_clients(cls):
- super(ServerActionsTestJSON, cls).setup_clients()
+ super(ServerActionsBaseTestJSON, cls).setup_clients()
cls.client = cls.servers_client
- @decorators.idempotent_id('6158df09-4b82-4ab3-af6d-29cf36af858d')
- @testtools.skipUnless(CONF.compute_feature_enabled.change_password,
- 'Change password not available.')
- def test_change_server_password(self):
- """Test changing server's password
-
- The server's password should be set to the provided password and
- the user can authenticate with the new password.
- """
- newserver = self.client.show_server(self.server_id)['server']
- # The server's password should be set to the provided password
- new_password = 'Newpass1234'
- self.client.change_password(newserver['id'], adminPass=new_password)
- waiters.wait_for_server_status(self.client, newserver['id'], 'ACTIVE')
-
- if CONF.validation.run_validation:
- # Verify that the user can authenticate with the new password
- server = self.client.show_server(newserver['id'])['server']
- linux_client = remote_client.RemoteClient(
- self.get_server_ip(server, self.validation_resources),
- self.ssh_user,
- new_password,
- server=server,
- servers_client=self.client)
- linux_client.validate_authentication()
-
def _test_reboot_server(self, reboot_type):
if CONF.validation.run_validation:
# Get the time the server was last rebooted,
@@ -121,28 +96,6 @@
self.assertGreater(new_boot_time, boot_time,
'%s > %s' % (new_boot_time, boot_time))
- @decorators.attr(type='smoke')
- @decorators.idempotent_id('2cb1baf6-ac8d-4429-bf0d-ba8a0ba53e32')
- def test_reboot_server_hard(self):
- """Test hard rebooting server
-
- The server should be power cycled.
- """
- self._test_reboot_server('HARD')
-
- @decorators.idempotent_id('1d1c9104-1b0a-11e7-a3d4-fa163e65f5ce')
- def test_remove_server_all_security_groups(self):
- """Test removing all security groups from server"""
- server = self.client.show_server(self.server_id)['server']
-
- # Remove all Security group
- self.client.remove_security_group(
- server['id'], name=server['security_groups'][0]['name'])
-
- # Verify all Security group
- server = self.client.show_server(server['id'])['server']
- self.assertNotIn('security_groups', server)
-
def _rebuild_server_and_check(self, image_ref, server):
rebuilt_server = (self.client.rebuild_server(server['id'], image_ref)
['server'])
@@ -222,87 +175,6 @@
servers_client=self.client)
linux_client.validate_authentication()
- @decorators.idempotent_id('aaa6cdf3-55a7-461a-add9-1c8596b9a07c')
- def test_rebuild_server(self):
- """Test rebuilding server
-
- The server should be rebuilt using the provided image and data.
- """
- self._test_rebuild_server()
-
- @decorators.idempotent_id('30449a88-5aff-4f9b-9866-6ee9b17f906d')
- def test_rebuild_server_in_stop_state(self):
- """Test rebuilding server in stop state
-
- The server in stop state should be rebuilt using the provided
- image and remain in SHUTOFF state.
- """
- server = self.client.show_server(self.server_id)['server']
- old_image = server['image']['id']
- new_image = (self.image_ref_alt
- if old_image == self.image_ref else self.image_ref)
- self.client.stop_server(self.server_id)
- waiters.wait_for_server_status(self.client, self.server_id, 'SHUTOFF')
- rebuilt_server = (self.client.rebuild_server(self.server_id, new_image)
- ['server'])
- # If the server was rebuilt on a different image, restore it to the
- # original image once the test ends
- if self.image_ref_alt != self.image_ref:
- self.addCleanup(self._rebuild_server_and_check, old_image, server)
-
- # Verify the properties in the initial response are correct
- self.assertEqual(self.server_id, rebuilt_server['id'])
- rebuilt_image_id = rebuilt_server['image']['id']
- self.assertEqual(new_image, rebuilt_image_id)
- self.assert_flavor_equal(self.flavor_ref, rebuilt_server['flavor'])
-
- # Verify the server properties after the rebuild completes
- waiters.wait_for_server_status(self.client,
- rebuilt_server['id'], 'SHUTOFF')
- server = self.client.show_server(rebuilt_server['id'])['server']
- rebuilt_image_id = server['image']['id']
- self.assertEqual(new_image, rebuilt_image_id)
-
- self.client.start_server(self.server_id)
- waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
-
- # NOTE(mriedem): Marked as slow because while rebuild and volume-backed is
- # common, we don't actually change the image (you can't with volume-backed
- # rebuild) so this isn't testing much outside normal rebuild
- # (and it's slow).
- @decorators.attr(type='slow')
- @decorators.idempotent_id('b68bd8d6-855d-4212-b59b-2e704044dace')
- @utils.services('volume')
- def test_rebuild_server_with_volume_attached(self):
- """Test rebuilding server with volume attached
-
- The volume should be attached to the instance after rebuild.
- """
- # create a new volume and attach it to the server
- volume = self.create_volume()
-
- server = self.client.show_server(self.server_id)['server']
- self.attach_volume(server, volume)
-
- # run general rebuild test
- self._test_rebuild_server()
-
- # make sure the volume is attached to the instance after rebuild
- vol_after_rebuild = self.volumes_client.show_volume(volume['id'])
- vol_after_rebuild = vol_after_rebuild['volume']
- self.assertEqual('in-use', vol_after_rebuild['status'])
- self.assertEqual(self.server_id,
- vol_after_rebuild['attachments'][0]['server_id'])
- if CONF.validation.run_validation:
- linux_client = remote_client.RemoteClient(
- self.get_server_ip(server, self.validation_resources),
- self.ssh_alt_user,
- password=None,
- pkey=self.validation_resources['keypair']['private_key'],
- server=server,
- servers_client=self.client)
- linux_client.validate_authentication()
-
def _test_resize_server_confirm(self, server_id, stop=False):
# The server's RAM and disk space should be modified to that of
# the provided flavor
@@ -331,6 +203,63 @@
# NOTE(mriedem): tearDown requires the server to be started.
self.client.start_server(server_id)
+ def _get_output(self):
+ output = self.client.get_console_output(
+ self.server_id, length=3)['output']
+ self.assertTrue(output, "Console output was empty.")
+ lines = len(output.split('\n'))
+ self.assertEqual(lines, 3)
+
+ def _validate_url(self, url):
+ valid_scheme = ['http', 'https']
+ parsed_url = urlparse.urlparse(url)
+ self.assertNotEqual('None', parsed_url.port)
+ self.assertNotEqual('None', parsed_url.hostname)
+ self.assertIn(parsed_url.scheme, valid_scheme)
+
+
+class ServerActionsTestJSON(ServerActionsBaseTestJSON):
+ """Test server actions"""
+
+ @decorators.idempotent_id('6158df09-4b82-4ab3-af6d-29cf36af858d')
+ @testtools.skipUnless(CONF.compute_feature_enabled.change_password,
+ 'Change password not available.')
+ def test_change_server_password(self):
+ """Test changing server's password
+
+ The server's password should be set to the provided password and
+ the user can authenticate with the new password.
+ """
+ newserver = self.client.show_server(self.server_id)['server']
+ # The server's password should be set to the provided password
+ new_password = 'Newpass1234'
+ self.client.change_password(newserver['id'], adminPass=new_password)
+ waiters.wait_for_server_status(self.client, newserver['id'], 'ACTIVE')
+
+ if CONF.validation.run_validation:
+ # Verify that the user can authenticate with the new password
+ server = self.client.show_server(newserver['id'])['server']
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server, self.validation_resources),
+ self.ssh_user,
+ new_password,
+ server=server,
+ servers_client=self.client)
+ linux_client.validate_authentication()
+
+ @decorators.idempotent_id('1d1c9104-1b0a-11e7-a3d4-fa163e65f5ce')
+ def test_remove_server_all_security_groups(self):
+ """Test removing all security groups from server"""
+ server = self.client.show_server(self.server_id)['server']
+
+ # Remove all Security group
+ self.client.remove_security_group(
+ server['id'], name=server['security_groups'][0]['name'])
+
+ # Verify all Security group
+ server = self.client.show_server(server['id'])['server']
+ self.assertNotIn('security_groups', server)
+
@decorators.idempotent_id('1499262a-9328-4eda-9068-db1ac57498d2')
@testtools.skipIf(not (CONF.compute_feature_enabled.cold_migration and
CONF.compute_feature_enabled.resize),
@@ -573,13 +502,6 @@
self.assertEqual((backup2, backup3),
(image_list[0]['name'], image_list[1]['name']))
- def _get_output(self):
- output = self.client.get_console_output(
- self.server_id, length=3)['output']
- self.assertTrue(output, "Console output was empty.")
- lines = len(output.split('\n'))
- self.assertEqual(lines, 3)
-
@decorators.idempotent_id('4b8867e6-fffa-4d54-b1d1-6fdda57be2f3')
@testtools.skipUnless(CONF.compute_feature_enabled.console_output,
'Console output not supported.')
@@ -635,6 +557,87 @@
waiters.wait_for_server_status(self.client, self.server_id, 'SHUTOFF')
self.wait_for(self._get_output)
+ @decorators.idempotent_id('aaa6cdf3-55a7-461a-add9-1c8596b9a07c')
+ def test_rebuild_server(self):
+ """Test rebuilding server
+
+ The server should be rebuilt using the provided image and data.
+ """
+ self._test_rebuild_server()
+
+ @decorators.idempotent_id('30449a88-5aff-4f9b-9866-6ee9b17f906d')
+ def test_rebuild_server_in_stop_state(self):
+ """Test rebuilding server in stop state
+
+ The server in stop state should be rebuilt using the provided
+ image and remain in SHUTOFF state.
+ """
+ server = self.client.show_server(self.server_id)['server']
+ old_image = server['image']['id']
+ new_image = (self.image_ref_alt
+ if old_image == self.image_ref else self.image_ref)
+ self.client.stop_server(self.server_id)
+ waiters.wait_for_server_status(self.client, self.server_id, 'SHUTOFF')
+ rebuilt_server = (self.client.rebuild_server(self.server_id, new_image)
+ ['server'])
+ # If the server was rebuilt on a different image, restore it to the
+ # original image once the test ends
+ if self.image_ref_alt != self.image_ref:
+ self.addCleanup(self._rebuild_server_and_check, old_image, server)
+
+ # Verify the properties in the initial response are correct
+ self.assertEqual(self.server_id, rebuilt_server['id'])
+ rebuilt_image_id = rebuilt_server['image']['id']
+ self.assertEqual(new_image, rebuilt_image_id)
+ self.assert_flavor_equal(self.flavor_ref, rebuilt_server['flavor'])
+
+ # Verify the server properties after the rebuild completes
+ waiters.wait_for_server_status(self.client,
+ rebuilt_server['id'], 'SHUTOFF')
+ server = self.client.show_server(rebuilt_server['id'])['server']
+ rebuilt_image_id = server['image']['id']
+ self.assertEqual(new_image, rebuilt_image_id)
+
+ self.client.start_server(self.server_id)
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
+
+ # NOTE(mriedem): Marked as slow because while rebuild and volume-backed is
+ # common, we don't actually change the image (you can't with volume-backed
+ # rebuild) so this isn't testing much outside normal rebuild
+ # (and it's slow).
+ @decorators.attr(type='slow')
+ @decorators.idempotent_id('b68bd8d6-855d-4212-b59b-2e704044dace')
+ @utils.services('volume')
+ def test_rebuild_server_with_volume_attached(self):
+ """Test rebuilding server with volume attached
+
+ The volume should be attached to the instance after rebuild.
+ """
+ # create a new volume and attach it to the server
+ volume = self.create_volume()
+
+ server = self.client.show_server(self.server_id)['server']
+ self.attach_volume(server, volume)
+
+ # run general rebuild test
+ self._test_rebuild_server()
+
+ # make sure the volume is attached to the instance after rebuild
+ vol_after_rebuild = self.volumes_client.show_volume(volume['id'])
+ vol_after_rebuild = vol_after_rebuild['volume']
+ self.assertEqual('in-use', vol_after_rebuild['status'])
+ self.assertEqual(self.server_id,
+ vol_after_rebuild['attachments'][0]['server_id'])
+ if CONF.validation.run_validation:
+ linux_client = remote_client.RemoteClient(
+ self.get_server_ip(server, self.validation_resources),
+ self.ssh_alt_user,
+ password=None,
+ pkey=self.validation_resources['keypair']['private_key'],
+ server=server,
+ servers_client=self.client)
+ linux_client.validate_authentication()
+
@decorators.idempotent_id('bd61a9fd-062f-4670-972b-2d6c3e3b9e73')
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
'Pause is not available.')
@@ -656,6 +659,73 @@
self.client.resume_server(self.server_id)
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
+ @decorators.idempotent_id('8cf9f450-a871-42cf-9bef-77eba189c0b0')
+ @decorators.related_bug('1745529')
+ @testtools.skipUnless(CONF.compute_feature_enabled.shelve,
+ 'Shelve is not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.pause,
+ 'Pause is not available.')
+ def test_shelve_paused_server(self):
+ """Test shelving a paused server"""
+ self.client.pause_server(self.server_id)
+ waiters.wait_for_server_status(self.client, self.server_id, 'PAUSED')
+ # Check if Shelve operation is successful on paused server.
+ compute.shelve_server(self.client, self.server_id,
+ force_shelve_offload=True)
+
+ @decorators.idempotent_id('80a8094c-211e-440a-ab88-9e59d556c7ee')
+ def test_lock_unlock_server(self):
+ """Test locking and unlocking server
+
+ Lock the server, and trying to stop it will fail because locked
+ server is not allowed to be stopped by non-admin user.
+ Then unlock the server, now the server can be stopped and started.
+ """
+ # Lock the server,try server stop(exceptions throw),unlock it and retry
+ self.client.lock_server(self.server_id)
+ self.addCleanup(self.client.unlock_server, self.server_id)
+ server = self.client.show_server(self.server_id)['server']
+ self.assertEqual(server['status'], 'ACTIVE')
+ # Locked server is not allowed to be stopped by non-admin user
+ self.assertRaises(lib_exc.Conflict,
+ self.client.stop_server, self.server_id)
+ self.client.unlock_server(self.server_id)
+ self.client.stop_server(self.server_id)
+ waiters.wait_for_server_status(self.client, self.server_id, 'SHUTOFF')
+ self.client.start_server(self.server_id)
+ waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
+
+ @decorators.idempotent_id('c6bc11bf-592e-4015-9319-1c98dc64daf5')
+ @testtools.skipUnless(CONF.compute_feature_enabled.vnc_console,
+ 'VNC Console feature is disabled.')
+ def test_get_vnc_console(self):
+ """Test getting vnc console from a server
+
+ The returned vnc console url should be in valid format.
+ """
+ if self.is_requested_microversion_compatible('2.5'):
+ body = self.client.get_vnc_console(
+ self.server_id, type='novnc')['console']
+ else:
+ body = self.client.get_remote_console(
+ self.server_id, console_type='novnc',
+ protocol='vnc')['remote_console']
+ self.assertEqual('novnc', body['type'])
+ self.assertNotEqual('', body['url'])
+ self._validate_url(body['url'])
+
+
+class ServerActionsBaseImageTestJSON(ServerActionsBaseTestJSON):
+
+ @decorators.attr(type='smoke')
+ @decorators.idempotent_id('2cb1baf6-ac8d-4429-bf0d-ba8a0ba53e32')
+ def test_reboot_server_hard(self):
+ """Test hard rebooting server
+
+ The server should be power cycled.
+ """
+ self._test_reboot_server('HARD')
+
@decorators.idempotent_id('77eba8e0-036e-4635-944b-f7a8f3b78dc9')
@testtools.skipUnless(CONF.compute_feature_enabled.shelve,
'Shelve is not available.')
@@ -694,20 +764,6 @@
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
glance_client.wait_for_resource_deletion(images[0]['id'])
- @decorators.idempotent_id('8cf9f450-a871-42cf-9bef-77eba189c0b0')
- @decorators.related_bug('1745529')
- @testtools.skipUnless(CONF.compute_feature_enabled.shelve,
- 'Shelve is not available.')
- @testtools.skipUnless(CONF.compute_feature_enabled.pause,
- 'Pause is not available.')
- def test_shelve_paused_server(self):
- """Test shelving a paused server"""
- self.client.pause_server(self.server_id)
- waiters.wait_for_server_status(self.client, self.server_id, 'PAUSED')
- # Check if Shelve operation is successful on paused server.
- compute.shelve_server(self.client, self.server_id,
- force_shelve_offload=True)
-
@decorators.idempotent_id('af8eafd4-38a7-4a4b-bdbc-75145a580560')
def test_stop_start_server(self):
"""Test stopping and starting server"""
@@ -716,53 +772,10 @@
self.client.start_server(self.server_id)
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- @decorators.idempotent_id('80a8094c-211e-440a-ab88-9e59d556c7ee')
- def test_lock_unlock_server(self):
- """Test locking and unlocking server
- Lock the server, and trying to stop it will fail because locked
- server is not allowed to be stopped by non-admin user.
- Then unlock the server, now the server can be stopped and started.
- """
- # Lock the server,try server stop(exceptions throw),unlock it and retry
- self.client.lock_server(self.server_id)
- self.addCleanup(self.client.unlock_server, self.server_id)
- server = self.client.show_server(self.server_id)['server']
- self.assertEqual(server['status'], 'ACTIVE')
- # Locked server is not allowed to be stopped by non-admin user
- self.assertRaises(lib_exc.Conflict,
- self.client.stop_server, self.server_id)
- self.client.unlock_server(self.server_id)
- self.client.stop_server(self.server_id)
- waiters.wait_for_server_status(self.client, self.server_id, 'SHUTOFF')
- self.client.start_server(self.server_id)
- waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
-
- def _validate_url(self, url):
- valid_scheme = ['http', 'https']
- parsed_url = urlparse.urlparse(url)
- self.assertNotEqual('None', parsed_url.port)
- self.assertNotEqual('None', parsed_url.hostname)
- self.assertIn(parsed_url.scheme, valid_scheme)
-
- @decorators.idempotent_id('c6bc11bf-592e-4015-9319-1c98dc64daf5')
- @testtools.skipUnless(CONF.compute_feature_enabled.vnc_console,
- 'VNC Console feature is disabled.')
- def test_get_vnc_console(self):
- """Test getting vnc console from a server
-
- The returned vnc console url should be in valid format.
- """
- if self.is_requested_microversion_compatible('2.5'):
- body = self.client.get_vnc_console(
- self.server_id, type='novnc')['console']
- else:
- body = self.client.get_remote_console(
- self.server_id, console_type='novnc',
- protocol='vnc')['remote_console']
- self.assertEqual('novnc', body['type'])
- self.assertNotEqual('', body['url'])
- self._validate_url(body['url'])
+class ServerActionsRawImageTestJSON(ServerActionsBaseImageTestJSON):
+ """Test server actions with raw image type"""
+ image_id = CONF.compute.image_raw_ref
class ServersAaction247Test(base.BaseV2ComputeTest):
diff --git a/tempest/config.py b/tempest/config.py
index 41d96c9..5bf6e52 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -307,6 +307,10 @@
help="This is image with full OS like ubuntu/centos used"
"in some tests. When not set related tests will be "
"skipped"),
+ cfg.StrOpt('image_raw_ref',
+ default=None,
+ help="Valid image reference in raw format to be used "
+ "in tests."),
cfg.StrOpt('image_full_username',
default="ubuntu",
help="Username for image_full_ref authentication."),
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index e1c8953..32dbd3c 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import ddt
+
from oslo_serialization import jsonutils as json
from tempest.common import utils
@@ -27,6 +29,7 @@
CONF = config.CONF
+@ddt.ddt
class TestServerBasicOps(manager.ScenarioTestWithNetwork):
"""The test suite for server basic operations
@@ -127,12 +130,15 @@
@decorators.idempotent_id('7fff3fb3-91d8-4fd0-bd7d-0204f1f180ba')
@decorators.attr(type='smoke')
+ @ddt.data('image_ref', 'image_raw_ref')
@utils.services('compute', 'network')
- def test_server_basic_ops(self):
+ def test_server_basic_ops(self, image):
keypair = self.create_keypair()
security_group = self.create_security_group()
self.md = {'meta1': 'data1', 'meta2': 'data2', 'metaN': 'dataN'}
+ image_id = getattr(CONF.compute, image)
self.instance = self.create_server(
+ image_id=image_id,
key_name=keypair['name'],
security_groups=[{'name': security_group['name']}],
config_drive=CONF.compute_feature_enabled.config_drive,
diff --git a/tempest/scenario/test_shelve_instance.py b/tempest/scenario/test_shelve_instance.py
index 204471e..4273a3a 100644
--- a/tempest/scenario/test_shelve_instance.py
+++ b/tempest/scenario/test_shelve_instance.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import ddt
import testtools
from tempest.common import compute
@@ -25,6 +26,7 @@
CONF = config.CONF
+@ddt.ddt
class TestShelveInstance(manager.ScenarioTest):
"""This test shelves then unshelves a Nova instance
@@ -72,14 +74,15 @@
dst_host = self.get_host_for_server(server['id'])
self.assertNotEqual(src_host, dst_host)
- def _create_server_then_shelve_and_unshelve(self, boot_from_volume=False,
- cold_migrate=False):
+ def _create_server_then_shelve_and_unshelve(
+ self, boot_from_volume=False, cold_migrate=False, image_id=None):
keypair = self.create_keypair()
security_group = self.create_security_group()
security_groups = [{'name': security_group['name']}]
server = self.create_server(
+ image_id=image_id,
key_name=keypair['name'],
security_groups=security_groups,
volume_backed=boot_from_volume)
@@ -107,9 +110,11 @@
@decorators.idempotent_id('1164e700-0af0-4a4c-8792-35909a88743c')
@testtools.skipUnless(CONF.network.public_network_id,
'The public_network_id option must be specified.')
+ @ddt.data('image_ref', 'image_raw_ref')
@utils.services('compute', 'network', 'image')
- def test_shelve_instance(self):
- self._create_server_then_shelve_and_unshelve()
+ def test_shelve_instance(self, image):
+ image_id = getattr(CONF.compute, image)
+ self._create_server_then_shelve_and_unshelve(image_id=image_id)
@decorators.attr(type='slow')
@decorators.idempotent_id('c1b6318c-b9da-490b-9c67-9339b627271f')