Merge lp:~abentley/juju-ci-tools/reproduce-1680936 into lp:juju-ci-tools

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 1987
Proposed branch: lp:~abentley/juju-ci-tools/reproduce-1680936
Merge into: lp:juju-ci-tools
Diff against target: 52 lines (+47/-0)
1 file modified
reproduction-scripts/containers_and_units.bash (+47/-0)
To merge this branch: bzr merge lp:~abentley/juju-ci-tools/reproduce-1680936
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+322225@code.launchpad.net

Commit message

Add reproduction script for bug #1680936.

Description of the change

This branch provides a reproduction script for bug #1680936.

It serves as an example for future reproduction scripts.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'reproduction-scripts'
2=== added file 'reproduction-scripts/containers_and_units.bash'
3--- reproduction-scripts/containers_and_units.bash 1970-01-01 00:00:00 +0000
4+++ reproduction-scripts/containers_and_units.bash 2017-04-07 19:16:59 +0000
5@@ -0,0 +1,47 @@
6+#!/bin/bash
7+# This script reproduces bug #1680936. It assumes a blank model. It:
8+# - deploys ubuntu (to machine 0)
9+# - adds a container to machine 0
10+# - removes the container from machine 0
11+# - optionally waits for the container to be removed from status
12+# - removes ubuntu/0
13+# If machine 0 is removed, it succeeds. If machine 0 is still there after 5
14+# minutes, it fails.
15+set -eux
16+
17+function wait_for_null(){
18+ deadline="$(($(date +"%s") + 300))"
19+ set +x
20+ while [ $(date +"%s") -lt $deadline ]; do
21+ if [ "$(juju status --format json|jq $1)" == "null" ]; then
22+ echo
23+ echo "Query $1 went null."
24+ return 0
25+ fi
26+ echo -n '.'
27+ sleep 1
28+ done
29+ echo
30+ set +x
31+ return 1
32+}
33+
34+juju deploy ubuntu
35+# Machine doesn't appear instantly
36+sleep 1
37+juju add-machine lxd:0
38+juju remove-machine 0/lxd/0
39+echo "Waiting for removal of machine 0/lxd/0"
40+if [ ${WAIT_LXD-false} == "true" ]; then
41+ wait_for_null '.machines."0".containers."0/lxd/0"'
42+fi
43+juju remove-unit ubuntu/0
44+echo "Waiting for removal of machine 0."
45+if wait_for_null '.machines."0"'; then
46+ echo "SUCCESS: machine 0 was removed."
47+ exit 0
48+else
49+ echo "FAILURE: machine 0 was not removed."
50+ juju status
51+ exit 1
52+fi

Subscribers

People subscribed via source and target branches