Use AWS::EC2::EIP for test_server_cfn_init

Many (most) clouds won't have the assumed network to directly ping/ssh
to the default IP address. This changes test_server_cfn_init to assign
a floating IP, and use that to ping and ssh to the server.

It also moves the ping to the end of the test. This was initially
meant to catch regressions in a co-gated neutron, but it is no longer
required for a heat-only test.

Change-Id: Ia9404289b2f9632883a479ccb435cbf6c51fcf2f
This commit is contained in:
Steve Baker 2015-03-12 14:42:51 +13:00
parent 19ddeb1b0b
commit 1fa9413400
2 changed files with 18 additions and 10 deletions

View File

@ -27,6 +27,12 @@ Resources:
Type: AWS::IAM::AccessKey
Properties:
UserName: {Ref: CfnUser}
IPAddress:
Type: AWS::EC2::EIP
Properties:
InstanceId: {Ref: SmokeServer}
SmokeServer:
Type: AWS::EC2::Instance
Metadata:
@ -78,4 +84,4 @@ Outputs:
SmokeServerIp:
Description: IP address of server
Value:
Fn::GetAtt: [SmokeServer, PublicIp]
Ref: IPAddress

View File

@ -30,20 +30,13 @@ class CfnInitIntegrationTest(scenario_base.ScenarioTestsBase):
def check_stack(self, sid):
# Check status of all resources
for res in ('WaitHandle', 'SmokeSecurityGroup', 'SmokeKeys',
'CfnUser', 'SmokeServer'):
'CfnUser', 'SmokeServer', 'IPAddress'):
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(
"Timed out waiting for %s to become reachable" % server_ip)
try:
self._wait_for_resource_status(
@ -72,6 +65,14 @@ class CfnInitIntegrationTest(scenario_base.ScenarioTestsBase):
self._stack_output(stack, 'WaitConditionStatus'))
self.assertEqual('smoke test complete', wait_status['smoke_status'])
server_ip = self._stack_output(stack, 'SmokeServerIp')
# Check that created server is reachable
if not self._ping_ip_address(server_ip):
self._log_console_output(servers=[server])
self.fail(
"Timed out waiting for %s to become reachable" % server_ip)
# Check that the user can authenticate with the generated keypair
if self.keypair:
try:
@ -106,7 +107,8 @@ class CfnInitIntegrationTest(scenario_base.ScenarioTestsBase):
# Launch stack
stack_id = self.launch_stack(
template_name="test_server_cfn_init.yaml",
parameters=parameters
parameters=parameters,
expected_status=None
)
# Check stack