Merge lp:~mthaddon/mojo/charm-testing-mojo-specs into lp:mojo/mojo-specs

Proposed by Tom Haddon
Status: Merged
Merged at revision: 32
Proposed branch: lp:~mthaddon/mojo/charm-testing-mojo-specs
Merge into: lp:mojo/mojo-specs
Diff against target: 201 lines (+134/-0)
13 files modified
charm-testing/README (+32/-0)
charm-testing/check-upgrade-charm (+9/-0)
charm-testing/create-upgrade-collect (+13/-0)
charm-testing/haproxy/collect (+2/-0)
charm-testing/haproxy/deploy (+12/-0)
charm-testing/juju-bootstrap (+3/-0)
charm-testing/juju-destroy-environment (+3/-0)
charm-testing/manifest (+23/-0)
charm-testing/post-deploy (+8/-0)
charm-testing/postgresql/collect (+2/-0)
charm-testing/postgresql/deploy (+12/-0)
charm-testing/pre-deploy (+8/-0)
charm-testing/upgrade-charm (+7/-0)
To merge this branch: bzr merge lp:~mthaddon/mojo/charm-testing-mojo-specs
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+300617@code.launchpad.net

Description of the change

Proof of concept specs for charm testing. Will need some discussion (and some changes to Mojo) so just WIP for now.

To post a comment you must log in.
Revision history for this message
Tom Haddon (mthaddon) wrote :

This is now ready for review

Revision history for this message
Stuart Bishop (stub) wrote :

This looks good. A few issues inline. 1) I am bash challenged 2) most of the time the upgrade test will be a noop so we should skip it in this case.

review: Approve
44. By Tom Haddon

Only do an upgrade test if we set UPGRADE_CHARM

