Integration scenario test refactoring
- Added new base class for scenario tests with common parameters
initialization in the setUpClass
- Added short description for every test
- Scenario tests structure has become more similar
Change-Id: Icdecb1f16290038f20471991a5f998de2c0a27ea
diff --git a/scenario/test_server_cfn_init.py b/scenario/test_server_cfn_init.py
index cc5d9d2..1f12e71 100644
--- a/scenario/test_server_cfn_init.py
+++ b/scenario/test_server_cfn_init.py
@@ -14,55 +14,32 @@
import logging
from heat_integrationtests.common import exceptions
-from heat_integrationtests.common import test
+from heat_integrationtests.scenario import scenario_base
LOG = logging.getLogger(__name__)
-class CfnInitIntegrationTest(test.HeatIntegrationTest):
+class CfnInitIntegrationTest(scenario_base.ScenarioTestsBase):
+ """
+ The class is responsible for testing cfn-init and cfn-signal workability
+ """
def setUp(self):
super(CfnInitIntegrationTest, self).setUp()
- if not self.conf.image_ref:
- raise self.skipException("No image configured to test")
- self.assign_keypair()
- self.client = self.orchestration_client
- self.template_name = 'test_server_cfn_init.yaml'
- self.sub_dir = 'templates'
-
- def launch_stack(self):
- net = self._get_default_network()
- parameters = {
- 'key_name': self.keypair_name,
- 'flavor': self.conf.instance_type,
- 'image': self.conf.image_ref,
- 'timeout': self.conf.build_timeout,
- 'subnet': net['subnets'][0],
- }
-
- # create the stack
- template = self._load_template(__file__, self.template_name,
- self.sub_dir)
- return self.stack_create(template=template,
- parameters=parameters)
def check_stack(self, sid):
- self._wait_for_resource_status(
- sid, 'WaitHandle', 'CREATE_COMPLETE')
- self._wait_for_resource_status(
- sid, 'SmokeSecurityGroup', 'CREATE_COMPLETE')
- self._wait_for_resource_status(
- sid, 'SmokeKeys', 'CREATE_COMPLETE')
- self._wait_for_resource_status(
- sid, 'CfnUser', 'CREATE_COMPLETE')
- self._wait_for_resource_status(
- sid, 'SmokeServer', 'CREATE_COMPLETE')
+ # Check status of all resources
+ for res in ('WaitHandle', 'SmokeSecurityGroup', 'SmokeKeys',
+ 'CfnUser', 'SmokeServer'):
+ self._wait_for_resource_status(
+ sid, res, 'CREATE_COMPLETE')
server_resource = self.client.resources.get(sid, 'SmokeServer')
server_id = server_resource.physical_resource_id
server = self.compute_client.servers.get(server_id)
server_ip = server.networks[self.conf.network_for_ssh][0]
+ # Check that created server is reachable
if not self._ping_ip_address(server_ip):
self._log_console_output(servers=[server])
self.fail(
@@ -80,6 +57,7 @@
# logs to be compared
self._log_console_output(servers=[server])
+ # Check stack status
self._wait_for_stack_status(sid, 'CREATE_COMPLETE')
stack = self.client.stacks.get(sid)
@@ -94,9 +72,8 @@
self._stack_output(stack, 'WaitConditionStatus'))
self.assertEqual('smoke test complete', wait_status['smoke_status'])
+ # Check that the user can authenticate with the generated keypair
if self.keypair:
- # Check that the user can authenticate with the generated
- # keypair
try:
linux_client = self.get_remote_client(
server_ip, username='ec2-user')
@@ -107,5 +84,30 @@
raise e
def test_server_cfn_init(self):
- sid = self.launch_stack()
- self.check_stack(sid)
+ """
+ Check cfn-init and cfn-signal availability on the created server.
+
+ The alternative scenario is the following:
+ 1. Create a stack with a server and configured security group.
+ 2. Check that all stack resources were created.
+ 3. Check that created server is reachable.
+ 4. Check that stack was created successfully.
+ 5. Check that is it possible to connect to server
+ via generated keypair.
+ """
+ parameters = {
+ "key_name": self.keypair_name,
+ "flavor": self.conf.instance_type,
+ "image": self.conf.image_ref,
+ "timeout": self.conf.build_timeout,
+ "subnet": self.net["subnets"][0],
+ }
+
+ # Launch stack
+ stack_id = self.launch_stack(
+ template_name="test_server_cfn_init.yaml",
+ parameters=parameters
+ )
+
+ # Check stack
+ self.check_stack(stack_id)