3
# This amulet test deploys the bundles.yaml file in this directory.
11
seconds_to_wait = 1200
14
class BundleTest(unittest.TestCase):
15
"""Create a class for testing the charm in the unit test framework."""
18
"""Set up an amulet deployment using the bundle."""
19
origin = os.environ.get('LANDSCAPE_CLIENT_CHARM_ORIGIN', None)
20
d = amulet.Deployment()
21
bundle_path = os.path.join(os.path.dirname(__file__), 'bundles.yaml')
22
with open(bundle_path, 'r') as bundle_file:
23
contents = yaml.safe_load(bundle_file)
25
if origin is not None:
26
d.configure("landscape-client", {"origin": origin})
27
d.setup(seconds_to_wait)
28
d.sentry.wait(seconds_to_wait)
31
def test_deployed(self):
32
"""Test to see if the bundle deployed successfully."""
33
self.assertTrue(self.d.deployed)
35
def test_wait_for_success_in_log(self):
36
"""landscape-client should successfully register."""
37
logfile = "/var/log/juju/unit-landscape-client*.log"
38
grep = "grep 'System successfully registered'"
39
# Only principal units are addressable in this way.
41
result = self.d.sentry.unit['ubuntu/0'].run(
42
"%s %s" % (grep, logfile))
46
# success, fall through
49
raise AssertionError("Could not verify registration of the client")
52
if __name__ == '__main__':