Add of basic rescue test
* Adds basic rescue tests * Instance validation of number of mounted disks only Change-Id: I549b82667e34c5edb921291b48a5e44e0dcd18c0
This commit is contained in:
15
test_repo/compute/extensions/rescue/__init__.py
Normal file
15
test_repo/compute/extensions/rescue/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
"""
|
||||||
|
Copyright 2013 Rackspace
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
"""
|
||||||
66
test_repo/compute/extensions/rescue/test_rescue_server.py
Normal file
66
test_repo/compute/extensions/rescue/test_rescue_server.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
"""
|
||||||
|
Copyright 2013 Rackspace
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from cafe.drivers.unittest.decorators import tags
|
||||||
|
from test_repo.compute.fixtures import ComputeFixture
|
||||||
|
|
||||||
|
|
||||||
|
class ServerRescueTests(ComputeFixture):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super(ServerRescueTests, cls).setUpClass()
|
||||||
|
server_response = cls.server_behaviors.create_active_server()
|
||||||
|
cls.server = server_response.entity
|
||||||
|
cls.resources.add(cls.server.id, cls.servers_client.delete_server)
|
||||||
|
flavor_response = cls.flavors_client.get_flavor_details(cls.flavor_ref)
|
||||||
|
cls.flavor = flavor_response.entity
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
super(ServerRescueTests, cls).tearDownClass()
|
||||||
|
|
||||||
|
@tags(type='smoke', net='yes')
|
||||||
|
def test_rescue_and_unrescue_server_test(self):
|
||||||
|
"""Verify that a server can enter and exit rescue mode"""
|
||||||
|
rescue_response = self.rescue_client.rescue(self.server.id)
|
||||||
|
changed_password = rescue_response.entity.admin_pass
|
||||||
|
self.assertTrue(rescue_response.status_code is 200,
|
||||||
|
msg="The response code while rescuing a server is %s instead of 200" % rescue_response.status_code)
|
||||||
|
self.assertTrue(self.server.admin_pass is not changed_password,
|
||||||
|
msg="The password did not change after Rescue.")
|
||||||
|
|
||||||
|
#Enter rescue mode
|
||||||
|
rescue_server_response = self.server_behaviors.wait_for_server_status(self.server.id, 'RESCUE')
|
||||||
|
rescue_server = rescue_server_response.entity
|
||||||
|
rescue_server.admin_pass = changed_password
|
||||||
|
|
||||||
|
#Verify if hard drives are attached
|
||||||
|
remote_client = self.server_behaviors.get_remote_instance_client(rescue_server,
|
||||||
|
self.servers_config)
|
||||||
|
partitions = remote_client.get_partition_details()
|
||||||
|
self.assertEqual(3, len(partitions))
|
||||||
|
|
||||||
|
#Exit rescue mode
|
||||||
|
unrescue_response = self.rescue_client.unrescue(self.server.id)
|
||||||
|
self.assertTrue(unrescue_response.status_code == 202,
|
||||||
|
msg="The response code while unrescuing a server is %s instead of 202" % rescue_response.status_code)
|
||||||
|
|
||||||
|
self.server_behaviors.wait_for_server_status(self.server.id, 'ACTIVE')
|
||||||
|
remote_client = self.server_behaviors.get_remote_instance_client(self.server,
|
||||||
|
self.servers_config)
|
||||||
|
partitions = remote_client.get_partition_details()
|
||||||
|
self.assertEqual(2, len(partitions), msg="The number of partitions after unrescue were not two.")
|
||||||
@@ -27,6 +27,7 @@ from cloudcafe.compute.images_api.client import ImagesClient
|
|||||||
from cloudcafe.compute.extensions.keypairs_api.client import KeypairsClient
|
from cloudcafe.compute.extensions.keypairs_api.client import KeypairsClient
|
||||||
from cloudcafe.compute.extensions.security_groups_api.client import \
|
from cloudcafe.compute.extensions.security_groups_api.client import \
|
||||||
SecurityGroupsClient
|
SecurityGroupsClient
|
||||||
|
from cloudcafe.compute.extensions.rescue_api.client import RescueClient
|
||||||
from cloudcafe.compute.servers_api.behaviors import ServerBehaviors
|
from cloudcafe.compute.servers_api.behaviors import ServerBehaviors
|
||||||
from cloudcafe.compute.images_api.behaviors import ImageBehaviors
|
from cloudcafe.compute.images_api.behaviors import ImageBehaviors
|
||||||
from cloudcafe.compute.config import ComputeConfig
|
from cloudcafe.compute.config import ComputeConfig
|
||||||
@@ -61,13 +62,13 @@ class ComputeFixture(BaseTestFixture):
|
|||||||
cls.image_ref_alt = cls.images_config.secondary_image
|
cls.image_ref_alt = cls.images_config.secondary_image
|
||||||
cls.disk_path = cls.servers_config.instance_disk_path
|
cls.disk_path = cls.servers_config.instance_disk_path
|
||||||
|
|
||||||
cls.identity_config = OSTokenAPI_Config()
|
cls.identity_config = TokenAPI_Config()
|
||||||
token_client = OSTokenAPI_Client(
|
token_client = TokenAPI_Client(
|
||||||
cls.identity_config.authentication_endpoint, 'json', 'json')
|
cls.identity_config.authentication_endpoint, 'json', 'json')
|
||||||
token_behaviors = OSTokenAPI_Behaviors(token_client)
|
token_behaviors = TokenAPI_Behaviors(token_client)
|
||||||
access_data = token_behaviors.get_access_data(cls.identity_config.username,
|
access_data = token_behaviors.get_access_data(cls.identity_config.username,
|
||||||
cls.identity_config.password,
|
cls.identity_config.api_key,
|
||||||
cls.identity_config.tenant_name)
|
cls.identity_config.tenant_id)
|
||||||
|
|
||||||
compute_service = access_data.get_service(
|
compute_service = access_data.get_service(
|
||||||
cls.compute_config.compute_endpoint_name)
|
cls.compute_config.compute_endpoint_name)
|
||||||
@@ -83,6 +84,8 @@ class ComputeFixture(BaseTestFixture):
|
|||||||
'json', 'json')
|
'json', 'json')
|
||||||
cls.sec_groups_client = SecurityGroupsClient(
|
cls.sec_groups_client = SecurityGroupsClient(
|
||||||
url, access_data.token.id_, 'json', 'json')
|
url, access_data.token.id_, 'json', 'json')
|
||||||
|
cls.rescue_client = RescueClient(url, access_data.token.id_,
|
||||||
|
'json', 'json')
|
||||||
cls.server_behaviors = ServerBehaviors(cls.servers_client,
|
cls.server_behaviors = ServerBehaviors(cls.servers_client,
|
||||||
cls.servers_config,
|
cls.servers_config,
|
||||||
cls.images_config,
|
cls.images_config,
|
||||||
|
|||||||
Reference in New Issue
Block a user