Merge lp:~lazypower/charms/precise/mongodb/ci-fix into lp:charms/mongodb

Proposed by Charles Butler
Status: Merged
Merged at revision: 43
Proposed branch: lp:~lazypower/charms/precise/mongodb/ci-fix
Merge into: lp:charms/mongodb
Diff against target: 107 lines (+41/-21)
3 files modified
tests/00-setup (+11/-0)
tests/00_setup.sh (+0/-11)
tests/100_configs.test (+30/-10)
To merge this branch: bzr merge lp:~lazypower/charms/precise/mongodb/ci-fix
Reviewer Review Type Date Requested Status
Juan L. Negron (community) Approve
Review via email: mp+208235@code.launchpad.net

Description of the change

Refactored tests for CI

Altered test_configs to correct non-time-wait context for mongodb to setup -
which on average takes approx 5 to 6 minutes on Local provider. Moved 00_setup
to 00-setup to comply with nomenclature from charm add tests

To post a comment you must log in.
Revision history for this message
Charles Butler (lazypower) wrote :

Please take a look.

Revision history for this message
Juan L. Negron (negronjl) wrote :

Hi Charles:

Thanks for the MP. It looks good to me ... merging it.

-Juan

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'tests/00-setup'
2--- tests/00-setup 1970-01-01 00:00:00 +0000
3+++ tests/00-setup 2014-02-25 21:52:13 +0000
4@@ -0,0 +1,11 @@
5+#!/bin/bash
6+
7+sudo apt-get install python-setuptools -y
8+
9+if [ -f '/etc/apt.d/sources.list.d/juju-stable-precise.list' ]; then
10+ sudo add-apt-repository ppa:juju/stable -y
11+fi
12+
13+sudo apt-get update
14+
15+sudo apt-get install amulet python3 python3-requests python3-pymongo juju-core charm-tools python-mock -y
16
17=== removed file 'tests/00_setup.sh'
18--- tests/00_setup.sh 2014-01-28 21:51:49 +0000
19+++ tests/00_setup.sh 1970-01-01 00:00:00 +0000
20@@ -1,11 +0,0 @@
21-#!/bin/bash
22-
23-sudo apt-get install python-setuptools -y
24-
25-if [ -f '/etc/apt.d/sources.list.d/juju-stable-precise.list' ]; then
26- sudo add-apt-repository ppa:juju/stable -y
27-fi
28-
29-sudo apt-get update
30-
31-sudo apt-get install amulet python3 python3-requests python3-pymongo juju-core charm-tools -y
32
33=== modified file 'tests/100_configs.test'
34--- tests/100_configs.test 2012-01-31 01:19:12 +0000
35+++ tests/100_configs.test 2014-02-25 21:52:13 +0000
36@@ -12,22 +12,41 @@
37
38 for try in `seq 1 600` ; do
39 host=`juju status | tests/get-unit-info mongodb public-address`
40+
41 if [ -z "$host" ] ; then
42- sleep 1
43+ sleep 10
44 else
45 break
46 fi
47 done
48
49 if [ -z "$host" ] ; then
50- echo FAIL: status timed out
51+ echo FAIL: host timed out
52 exit 1
53 fi
54
55+assert_unit_ready() {
56+ for try in `seq 1 600` ; do
57+ status=`juju status | tests/get-unit-info mongodb agent-state`
58+ if [ "$status" != "started" ] ; then
59+ sleep 10
60+ else
61+ echo "found status as $status"
62+ break
63+ fi
64+ done
65+
66+ if [ -z "$status" ] ; then
67+ echo FAIL: status timed out
68+ exit 1
69+ fi
70+}
71+
72 assert_is_listening() {
73 local port=$1
74+ tries=$2
75 listening=""
76- for try in `seq 1 10` ; do
77+ for try in `seq 1 $tries` ; do
78 if ! nc $host $port < /dev/null ; then
79 continue
80 fi
81@@ -36,18 +55,19 @@
82 done
83
84 if [ -z "$listening" ] ; then
85- echo "FAIL: not listening on port 27017 after 10 retries"
86+ echo "FAIL: not listening on port $port after $tries retries"
87 return 1
88 else
89- echo "PASS: listening on port 27017"
90+ echo "PASS: listening on port $port"
91 return 0
92 fi
93 }
94
95-assert_is_listening 27017
96-
97-juju set mongodb default_port=55555
98-
99-assert_is_listening 55555
100+assert_unit_ready
101+
102+assert_is_listening 27017 10
103+
104+juju set mongodb port=55555
105+assert_is_listening 55555 200000
106 echo PASS: config changes tests passed.
107 exit 0

Subscribers

People subscribed via source and target branches