~landscape/charms/xenial/mongodb/trunk

« back to all changes in this revision

Viewing changes to tests/100_configs.test

  • Committer: Tim Van Steenburgh
  • Date: 2014-11-20 14:55:49 UTC
  • mfrom: (53.5.5 mongodb)
  • Revision ID: tim.van.steenburgh@canonical.com-20141120145549-m287c75a35r7w8f2
Refactor tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
 
3
 
set -e
4
 
 
5
 
teardown() {
6
 
    juju destroy-service mongodb
7
 
}
8
 
trap teardown EXIT
9
 
 
10
 
juju deploy mongodb
11
 
juju expose mongodb
12
 
 
13
 
for try in `seq 1 600` ; do
14
 
    host=`juju status | tests/get-unit-info mongodb public-address`
15
 
    
16
 
    if [ -z "$host" ] ; then
17
 
        sleep 10
18
 
    else
19
 
        break
20
 
    fi
21
 
done
22
 
 
23
 
if [ -z "$host" ] ; then
24
 
    echo FAIL: host timed out
25
 
    exit 1
26
 
fi
27
 
 
28
 
assert_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
 
 
45
 
assert_is_listening() {
46
 
    local port=$1
47
 
    tries=$2 
48
 
    listening=""
49
 
    for try in `seq 1 $tries` ; do
50
 
        if ! nc $host $port < /dev/null ; then
51
 
            continue
52
 
        fi
53
 
        listening="27017"
54
 
        break
55
 
    done
56
 
 
57
 
    if [ -z "$listening" ] ; then
58
 
       echo "FAIL: not listening on port $port after $tries retries"
59
 
       return 1
60
 
    else
61
 
       echo "PASS: listening on port $port"
62
 
       return 0
63
 
    fi
64
 
}
65
 
 
66
 
assert_unit_ready
67
 
 
68
 
assert_is_listening 27017 10
69
 
 
70
 
juju set mongodb port=55555
71
 
assert_is_listening 55555 200000
72
 
echo PASS: config changes tests passed.
73
 
exit 0