mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Reduced the amount of informtaion in debuggings tatements
This commit is contained in:
parent
de53bf03f7
commit
3f56baddd7
1 changed files with 14 additions and 3 deletions
|
@ -27,6 +27,12 @@ class CloudTest(ShellCase):
|
|||
PROVIDER = ''
|
||||
REQUIRED_PROVIDER_CONFIG_ITEMS = tuple()
|
||||
|
||||
def query_instances(self):
|
||||
'''
|
||||
Standardize the data returned from a query
|
||||
'''
|
||||
return set(x.strip(': ') for x in self.run_cloud('--query') if x.lower().startswith('cloud-test-'))
|
||||
|
||||
def _instance_exists(self, instance_name=None, query=None):
|
||||
'''
|
||||
:param instance_name: The name of the instance to check for in salt-cloud.
|
||||
|
@ -37,8 +43,11 @@ class CloudTest(ShellCase):
|
|||
if not instance_name:
|
||||
instance_name = self.instance_name
|
||||
if not query:
|
||||
query = self.run_cloud('--query')
|
||||
query = self.query_instances()
|
||||
|
||||
log.debug('Checking for "{}" in => {}'.format(instance_name, query))
|
||||
if isinstance(query, set):
|
||||
return instance_name in query
|
||||
return any(instance_name == q.strip(': ') for q in query)
|
||||
|
||||
def assertInstanceExists(self, creation_ret=None, instance_name=None):
|
||||
|
@ -50,12 +59,14 @@ class CloudTest(ShellCase):
|
|||
instance_name = self.instance_name
|
||||
|
||||
# Verify that the instance exists via query
|
||||
query = self.run_cloud('--query')
|
||||
query = self.query_instances()
|
||||
self.assertTrue(self._instance_exists(instance_name, query),
|
||||
'Instance "{}" was not created successfully: |\n\t\t{}\n\t\t|`'.format(
|
||||
instance_name, '\n\t\t'.join(creation_ret if creation_ret else query)))
|
||||
|
||||
# If it exists but doesn't show up in the creation_ret, there was an error during creation
|
||||
log.debug('Instance exists and was created: "{}"'.format(instance_name))
|
||||
|
||||
# If it exists but doesn't show up in the creation_ret, there was probably an error during creation
|
||||
if creation_ret:
|
||||
self.assertIn(instance_name, [i.strip(': ') for i in creation_ret],
|
||||
'An error occured during instance creation: |\n\t\t{}\n\t\t|'.format(
|
||||
|
|
Loading…
Add table
Reference in a new issue