Adds tests for instance actions

* Added general check for action validation to fixture
* Added tests for most basic actions
* Skipped tests failing due to likely bugs

Change-Id: I3ab14143aea092540697e90d7e65008eea40f292
This commit is contained in:
Daryl Walleck
2013-05-27 16:30:36 -05:00
parent b0c80e0102
commit e24e10dea7
6 changed files with 159 additions and 9 deletions

View File

@@ -63,9 +63,9 @@ class ComputeFixture(BaseTestFixture):
cls.disk_path = cls.servers_config.instance_disk_path cls.disk_path = cls.servers_config.instance_disk_path
cls.endpoint_config = UserAuthConfig() cls.endpoint_config = UserAuthConfig()
user_config = UserConfig() cls.user_config = UserConfig()
access_data = AuthProvider.get_access_data(cls.endpoint_config, access_data = AuthProvider.get_access_data(cls.endpoint_config,
user_config) cls.user_config)
compute_service = access_data.get_service( compute_service = access_data.get_service(
cls.compute_endpoint.compute_endpoint_name) cls.compute_endpoint.compute_endpoint_name)
@@ -111,6 +111,29 @@ class ComputeFixture(BaseTestFixture):
image_ref = image_response.headers['location'] image_ref = image_response.headers['location']
return image_ref.rsplit('/')[-1] return image_ref.rsplit('/')[-1]
def validate_instance_action(self, action, server_id,
user_id, project_id, request_id):
message = "Expected {0} to be {1}, was {2}."
self.assertEqual(action.instance_uuid, server_id,
msg=message.format('instance id',
action.instance_uuid,
server_id))
self.assertEqual(action.user_id, user_id,
msg=message.format('user id',
action.user_id,
user_id))
self.assertEqual(action.project_id, project_id,
msg=message.format('project id',
action.project_id,
project_id))
self.assertIsNotNone(action.start_time)
self.assertEquals(action.request_id, request_id,
msg=message.format('request id',
action.request_id,
request_id))
self.assertIsNone(action.message)
class CreateServerFixture(ComputeFixture): class CreateServerFixture(ComputeFixture):
""" """

View File

@@ -71,3 +71,26 @@ class ChangeServerPasswordTests(CreateServerFixture):
remote_client.can_connect_to_public_ip(), remote_client.can_connect_to_public_ip(),
"Could not connect to server (%s) using new admin password %s" % "Could not connect to server (%s) using new admin password %s" %
(public_address, self.new_password)) (public_address, self.new_password))
@tags(type='smoke', net='no')
@unittest.skip("lp1183712")
def test_password_changed_server_instance_actions(self):
"""
Verify the correct actions are logged during a password change.
"""
actions = self.servers_client.get_instance_actions(
self.server.id).entity
# Verify the change password action is listed
self.assertTrue(any(a.action == 'changePassword' for a in actions))
filtered_actions = [a for a in actions
if a.action == 'changePassword']
self.assertEquals(len(filtered_actions), 1)
password_action = filtered_actions[0]
self.validate_instance_action(
password_action, self.server.id, self.user_config.user_id,
self.user_config.tenant_id,
self.resp.headers['x-compute-request-id'])

View File

@@ -156,3 +156,22 @@ class RebuildServerTests(ComputeFixture):
# Verify the values of the metadata items are correct # Verify the values of the metadata items are correct
self.assertEqual(rebuilt_server.metadata.key, 'value') self.assertEqual(rebuilt_server.metadata.key, 'value')
@tags(type='smoke', net='no')
def test_rebuilt_server_instance_actions(self):
"""Verify the correct actions are logged during a rebuild."""
actions = self.servers_client.get_instance_actions(
self.server.id).entity
# Verify the rebuild action is listed
self.assertTrue(any(a.action == 'rebuild' for a in actions))
filtered_actions = [a for a in actions if a.action == 'rebuild']
self.assertEquals(len(filtered_actions), 1)
rebuild_action = filtered_actions[0]
self.validate_instance_action(
rebuild_action, self.server.id, self.user_config.user_id,
self.user_config.tenant_id,
self.rebuilt_server_response.headers['x-compute-request-id'])

