Merge lp:~dpb/charms/precise/landscape-client/add-landscape-relation into lp:~charmers/charms/precise/landscape-client/trunk
- Precise Pangolin (12.04)
- add-landscape-relation
- Merge into trunk
Proposed by
David Britton
Status: | Merged |
---|---|
Merged at revision: | 22 |
Proposed branch: | lp:~dpb/charms/precise/landscape-client/add-landscape-relation |
Merge into: | lp:~charmers/charms/precise/landscape-client/trunk |
Diff against target: |
472 lines (+314/-20) 13 files modified
README (+4/-9) TESTING (+5/-0) config.yaml (+1/-0) hooks/common.py (+14/-2) hooks/hooks.py (+45/-8) hooks/install (+11/-0) metadata.yaml (+2/-0) revision (+1/-1) tests/001_install.test (+95/-0) tests/Makefile (+8/-0) tests/lib/test-config.yaml (+8/-0) tests/lib/test-helpers.sh (+114/-0) tests/test.sh (+6/-0) |
To merge this branch: | bzr merge lp:~dpb/charms/precise/landscape-client/add-landscape-relation |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Ceppi (community) | Approve | ||
Review via email: mp+161497@code.launchpad.net |
Commit message
Description of the change
- Main change: allow association to a landscape-server via relation. This is mostly useful for testing, but could be useful in the future for rapid deployment into an environment that already has a landscape server (which there is no public charm for yet)
- Update README with a couple changes I noticed during testing.
- Add 'tests/' jitsu-test-style test case. Still need to work with m_3 to figure out a couple oddities with it, but it does work for me at least
- centralize hooks into a hooks.py with symlinks
- Add ability to install from a branch (lp: syntax)
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'README' | |||
2 | --- README 2013-02-26 00:45:59 +0000 | |||
3 | +++ README 2013-04-29 20:44:30 +0000 | |||
4 | @@ -14,7 +14,6 @@ | |||
5 | 14 | landscape-client: | 14 | landscape-client: |
6 | 15 | account-name: <account_name_here> | 15 | account-name: <account_name_here> |
7 | 16 | registration-key: <registration_key_here> | 16 | registration-key: <registration_key_here> |
8 | 17 | computer-title: <computer_title_here> | ||
9 | 18 | tags: <csv_tag_list> | 17 | tags: <csv_tag_list> |
10 | 19 | 18 | ||
11 | 20 | The following is a version if you need to customize the communication URL | 19 | The following is a version if you need to customize the communication URL |
12 | @@ -25,12 +24,11 @@ | |||
13 | 25 | landscape-client: | 24 | landscape-client: |
14 | 26 | account-name: standalone | 25 | account-name: standalone |
15 | 27 | registration-key: 128-qosk-7382 | 26 | registration-key: 128-qosk-7382 |
16 | 28 | computer-title: Dev Laptop 09 | ||
17 | 29 | tags: laptop,precise,developer | 27 | tags: laptop,precise,developer |
22 | 30 | ping-url = http://landscape.example.com/ping | 28 | ping-url: http://landscape.example.com/ping |
23 | 31 | url = https://landscape.example.com/message-system | 29 | url: https://landscape.example.com/message-system |
24 | 32 | script-users = ALL | 30 | script-users: ALL |
25 | 33 | include-manager-plugins = ScriptExecution | 31 | include-manager-plugins: ScriptExecution |
26 | 34 | 32 | ||
27 | 35 | Configuration | 33 | Configuration |
28 | 36 | ============= | 34 | ============= |
29 | @@ -52,9 +50,6 @@ | |||
30 | 52 | registration-key: | 50 | registration-key: |
31 | 53 | The account registration key, found in the Landscape account GUI. | 51 | The account registration key, found in the Landscape account GUI. |
32 | 54 | 52 | ||
33 | 55 | computer-title: | ||
34 | 56 | Human readable title for your computer. | ||
35 | 57 | |||
36 | 58 | tags: | 53 | tags: |
37 | 59 | Comma separated list of tags to apply to the computer once it is | 54 | Comma separated list of tags to apply to the computer once it is |
38 | 60 | registered. | 55 | registered. |
39 | 61 | 56 | ||
40 | === added file 'TESTING' | |||
41 | --- TESTING 1970-01-01 00:00:00 +0000 | |||
42 | +++ TESTING 2013-04-29 20:44:30 +0000 | |||
43 | @@ -0,0 +1,5 @@ | |||
44 | 1 | Simple end-to-end testing can be performed by: | ||
45 | 2 | |||
46 | 3 | cd tests | ||
47 | 4 | make build | ||
48 | 5 | ./test.sh | ||
49 | 0 | 6 | ||
50 | === modified file 'config.yaml' | |||
51 | --- config.yaml 2013-02-26 00:45:59 +0000 | |||
52 | +++ config.yaml 2013-04-29 20:44:30 +0000 | |||
53 | @@ -6,6 +6,7 @@ | |||
54 | 6 | distro (default), ppa:somecustom/ppa or a full APT url source | 6 | distro (default), ppa:somecustom/ppa or a full APT url source |
55 | 7 | entry with optional key. For example: | 7 | entry with optional key. For example: |
56 | 8 | deb https://asf@private-ppa.launchpad.net/myrepo precise main|YOURAPTKEY" | 8 | deb https://asf@private-ppa.launchpad.net/myrepo precise main|YOURAPTKEY" |
57 | 9 | Also supported is a public branch like lp:~landscape/landscape-client/trunk | ||
58 | 9 | type: string | 10 | type: string |
59 | 10 | data-path: | 11 | data-path: |
60 | 11 | description: | | 12 | description: | |
61 | 12 | 13 | ||
62 | === modified file 'hooks/common.py' | |||
63 | --- hooks/common.py 2013-03-02 00:05:38 +0000 | |||
64 | +++ hooks/common.py 2013-04-29 20:44:30 +0000 | |||
65 | @@ -47,7 +47,12 @@ | |||
66 | 47 | stop_client_and_disable_init_script() | 47 | stop_client_and_disable_init_script() |
67 | 48 | self.exit_code = exit_code | 48 | self.exit_code = exit_code |
68 | 49 | 49 | ||
70 | 50 | 50 | def clear_registration(): | |
71 | 51 | """ | ||
72 | 52 | Do steps necessary to clear the client registration, so that next time | ||
73 | 53 | it will re-register | ||
74 | 54 | """ | ||
75 | 55 | stop_client_and_disable_init_script() | ||
76 | 51 | 56 | ||
77 | 52 | def try_to_register(): | 57 | def try_to_register(): |
78 | 53 | """Try to register the client if needed. | 58 | """Try to register the client if needed. |
79 | @@ -58,6 +63,9 @@ | |||
80 | 58 | which means that it's expected that the configuration will be broken | 63 | which means that it's expected that the configuration will be broken |
81 | 59 | at that point. | 64 | at that point. |
82 | 60 | 65 | ||
83 | 66 | The following keys need to be set for an attempt to be made: | ||
84 | 67 | - account_name, computer_title | ||
85 | 68 | |||
86 | 61 | If an error is encountered, the client will be disabled and the hook | 69 | If an error is encountered, the client will be disabled and the hook |
87 | 62 | calling this function will exit with an error code. | 70 | calling this function will exit with an error code. |
88 | 63 | """ | 71 | """ |
89 | @@ -68,7 +76,11 @@ | |||
90 | 68 | config = LandscapeSetupConfiguration() | 76 | config = LandscapeSetupConfiguration() |
91 | 69 | config.load([]) | 77 | config.load([]) |
92 | 70 | config.silent = True | 78 | config.silent = True |
94 | 71 | if configured or not config.get("computer_title"): | 79 | if configured: |
95 | 80 | print "Client already registered, skipping" | ||
96 | 81 | return 0 | ||
97 | 82 | if not config.get("account_name") or not config.get("computer_title"): | ||
98 | 83 | print "Need account-name and computer-title to proceed, skipping" | ||
99 | 72 | return 0 | 84 | return 0 |
100 | 73 | try: | 85 | try: |
101 | 74 | setup(config) | 86 | setup(config) |
102 | 75 | 87 | ||
103 | === added file 'hooks/common.pyc' | |||
104 | 76 | Binary files hooks/common.pyc 1970-01-01 00:00:00 +0000 and hooks/common.pyc 2013-04-29 20:44:30 +0000 differ | 88 | Binary files hooks/common.pyc 1970-01-01 00:00:00 +0000 and hooks/common.pyc 2013-04-29 20:44:30 +0000 differ |
105 | === added symlink 'hooks/config-changed' | |||
106 | === target is u'hooks.py' | |||
107 | === renamed file 'hooks/config-changed' => 'hooks/hooks.py' | |||
108 | --- hooks/config-changed 2013-02-01 11:55:50 +0000 | |||
109 | +++ hooks/hooks.py 2013-04-29 20:44:30 +0000 | |||
110 | @@ -3,11 +3,48 @@ | |||
111 | 3 | from subprocess import check_output | 3 | from subprocess import check_output |
112 | 4 | import json | 4 | import json |
113 | 5 | import sys | 5 | import sys |
122 | 6 | 6 | import os | |
123 | 7 | from common import update_client_config | 7 | import base64 |
124 | 8 | 8 | ||
125 | 9 | 9 | from common import update_client_config, clear_registration | |
126 | 10 | configs = json.loads(check_output(["config-get", "--format=json"])) | 10 | |
127 | 11 | if configs: | 11 | |
128 | 12 | sys.exit(update_client_config(configs)) | 12 | def _write_certificate(certificate, filename): |
129 | 13 | 13 | """ | |
130 | 14 | @param certificate Text of the certificate, base64 encoded. | ||
131 | 15 | @param filename Full path to file to write | ||
132 | 16 | """ | ||
133 | 17 | with open(filename, "w") as file: | ||
134 | 18 | file.write(base64.b64decode(certificate)) | ||
135 | 19 | |||
136 | 20 | def _registration_relation(): | ||
137 | 21 | cert_file = "/etc/ssl/certs/landscape_server_ca.crt" | ||
138 | 22 | data = json.loads(check_output(["relation-get", "--format=json"])) | ||
139 | 23 | if "ssl-public-key" in data: | ||
140 | 24 | _write_certificate(data["ssl-public-key"], cert_file) | ||
141 | 25 | data["ssl-public-key"] = cert_file | ||
142 | 26 | if "ping-url" in data: | ||
143 | 27 | config_changed(relation_data=data) | ||
144 | 28 | |||
145 | 29 | def config_changed(relation_data={}): | ||
146 | 30 | """ | ||
147 | 31 | @param relation_data: data from the context of a relation, it should | ||
148 | 32 | match the data in the config | ||
149 | 33 | """ | ||
150 | 34 | configs = json.loads(check_output(["config-get", "--format=json"])) | ||
151 | 35 | relation_data.update(configs) | ||
152 | 36 | if 'account-name' in relation_data: | ||
153 | 37 | sys.exit(update_client_config(relation_data)) | ||
154 | 38 | |||
155 | 39 | def registration_relation_joined(): | ||
156 | 40 | _registration_relation(); | ||
157 | 41 | |||
158 | 42 | def registration_relation_changed(): | ||
159 | 43 | _registration_relation(); | ||
160 | 44 | |||
161 | 45 | def registration_relation_departed(): | ||
162 | 46 | clear_registration() | ||
163 | 47 | |||
164 | 48 | if __name__ == "__main__": | ||
165 | 49 | hook = os.path.basename(sys.argv[0]).replace("-", "_") | ||
166 | 50 | eval("%s()" % hook) | ||
167 | 14 | 51 | ||
168 | === modified file 'hooks/install' | |||
169 | --- hooks/install 2013-02-27 00:16:45 +0000 | |||
170 | +++ hooks/install 2013-04-29 20:44:30 +0000 | |||
171 | @@ -45,6 +45,17 @@ | |||
172 | 45 | chmod go+r $SOURCES_FILE | 45 | chmod go+r $SOURCES_FILE |
173 | 46 | return | 46 | return |
174 | 47 | ;; | 47 | ;; |
175 | 48 | lp*) | ||
176 | 49 | rm -rf landscape-client-source; bzr branch $src landscape-client-source | ||
177 | 50 | cd landscape-client-source | ||
178 | 51 | apt_get install devscripts | ||
179 | 52 | apt_get build-dep landscape-client | ||
180 | 53 | DEBUILD_OPTS="-uc -us" make package | ||
181 | 54 | dpkg -i ../landscape-client_* ../landscape-common_* || /bin/true | ||
182 | 55 | apt_get -f install | ||
183 | 56 | cd ../ | ||
184 | 57 | # Should no-op the install later. | ||
185 | 58 | ;; | ||
186 | 48 | *) | 59 | *) |
187 | 49 | echo "Invalid repository origin specified: '" $src "'" | 60 | echo "Invalid repository origin specified: '" $src "'" |
188 | 50 | ;; | 61 | ;; |
189 | 51 | 62 | ||
190 | === added symlink 'hooks/registration-relation-changed' | |||
191 | === target is u'hooks.py' | |||
192 | === added symlink 'hooks/registration-relation-departed' | |||
193 | === target is u'hooks.py' | |||
194 | === added symlink 'hooks/registration-relation-joined' | |||
195 | === target is u'hooks.py' | |||
196 | === modified file 'metadata.yaml' | |||
197 | --- metadata.yaml 2013-02-08 17:37:09 +0000 | |||
198 | +++ metadata.yaml 2013-04-29 20:44:30 +0000 | |||
199 | @@ -11,3 +11,5 @@ | |||
200 | 11 | container: | 11 | container: |
201 | 12 | interface: juju-info | 12 | interface: juju-info |
202 | 13 | scope: container | 13 | scope: container |
203 | 14 | registration: | ||
204 | 15 | interface: http | ||
205 | 14 | 16 | ||
206 | === modified file 'revision' | |||
207 | --- revision 2013-03-07 20:22:30 +0000 | |||
208 | +++ revision 2013-04-29 20:44:30 +0000 | |||
209 | @@ -1,1 +1,1 @@ | |||
211 | 1 | 9 | 1 | 10 |
212 | 2 | 2 | ||
213 | === added directory 'tests' | |||
214 | === added file 'tests/001_install.test' | |||
215 | --- tests/001_install.test 1970-01-01 00:00:00 +0000 | |||
216 | +++ tests/001_install.test 2013-04-29 20:44:30 +0000 | |||
217 | @@ -0,0 +1,95 @@ | |||
218 | 1 | #!/bin/bash -eu | ||
219 | 2 | |||
220 | 3 | source lib/test-helpers.sh | ||
221 | 4 | |||
222 | 5 | test_setup() { | ||
223 | 6 | echo "INFO: Setup Test Environment" | ||
224 | 7 | juju deploy ubuntu | ||
225 | 8 | juju deploy --repository . local:landscape-client | ||
226 | 9 | juju add-relation ubuntu landscape-client | ||
227 | 10 | } | ||
228 | 11 | |||
229 | 12 | teardown() { | ||
230 | 13 | echo "INFO: Starting Teardown" | ||
231 | 14 | juju destroy-service ubuntu || /bin/true | ||
232 | 15 | juju destroy-service landscape-client || /bin/true | ||
233 | 16 | } | ||
234 | 17 | |||
235 | 18 | assert_command_on_unit() { | ||
236 | 19 | # Assert the command succeeds on the unit | ||
237 | 20 | # $1 = unit to contact | ||
238 | 21 | # $2 = command | ||
239 | 22 | if ! juju ssh $1 "$2"; then | ||
240 | 23 | error "CMD: $2 failed in $(diagnose)" | ||
241 | 24 | exit 1 | ||
242 | 25 | fi | ||
243 | 26 | } | ||
244 | 27 | |||
245 | 28 | run_command_on_unit() { | ||
246 | 29 | juju ssh $1 "$2" | ||
247 | 30 | } | ||
248 | 31 | |||
249 | 32 | assert_config() { | ||
250 | 33 | # $1 = config | ||
251 | 34 | # $2 and on = list of strings to run through egrep | ||
252 | 35 | config=$1 | ||
253 | 36 | shift | ||
254 | 37 | while [ $# -gt 0 ]; do | ||
255 | 38 | if ! echo "$config" | egrep "$1"; then | ||
256 | 39 | error "Config incorrect or missing: $1\n$(diagnose)" | ||
257 | 40 | exit 1 | ||
258 | 41 | fi | ||
259 | 42 | shift | ||
260 | 43 | done | ||
261 | 44 | } | ||
262 | 45 | |||
263 | 46 | |||
264 | 47 | start-test "landscape-client add relation verify deploy" | ||
265 | 48 | |||
266 | 49 | teardown | ||
267 | 50 | test_setup | ||
268 | 51 | |||
269 | 52 | # Ensure ubuntu started, and landscape-client is related without error | ||
270 | 53 | jitsu watch --failfast \ | ||
271 | 54 | ubuntu --state=started -r "ubuntu landscape-client" \ | ||
272 | 55 | landscape-client --state=started | ||
273 | 56 | |||
274 | 57 | |||
275 | 58 | # Ensure all ubuntu service units look as expected (unregistered) | ||
276 | 59 | for i in $(jitsu get-service-info ubuntu public-address); do | ||
277 | 60 | unit=$(echo $i | cut -d: -f1) | ||
278 | 61 | host=$(echo $i | cut -d: -f2) | ||
279 | 62 | assert_command_on_unit $unit "ps -ef | grep -v /usr/bin/landscape-client" | ||
280 | 63 | assert_command_on_unit $unit "test -e /etc/landscape/client.conf" | ||
281 | 64 | assert_command_on_unit $unit "sudo cat /etc/landscape/client.conf" | ||
282 | 65 | assert_command_on_unit $unit "sudo grep computer_title /etc/landscape/client.conf | grep $unit" | ||
283 | 66 | done | ||
284 | 67 | |||
285 | 68 | # Set appropriate config for testing | ||
286 | 69 | juju set --config lib/test-config.yaml landscape-client | ||
287 | 70 | |||
288 | 71 | # We expect error since we aren't actually going to register the client | ||
289 | 72 | jitsu watch \ | ||
290 | 73 | landscape-client --state=configure-error | ||
291 | 74 | |||
292 | 75 | # Ensure all ubuntu service units look as expected (registration-attempt) | ||
293 | 76 | for i in $(jitsu get-service-info ubuntu public-address); do | ||
294 | 77 | unit=$(echo $i | cut -d: -f1) | ||
295 | 78 | host=$(echo $i | cut -d: -f2) | ||
296 | 79 | assert_command_on_unit $unit "ps -ef | grep -v /usr/bin/landscape-client" | ||
297 | 80 | assert_command_on_unit $unit "test -e /etc/landscape/client.conf" | ||
298 | 81 | config=$(run_command_on_unit $unit "sudo cat /etc/landscape/client.conf") | ||
299 | 82 | assert_config "$config" \ | ||
300 | 83 | "ping_url = http://foo.example.com/ping" \ | ||
301 | 84 | "data_path = /var/lib/landscape/client" \ | ||
302 | 85 | "computer_title = $unit" \ | ||
303 | 86 | "tags = foo,bar,baz" \ | ||
304 | 87 | "registration_password = foo-registration-key" \ | ||
305 | 88 | "url = https://foo.example.com/message-system" \ | ||
306 | 89 | "include_manager_plugins = ScriptExecution" \ | ||
307 | 90 | "script_users = ALL" \ | ||
308 | 91 | "registration_key = foo-registration-key" \ | ||
309 | 92 | "account_name = foo-account-name" | ||
310 | 93 | done | ||
311 | 94 | |||
312 | 95 | end-test "Deployed Successfully" | ||
313 | 0 | 96 | ||
314 | === added file 'tests/Makefile' | |||
315 | --- tests/Makefile 1970-01-01 00:00:00 +0000 | |||
316 | +++ tests/Makefile 2013-04-29 20:44:30 +0000 | |||
317 | @@ -0,0 +1,8 @@ | |||
318 | 1 | build: | ||
319 | 2 | @mkdir -p precise | ||
320 | 3 | @test -e precise/landscape-client || ln -sf ../ precise/landscape-client | ||
321 | 4 | @echo "- Checking juju status, to make sure juju bootstrap has been done" | ||
322 | 5 | @juju status > /dev/null 2>/dev/null | ||
323 | 6 | |||
324 | 7 | test: | ||
325 | 8 | ./install-test | ||
326 | 0 | 9 | ||
327 | === added directory 'tests/lib' | |||
328 | === added file 'tests/lib/test-config.yaml' | |||
329 | --- tests/lib/test-config.yaml 1970-01-01 00:00:00 +0000 | |||
330 | +++ tests/lib/test-config.yaml 2013-04-29 20:44:30 +0000 | |||
331 | @@ -0,0 +1,8 @@ | |||
332 | 1 | landscape-client: | ||
333 | 2 | account-name: foo-account-name | ||
334 | 3 | registration-key: foo-registration-key | ||
335 | 4 | tags: foo,bar,baz | ||
336 | 5 | ping-url: http://foo.example.com/ping | ||
337 | 6 | url: https://foo.example.com/message-system | ||
338 | 7 | script-users: ALL | ||
339 | 8 | include-manager-plugins: ScriptExecution | ||
340 | 0 | 9 | ||
341 | === added file 'tests/lib/test-helpers.sh' | |||
342 | --- tests/lib/test-helpers.sh 1970-01-01 00:00:00 +0000 | |||
343 | +++ tests/lib/test-helpers.sh 2013-04-29 20:44:30 +0000 | |||
344 | @@ -0,0 +1,114 @@ | |||
345 | 1 | #!/bin/bash | ||
346 | 2 | |||
347 | 3 | set -eu | ||
348 | 4 | |||
349 | 5 | # Test setup | ||
350 | 6 | readonly TEST_NAME=$0 | ||
351 | 7 | |||
352 | 8 | # Test counts. Neither skips or errors are necessarily fatal. | ||
353 | 9 | SKIPS=0 | ||
354 | 10 | ERRORS=0 | ||
355 | 11 | UNHANDLED=0 | ||
356 | 12 | |||
357 | 13 | |||
358 | 14 | function info() { | ||
359 | 15 | echo "INFO: $@" | ||
360 | 16 | } | ||
361 | 17 | |||
362 | 18 | function ok() { | ||
363 | 19 | echo "PASS: $@" | ||
364 | 20 | } | ||
365 | 21 | |||
366 | 22 | function skip() { | ||
367 | 23 | echo "SKIP: $@" | ||
368 | 24 | (( SKIPS +=1 )) | ||
369 | 25 | } | ||
370 | 26 | |||
371 | 27 | function error() { | ||
372 | 28 | echo "FAIL: $@" | ||
373 | 29 | (( ERRORS += 1 )) | ||
374 | 30 | } | ||
375 | 31 | |||
376 | 32 | |||
377 | 33 | function start-test() { | ||
378 | 34 | readonly DATADIR=$(mktemp -d --tmpdir "${TEST_NAME}.XXXXXXX") | ||
379 | 35 | info "Executing ${TEST_NAME} with results in $DATADIR: $1" | ||
380 | 36 | setup | ||
381 | 37 | trap trapped-teardown EXIT TERM INT | ||
382 | 38 | } | ||
383 | 39 | |||
384 | 40 | function setup() { | ||
385 | 41 | # Empty, override in actual test as needed | ||
386 | 42 | true | ||
387 | 43 | } | ||
388 | 44 | |||
389 | 45 | |||
390 | 46 | function end-test() { | ||
391 | 47 | info "Completed test $TEST_NAME" | ||
392 | 48 | trap - EXIT | ||
393 | 49 | test-teardown | ||
394 | 50 | } | ||
395 | 51 | |||
396 | 52 | |||
397 | 53 | function teardown() { | ||
398 | 54 | # Empty, override in actual test as needed | ||
399 | 55 | true | ||
400 | 56 | } | ||
401 | 57 | |||
402 | 58 | |||
403 | 59 | function test-teardown() { | ||
404 | 60 | teardown | ||
405 | 61 | |||
406 | 62 | if [[ "$ERRORS" -gt 0 ]] ; then | ||
407 | 63 | TEST_RESULT=1 | ||
408 | 64 | elif [[ "$SKIPS" -gt 0 ]] ; then | ||
409 | 65 | TEST_RESULT=100 | ||
410 | 66 | touch $DATADIR/passed | ||
411 | 67 | else | ||
412 | 68 | TEST_RESULT=0 | ||
413 | 69 | touch $DATADIR/passed | ||
414 | 70 | fi | ||
415 | 71 | |||
416 | 72 | if [ -n "$DATADIR" ] ; then | ||
417 | 73 | if [ -f $DATADIR/passed ]; then | ||
418 | 74 | info "Passed test results for ${TEST_NAME} in ${DATADIR}, skips=${SKIPS}" | ||
419 | 75 | # rm -r $DATADIR | ||
420 | 76 | else | ||
421 | 77 | info "Failed test results for ${TEST_NAME} in ${DATADIR}, errors=${ERRORS}, skips=${SKIPS}" | ||
422 | 78 | if [ -f $DATADIR/wget.log ] ; then | ||
423 | 79 | info "BEGIN wget.log" | ||
424 | 80 | cat $DATADIR/wget.log | ||
425 | 81 | info "END wget.log" | ||
426 | 82 | fi | ||
427 | 83 | fi | ||
428 | 84 | fi | ||
429 | 85 | exit $TEST_RESULT | ||
430 | 86 | } | ||
431 | 87 | |||
432 | 88 | |||
433 | 89 | function diagnose() { | ||
434 | 90 | # Unpack the caller info to get some useful diagnostics for | ||
435 | 91 | # tracing any assertion issues | ||
436 | 92 | local data=( $(caller 1) ) | ||
437 | 93 | local lineno=${data[0]} | ||
438 | 94 | local function_name=${data[1]} | ||
439 | 95 | local script_name=${data[2]} | ||
440 | 96 | echo "function $function_name at line $lineno ($script_name)" | ||
441 | 97 | } | ||
442 | 98 | |||
443 | 99 | function trapped-teardown() { | ||
444 | 100 | (( UNHANDLED += 1 )) | ||
445 | 101 | error "Untrapped error in $(diagnose)" | ||
446 | 102 | test-teardown | ||
447 | 103 | } | ||
448 | 104 | |||
449 | 105 | function assert() { | ||
450 | 106 | # The assert function takes two args, such as: | ||
451 | 107 | # assert "what we are asserting" "non empty result passes" | ||
452 | 108 | # If the second arg is empty or undefined, the assertion fails | ||
453 | 109 | if [[ "$#" -lt 2 || -z "$2" ]] ; then | ||
454 | 110 | error "$1, assertion failed in $(diagnose)" | ||
455 | 111 | else | ||
456 | 112 | ok "$1" | ||
457 | 113 | fi | ||
458 | 114 | } | ||
459 | 0 | 115 | ||
460 | === added directory 'tests/precise' | |||
461 | === added symlink 'tests/precise/landscape-client' | |||
462 | === target is u'../..' | |||
463 | === added file 'tests/test.sh' | |||
464 | --- tests/test.sh 1970-01-01 00:00:00 +0000 | |||
465 | +++ tests/test.sh 2013-04-29 20:44:30 +0000 | |||
466 | @@ -0,0 +1,6 @@ | |||
467 | 1 | #!/bin/bash -e | ||
468 | 2 | |||
469 | 3 | DIR="$( cd "$( dirname "$0" )" && pwd )" | ||
470 | 4 | cd $DIR | ||
471 | 5 | |||
472 | 6 | run-parts -v --exit-on-error --regex '^.*\.test$' . |
Hi David, sorry it took so long to get around to this. So I'll be brief with the review. This LGTM! Thank you for supplying tests. I've got some more information for you below.
So, we're going to be dropping jitsu very soon as a lot of it isn't compatible with juju-core. I'm working on a real set of testing-helpers ("testing harness") that will replace jitsu-watch and test-helpers.sh with a more robust bash/python library. Keep an eye on the list for more information on that next week. I don't see it necessary to change what you have here but just be aware in the next few months as we move our automated testing environment from just pyjuju to both pyjuju + juju-core and eventually just juju-core that these tests will need to be amended.