3
# This Amulet based tests
4
# The goal is to ensure the Ubuntu charm
5
# sucessfully deploys and can be accessed.
6
# Note the Ubuntu charm does not have any
7
# relations or config options.
13
# Timeout value, in seconds to deploy the environment
16
# Set up the deployer module to interact and set up the environment.
17
d = amulet.Deployment()
19
# Define the environment in terms of charms, their config, and relations.
21
# Add the Ubuntu charm to the deployment.
24
# Deploy the environment currently defined
26
# Wait the defined about amount of time to deploy the environment.
27
# Setup makes sure the services are deployed, related, and in a
29
d.setup(timeout=seconds)
30
# Use a sentry to ensure there are no remaining hooks being execute
33
except amulet.helpers.TimeoutError:
34
# Pending the configuration the test will fail or be skipped
35
# if not deployed properly.
36
error_message = 'The environment did not deploy in %d seconds.' % seconds
37
amulet.raise_status(amulet.SKIP, msg=error_message)
39
# Something else has gone wrong, raise the error so we can see it and this
40
# will automatically "FAIL" the test.
43
# Access the Ubuntu instance to ensure it has been deployed correctly
45
# Define the commands to be ran
46
lsb_release_command = 'cat /etc/lsb-release'
47
uname_command = 'uname -a'
49
# Cat the release information
50
output, code = d.sentry.unit['ubuntu/0'].run(lsb_release_command)
51
# Confirm the lsb-release command was ran successfully
53
error_message = 'The ' + lsb_release_command + ' did not return the expected return code of 0.'
55
amulet.raise_status(amulet.FAIL, msg=error_message)
57
message = 'The lsb-release command successfully executed.'
61
# Get the uname -a output
62
output, code = d.sentry.unit['ubuntu/0'].run(uname_command)
63
# Confirm the uname command was ran successfully
65
error_message = 'The ' + uname_command + ' did not return the expected return code of 0.'
67
amulet.raise_status(amulet.FAIL, msg=error_message)
69
message = 'The uname command successfully executed.'