Revision history for this message
Tom Haddon (mthaddon) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'charm-testing'
2=== added file 'charm-testing/README'
3--- charm-testing/README 1970-01-01 00:00:00 +0000
4+++ charm-testing/README 2016-07-28 14:53:46 +0000
5@@ -0,0 +1,32 @@
6+The "charm-testing" stages found here are designed, as the name implies for
7+testing charms. To run it you need to:
8+
9+ * export JUJU_ENV
10+ * export UPGRADE_CHARM as the URL of the charm you want to test an upgrade to
11+ * use the "stage" (e.g. charm-testing/haproxy) based on which charm you want
12+ to test
13+
14+It works in the following way:
15+
16+ * Bootstraps a juju environment
17+ * Pulls down the upstream charm in question (e.g. haproxy) along with any
18+ other charms that are defined in the collect step as being needed to test
19+ the charm in question. As an example, for haproxy you may want to deploy
20+ an apache2 server in front of it and an application server with 3 units
21+ behind it.
22+ * Deploys those charms in the configuration defined in the "deploy" file
23+ within the relevant directory
24+ * Tests a charm upgrade to whatever was defined in the UPGRADE_CHARM variable
25+ * Tears down the environment and redeploys with the charm as defined in
26+ UPGRADE_CHARM. This ensures that you can also install the new charm from
27+ scratch as well as having verified a charm upgrade.
28+
29+If you have a new charm that you'd like to test using this approach, you can
30+propose a merge to this branch with the following:
31+
32+ * A new directory named for the charm in question in charm-testing (e.g.
33+ telegraf)
34+ * A deploy and collect file defining what the upstream versions of the charms
35+ you want to test, with their options and relations
36+ * Optionally a pre-deploy and post-deploy script that will override the
37+ current ones that do nothing.
38
39=== added file 'charm-testing/check-upgrade-charm'
40--- charm-testing/check-upgrade-charm 1970-01-01 00:00:00 +0000
41+++ charm-testing/check-upgrade-charm 2016-07-28 14:53:46 +0000
42@@ -0,0 +1,9 @@
43+#!/bin/bash
44+
45+if [ -n "$UPGRADE_CHARM" ]; then
46+ echo "Upgrade charm set to $UPGRADE_CHARM ; proceeding..."
47+ exit 0
48+fi
49+
50+echo "Upgrade charm (UPGRADE_CHARM environment variable) not set. Exiting..."
51+exit 99
52
53=== added file 'charm-testing/create-upgrade-collect'
54--- charm-testing/create-upgrade-collect 1970-01-01 00:00:00 +0000
55+++ charm-testing/create-upgrade-collect 2016-07-28 14:53:46 +0000
56@@ -0,0 +1,13 @@
57+#!/bin/bash
58+
59+# Our expected MOJO_STAGE would be something like 'charm-testing/postgresql' so
60+# this would be set to 'postgresql'
61+CHARM=${MOJO_STAGE##*/}
62+# If we have a charm directory already, let's remove it in case the new
63+# version is a different type (bzr, git, charmstore, etc.)
64+cd ${MOJO_BUILD_DIR}
65+[ -d ${CHARM} ] && rm -rf ${CHARM}
66+# Now create a collect file we can use in the next phase to download the new
67+# charm we want to test
68+cd ${MOJO_SPEC_DIR}/${MOJO_STAGE}
69+echo "${CHARM} ${UPGRADE_CHARM}" > collect-upgrade
70
71=== added directory 'charm-testing/haproxy'
72=== added file 'charm-testing/haproxy/collect'
73--- charm-testing/haproxy/collect 1970-01-01 00:00:00 +0000
74+++ charm-testing/haproxy/collect 2016-07-28 14:53:46 +0000
75@@ -0,0 +1,2 @@
76+haproxy lp:charms/trusty/haproxy
77+nrpe cs:{{ series }}/nrpe
78
79=== added file 'charm-testing/haproxy/deploy'
80--- charm-testing/haproxy/deploy 1970-01-01 00:00:00 +0000
81+++ charm-testing/haproxy/deploy 2016-07-28 14:53:46 +0000
82@@ -0,0 +1,12 @@
83+haproxy:
84+ series: {{series}}
85+ services:
86+ haproxy:
87+ charm: haproxy
88+ nrpe:
89+ charm: nrpe
90+ {% if series == "xenial" %}options:
91+ procs: '-w 200 -c 250'
92+ swap: '-w 90% -c 75% -n ok'{% endif %}
93+ relations:
94+ - ["haproxy", "nrpe:nrpe-external-master"]
95
96=== added file 'charm-testing/juju-bootstrap'
97--- charm-testing/juju-bootstrap 1970-01-01 00:00:00 +0000
98+++ charm-testing/juju-bootstrap 2016-07-28 14:53:46 +0000
99@@ -0,0 +1,3 @@
100+#!/bin/bash
101+
102+juju bootstrap
103
104=== added file 'charm-testing/juju-destroy-environment'
105--- charm-testing/juju-destroy-environment 1970-01-01 00:00:00 +0000
106+++ charm-testing/juju-destroy-environment 2016-07-28 14:53:46 +0000
107@@ -0,0 +1,3 @@
108+#!/bin/bash
109+
110+juju destroy-environment -y $JUJU_ENV
111
112=== added file 'charm-testing/manifest'
113--- charm-testing/manifest 1970-01-01 00:00:00 +0000
114+++ charm-testing/manifest 2016-07-28 14:53:46 +0000
115@@ -0,0 +1,23 @@
116+## Required environment variables: UPGRADE_CHARM, JUJU_ENV
117+script config=juju-bootstrap
118+# Collect, pre-deploy (lint, etc.) deploy and check the initial charm
119+collect config=collect
120+script config=pre-deploy
121+deploy config=deploy wait=true
122+nagios-check retry=3 sleep=60
123+verify config=post-deploy
124+# Now test an upgrade to the new charm if UPGRADE_CHARM is set
125+stop-on return-code=99 config=check-upgrade-charm UPGRADE_CHARM=${UPGRADE_CHARM}
126+script config=create-upgrade-collect UPGRADE_CHARM=${UPGRADE_CHARM}
127+collect config=collect-upgrade
128+script config=upgrade-charm
129+juju-check-wait
130+nagios-check
131+verify config=post-deploy
132+# Now tear down the env, and test a deployment from scratch (with the updated charm in place)
133+script config=juju-destroy-environment JUJU_ENV=$JUJU_ENV
134+script config=juju-bootstrap
135+script config=pre-deploy
136+deploy config=deploy wait=true
137+nagios-check retry=3 sleep=60
138+verify config=post-deploy
139
140=== added file 'charm-testing/post-deploy'
141--- charm-testing/post-deploy 1970-01-01 00:00:00 +0000
142+++ charm-testing/post-deploy 2016-07-28 14:53:46 +0000
143@@ -0,0 +1,8 @@
144+#!/bin/bash
145+
146+echo "No post-deploy steps currently for this service."
147+echo " To create post-deploy steps (e2e service checks, etc.) create an "
148+echo " executable script in the specific directory for the service in "
149+echo " question which will override this one."
150+
151+exit 0
152
153=== added directory 'charm-testing/postgresql'
154=== added file 'charm-testing/postgresql/collect'
155--- charm-testing/postgresql/collect 1970-01-01 00:00:00 +0000
156+++ charm-testing/postgresql/collect 2016-07-28 14:53:46 +0000
157@@ -0,0 +1,2 @@
158+postgresql cs:{{ series }}/postgresql
159+nrpe cs:{{ series }}/nrpe
160
161=== added file 'charm-testing/postgresql/deploy'
162--- charm-testing/postgresql/deploy 1970-01-01 00:00:00 +0000
163+++ charm-testing/postgresql/deploy 2016-07-28 14:53:46 +0000
164@@ -0,0 +1,12 @@
165+postgresql:
166+ series: {{series}}
167+ services:
168+ postgresql:
169+ charm: postgresql
170+ nrpe:
171+ charm: nrpe
172+ {% if series == "xenial" %}options:
173+ procs: '-w 200 -c 250'
174+ swap: '-w 90% -c 75% -n ok'{% endif %}
175+ relations:
176+ - ["postgresql", "nrpe:nrpe-external-master"]
177
178=== added file 'charm-testing/pre-deploy'
179--- charm-testing/pre-deploy 1970-01-01 00:00:00 +0000
180+++ charm-testing/pre-deploy 2016-07-28 14:53:46 +0000
181@@ -0,0 +1,8 @@
182+#!/bin/bash
183+
184+echo "No pre-deploy steps currently for this service."
185+echo " To create pre-deploy steps (lint checks, etc.) create an executable"
186+echo " script in the specific directory for the service in question,"
187+echo " which will override this one."
188+
189+exit 0
190
191=== added file 'charm-testing/upgrade-charm'
192--- charm-testing/upgrade-charm 1970-01-01 00:00:00 +0000
193+++ charm-testing/upgrade-charm 2016-07-28 14:53:46 +0000
194@@ -0,0 +1,7 @@
195+#!/bin/bash
196+
197+CHARM=${MOJO_STAGE##*/}
198+
199+export JUJU_REPOSITORY=$MOJO_REPO_DIR
200+echo "About to upgrade $CHARM"
201+juju upgrade-charm $CHARM

Subscribers

People subscribed via source and target branches

to all changes: