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
=== added file 'tests/00-setup'
--- tests/00-setup 1970-01-01 00:00:00 +0000
+++ tests/00-setup 2014-02-25 21:52:13 +0000
@@ -0,0 +1,11 @@
1#!/bin/bash
2
3sudo apt-get install python-setuptools -y
4
5if [ -f '/etc/apt.d/sources.list.d/juju-stable-precise.list' ]; then
6 sudo add-apt-repository ppa:juju/stable -y
7fi
8
9sudo apt-get update
10
11sudo apt-get install amulet python3 python3-requests python3-pymongo juju-core charm-tools python-mock -y
012
=== removed file 'tests/00_setup.sh'
--- tests/00_setup.sh 2014-01-28 21:51:49 +0000
+++ tests/00_setup.sh 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
1#!/bin/bash
2
3sudo apt-get install python-setuptools -y
4
5if [ -f '/etc/apt.d/sources.list.d/juju-stable-precise.list' ]; then
6 sudo add-apt-repository ppa:juju/stable -y
7fi
8
9sudo apt-get update
10
11sudo apt-get install amulet python3 python3-requests python3-pymongo juju-core charm-tools -y
120
=== modified file 'tests/100_configs.test'
--- tests/100_configs.test 2012-01-31 01:19:12 +0000
+++ tests/100_configs.test 2014-02-25 21:52:13 +0000
@@ -12,22 +12,41 @@
1212
13for try in `seq 1 600` ; do13for try in `seq 1 600` ; do
14 host=`juju status | tests/get-unit-info mongodb public-address`14 host=`juju status | tests/get-unit-info mongodb public-address`
15
15 if [ -z "$host" ] ; then16 if [ -z "$host" ] ; then
16 sleep 117 sleep 10
17 else18 else
18 break19 break
19 fi20 fi
20done21done
2122
22if [ -z "$host" ] ; then23if [ -z "$host" ] ; then
23 echo FAIL: status timed out24 echo FAIL: host timed out
24 exit 125 exit 1
25fi26fi
2627
28assert_unit_ready() {
29 for try in `seq 1 600` ; do
30 status=`juju status | tests/get-unit-info mongodb agent-state`
31 if [ "$status" != "started" ] ; then
32 sleep 10
33 else
34 echo "found status as $status"
35 break
36 fi
37 done
38
39 if [ -z "$status" ] ; then
40 echo FAIL: status timed out
41 exit 1
42 fi
43}
44
27assert_is_listening() {45assert_is_listening() {
28 local port=$146 local port=$1
47 tries=$2
29 listening=""48 listening=""
30 for try in `seq 1 10` ; do49 for try in `seq 1 $tries` ; do
31 if ! nc $host $port < /dev/null ; then50 if ! nc $host $port < /dev/null ; then
32 continue51 continue
33 fi52 fi
@@ -36,18 +55,19 @@
36 done55 done
3756
38 if [ -z "$listening" ] ; then57 if [ -z "$listening" ] ; then
39 echo "FAIL: not listening on port 27017 after 10 retries"58 echo "FAIL: not listening on port $port after $tries retries"
40 return 159 return 1
41 else60 else
42 echo "PASS: listening on port 27017"61 echo "PASS: listening on port $port"
43 return 062 return 0
44 fi63 fi
45}64}
4665
47assert_is_listening 2701766assert_unit_ready
4867
49juju set mongodb default_port=5555568assert_is_listening 27017 10
5069
51assert_is_listening 5555570juju set mongodb port=55555
71assert_is_listening 55555 200000
52echo PASS: config changes tests passed.72echo PASS: config changes tests passed.
53exit 073exit 0

Subscribers

People subscribed via source and target branches