7
from .lib import helper
9
d = amulet.Deployment()
12
d.relate('mysql:db', 'wordpress:db')
16
# Create the deployment described above, give us 900 seconds to do it
18
# Setup will only make sure the services are deployed, related, and in a
19
# "started" state. We can employ the sentries to actually make sure there
20
# are no more hooks being executed on any of the nodes.
22
except amulet.helpers.TimeoutError:
23
amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
25
# Something else has gone wrong, raise the error so we can see it and this
26
# will automatically "FAIL" the test.
29
# Shorten the names a little to make working with unit data easier
30
wp_unit = d.sentry.unit['wordpress/0']
31
mysql_unit = d.sentry.unit['mysql/0']
33
# WordPress requires user input to "finish" a setup. This code is contained in
34
# the helper.py file found in the lib directory. If it's not able to complete
35
# the WordPress setup we need to quit the test, not as failed per se, but as a
36
# SKIPed test since we can't accurately setup the environment
38
helper.finish_setup(wp_unit.info['public-address'], password='amulet-test')
40
amulet.raise_status(amulet.SKIP, msg="Unable to finish WordPress setup")
42
home_page = requests.get('http://%s/' % wp_unit.info['public-address'])
43
home_page.raise_for_status() # Make sure it's not 5XX error
45
# Augment our deployment by adding a few more services, currently memcached
46
# relation only works after MySQL has been established and the user has
47
# completed the setup process. This isn't considered good practice in charms
48
# but it's simply a limitation to be addressed in the near future.
50
d.relate('wordpress:cache', 'memcached:cache')
52
# Since we've changed the schema of our deployment, we need to run setup again
55
# Default timeout should be enough time to get memcached up and related
58
except amulet.helpers.TimeoutError:
59
amulet.raise_status(amulet.SKIP, msg="Memcached wasn't stood up in time.")
61
# Incase deployer throws an error
64
# Verify WordPress still responds with a 200
65
home_page = requests.get('http://%s/' % wp_unit.info['public-address'])
66
home_page.raise_for_status()
68
# Verify the WordPress plugin was installed correctly
69
wp_unit.directory('/var/www/wp-content/plugins/wp-ffpc')