View File

@@ -14,9 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
""" """
import unittest2 as unittest
from cafe.drivers.unittest.decorators import tags from cafe.drivers.unittest.decorators import tags
from cloudcafe.compute.common.types import NovaServerStatusTypes from cloudcafe.compute.common.types import NovaServerStatusTypes
from cloudcafe.compute.common.equality_tools import EqualityTools
from test_repo.compute.fixtures import ComputeFixture from test_repo.compute.fixtures import ComputeFixture
@@ -30,11 +31,13 @@ class ResizeServerUpConfirmTests(ComputeFixture):
cls.resources.add(server_to_resize.id, cls.servers_client.delete_server) cls.resources.add(server_to_resize.id, cls.servers_client.delete_server)
# resize server and confirm # resize server and confirm
cls.servers_client.resize(server_to_resize.id, cls.flavor_ref_alt) cls.resize_resp = cls.servers_client.resize(
cls.server_behaviors.wait_for_server_status(server_to_resize.id, server_to_resize.id, cls.flavor_ref_alt)
NovaServerStatusTypes.VERIFY_RESIZE) cls.server_behaviors.wait_for_server_status(
server_to_resize.id, NovaServerStatusTypes.VERIFY_RESIZE)
cls.servers_client.confirm_resize(server_to_resize.id) cls.confirm_resize_resp = cls.servers_client.confirm_resize(
server_to_resize.id)
cls.server_behaviors.wait_for_server_status(server_to_resize.id, cls.server_behaviors.wait_for_server_status(server_to_resize.id,
NovaServerStatusTypes.ACTIVE) NovaServerStatusTypes.ACTIVE)
resized_server_response = cls.servers_client.get_server(server_to_resize.id) resized_server_response = cls.servers_client.get_server(server_to_resize.id)
@@ -95,3 +98,33 @@ class ResizeServerUpConfirmTests(ComputeFixture):
self.assertTrue(int(self.resized_flavor.ram) == server_ram_size or lower_limit <= server_ram_size, self.assertTrue(int(self.resized_flavor.ram) == server_ram_size or lower_limit <= server_ram_size,
msg="Ram size after confirm-resize did not match. Expected ram size : %s, Actual ram size : %s" % msg="Ram size after confirm-resize did not match. Expected ram size : %s, Actual ram size : %s" %
(self.resized_flavor.ram, server_ram_size)) (self.resized_flavor.ram, server_ram_size))
@tags(type='smoke', net='no')
@unittest.skip("lp1183712")
def test_resized_server_instance_actions(self):
"""Verify the correct actions are logged during a confirmed resize."""
actions = self.servers_client.get_instance_actions(
self.server.id).entity
# Verify the resize action is listed
self.assertTrue(any(a.action == 'resize' for a in actions))
filtered_actions = [a for a in actions if a.action == 'resize']
self.assertEquals(len(filtered_actions), 1)
resize_action = filtered_actions[0]
self.validate_instance_action(
resize_action, self.server.id, self.user_config.user_id,
self.user_config.tenant_id,
self.resize_resp.headers['x-compute-request-id'])
# Verify the confirm resize action is listed
self.assertTrue(any(a.action == 'confirmResize' for a in actions))
filtered_actions = [a for a in actions if a.action == 'confirmResize']
self.assertEquals(len(filtered_actions), 1)
resize_action = filtered_actions[0]
self.validate_instance_action(
resize_action, self.server.id, self.user_config.user_id,
self.user_config.tenant_id,
self.confirm_resize_resp.headers['x-compute-request-id'])

View File

