mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
removed print statements, optimized query
This commit is contained in:
parent
14b75397f3
commit
29ee7ceafd
1 changed files with 9 additions and 9 deletions
|
@ -21,39 +21,39 @@ class CloudTest(ShellCase):
|
|||
def instance_name(self):
|
||||
if not hasattr(self, '_instance_name'):
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
self._instance_name = generate_random_name('CLOUD-TEST-').upper()
|
||||
self._instance_name = generate_random_name('cloud-test-').lower()
|
||||
return self._instance_name
|
||||
|
||||
def _instance_exists(self):
|
||||
# salt-cloud -a show_instance myinstance
|
||||
query = self.run_cloud('--query')
|
||||
print('INSTANCE EXISTS? {}: {}'.format(self.instance_name, query))
|
||||
return ' {0}:'.format(self.instance_name) in query
|
||||
log.debug('Checking for "{}" in => {}'.format(self.instance_name, query))
|
||||
return any(self.instance_name is q.strip(': ') for q in query)
|
||||
|
||||
def _destroy_instance(self):
|
||||
print('Deleting instance "{}"'.format(self.instance_name))
|
||||
log.debug('Deleting instance "{}"'.format(self.instance_name))
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(self.instance_name), timeout=TIMEOUT)
|
||||
# example response: ['gce-config:', '----------', ' gce:', '----------', 'cloud-test-dq4e6c:', 'True', '']
|
||||
delete_str = ''.join(delete)
|
||||
print('Deletion status: {}'.format(delete_str))
|
||||
log.debug('Deletion status: {}'.format(delete_str))
|
||||
|
||||
if any([x in delete_str for x in (
|
||||
'True',
|
||||
'was successfully deleted'
|
||||
)]):
|
||||
print('Instance "{}" was successfully deleted'.format(self.instance_name))
|
||||
log.debug('Instance "{}" was successfully deleted'.format(self.instance_name))
|
||||
elif any([x in delete_str for x in (
|
||||
'shutting-down',
|
||||
'.delete',
|
||||
)]):
|
||||
print('Instance "{}" is cleaning up'.format(self.instance_name))
|
||||
log.debug('Instance "{}" is cleaning up'.format(self.instance_name))
|
||||
sleep(30)
|
||||
else:
|
||||
print('Instance "{}" may not have been deleted properly'.format(self.instance_name))
|
||||
log.warning('Instance "{}" may not have been deleted properly'.format(self.instance_name))
|
||||
|
||||
# By now it should all be over
|
||||
self.assertEqual(self._instance_exists(), False, 'Could not destroy "{}"'.format(self.instance_name))
|
||||
print('Instance "{}" no longer exists'.format(self.instance_name))
|
||||
log.debug('Instance "{}" no longer exists'.format(self.instance_name))
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue