Skip to content

Commit

Permalink
Merge pull request openstack-charmers#440 from openstack-charmers/lou…
Browse files Browse the repository at this point in the history
…rot/app-under-test

Make determination of app under test more robust
  • Loading branch information
David Ames authored Oct 9, 2020
2 parents 181bb98 + f27ee7c commit 41c5434
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion zaza/openstack/charm_tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,28 @@ def setUpClass(cls, application_name=None, model_alias=None):
else:
cls.model_name = model.get_juju_model()
cls.test_config = lifecycle_utils.get_charm_config(fatal=False)
charm_under_test_name = cls.test_config['charm_name']

if application_name:
cls.application_name = application_name
else:
cls.application_name = cls.test_config['charm_name']
deployed_app_names = model.sync_deployed(model_name=cls.model_name)
if charm_under_test_name in deployed_app_names:
# There is an application named like the charm under test.
# Let's consider it the application under test:
cls.application_name = charm_under_test_name
else:
# Let's search for any application whose name starts with the
# name of the charm under test and assume it's the application
# under test:
for app_name in deployed_app_names:
if app_name.startswith(charm_under_test_name):
cls.application_name = app_name
break
else:
logging.warning('Could not find application under test')
return

cls.lead_unit = model.get_lead_unit_name(
cls.application_name,
model_name=cls.model_name)
Expand Down

0 comments on commit 41c5434

Please sign in to comment.