@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
""" """
import unittest2 as unittest
from cafe.drivers.unittest.decorators import tags from cafe.drivers.unittest.decorators import tags
from cloudcafe.compute.common.types import NovaServerStatusTypes from cloudcafe.compute.common.types import NovaServerStatusTypes
from test_repo.compute.fixtures import ComputeFixture from test_repo.compute.fixtures import ComputeFixture
@@ -29,11 +31,13 @@ class ResizeServerUpRevertTests(ComputeFixture):
cls.resources.add(server_to_resize.id, cls.servers_client.delete_server) cls.resources.add(server_to_resize.id, cls.servers_client.delete_server)
# resize server and confirm # resize server and confirm
cls.servers_client.resize(server_to_resize.id, cls.flavor_ref_alt) cls.resize_resp = cls.servers_client.resize(
server_to_resize.id, cls.flavor_ref_alt)
cls.server_behaviors.wait_for_server_status(server_to_resize.id, cls.server_behaviors.wait_for_server_status(server_to_resize.id,
NovaServerStatusTypes.VERIFY_RESIZE) NovaServerStatusTypes.VERIFY_RESIZE)
cls.servers_client.revert_resize(server_to_resize.id) cls.revert_resize_resp = cls.servers_client.revert_resize(
server_to_resize.id)
cls.server_behaviors.wait_for_server_status(server_to_resize.id, cls.server_behaviors.wait_for_server_status(server_to_resize.id,
NovaServerStatusTypes.ACTIVE) NovaServerStatusTypes.ACTIVE)
resized_server_response = cls.servers_client.get_server(server_to_resize.id) resized_server_response = cls.servers_client.get_server(server_to_resize.id)
@@ -89,3 +93,33 @@ class ResizeServerUpRevertTests(ComputeFixture):
self.assertTrue(int(self.flavor.ram) == server_ram_size or lower_limit <= server_ram_size, self.assertTrue(int(self.flavor.ram) == server_ram_size or lower_limit <= server_ram_size,
msg="Ram size after confirm-resize did not match. Expected ram size : %s, Actual ram size : %s" % msg="Ram size after confirm-resize did not match. Expected ram size : %s, Actual ram size : %s" %
(self.flavor.ram, server_ram_size)) (self.flavor.ram, server_ram_size))
@tags(type='smoke', net='no')
@unittest.skip("lp1183712")
def test_resize_reverted_server_instance_actions(self):
"""Verify the correct actions are logged during a resize revert."""
actions = self.servers_client.get_instance_actions(
self.server.id).entity
# Verify the resize action is listed
self.assertTrue(any(a.action == 'resize' for a in actions))
filtered_actions = [a for a in actions if a.action == 'resize']
self.assertEquals(len(filtered_actions), 1)
resize_action = filtered_actions[0]
self.validate_instance_action(
resize_action, self.server.id, self.user_config.user_id,
self.user_config.tenant_id,
self.resize_resp.headers['x-compute-request-id'])
# Verify the revert resize action is listed
self.assertTrue(any(a.action == 'revertResize' for a in actions))
filtered_actions = [a for a in actions if a.action == 'revertResize']
self.assertEquals(len(filtered_actions), 1)
resize_action = filtered_actions[0]
self.validate_instance_action(
resize_action, self.server.id, self.user_config.user_id,
self.user_config.tenant_id,
self.revert_resize_resp.headers['x-compute-request-id'])

View File

@@ -203,3 +203,21 @@ class CreateServerTest(ComputeFixture):
# Verify the values of the metadata items are correct # Verify the values of the metadata items are correct
self.assertEqual(self.server.metadata.meta_key_1, 'meta_value_1') self.assertEqual(self.server.metadata.meta_key_1, 'meta_value_1')
self.assertEqual(self.server.metadata.meta_key_2, 'meta_value_2') self.assertEqual(self.server.metadata.meta_key_2, 'meta_value_2')
@tags(type='smoke', net='no')
def test_created_server_instance_actions(self):
"""Verify the correct actions are logged while creating a server."""
actions = self.servers_client.get_instance_actions(
self.server.id).entity
# Verify the create action is listed
self.assertTrue(any(a.action == 'create' for a in actions))
filtered_actions = [a for a in actions if a.action == 'create']
self.assertEquals(len(filtered_actions), 1)
create_action = filtered_actions[0]
self.validate_instance_action(
create_action, self.server.id, self.user_config.user_id,
self.user_config.tenant_id,
self.create_resp.headers['x-compute-request-id'])