Skip to content

Commit

Permalink
Merge pull request #54278 from Akm0d/cloud-test-logging
Browse files Browse the repository at this point in the history
Correctly detect when an ms_azure instance is deleted
  • Loading branch information
dwoz authored Aug 21, 2019
2 parents 94f77a0 + 2dc1520 commit 93cf40a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/integration/cloud/helpers/cloud_test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ def assertInstanceExists(self, creation_ret=None, instance_name=None):

# Assert that the last query was successful
self.assertTrue(self._instance_exists(instance_name, query),
'Instance "{}" was not created successfully: '.format(', '.join(query)))
'Instance "{}" was not created successfully: {}'.format(self.instance_name, ', '.join(query)))

log.debug('Instance exists and was created: "{}"'.format(instance_name))

def assertDestroyInstance(self):
shutdown_delay = 30
log.debug('Deleting instance "{}"'.format(self.instance_name))
delete_str = self.run_cloud('-d {0} --assume-yes --out=yaml'.format(self.instance_name), timeout=TIMEOUT)
if delete_str:
Expand All @@ -122,7 +121,15 @@ def assertDestroyInstance(self):
self.assertEqual(current_state.get('name'), 'shutting-down')
return
# It's not clear from the delete string that deletion was successful, ask salt-cloud after a delay
sleep(shutdown_delay)
query = self.query_instances()
# some instances take a while to report their destruction
for tries in range(6):
if self._instance_exists(query=query):
sleep(30)
log.debug('Instance "{}" still found in query after {} tries: {}'
.format(self.instance_name, tries, query))
query = self.query_instances()
# The last query should have been successful
self.assertNotIn(self.instance_name, self.query_instances())

@property
Expand Down

0 comments on commit 93cf40a

Please sign in to comment.