~dpb/charms/precise/landscape-client/1273788-change-relation-interface

« back to all changes in this revision

Viewing changes to tests/001_install.test

  • Committer: Marco Ceppi
  • Date: 2013-05-29 22:01:20 UTC
  • mfrom: (19.3.11 landscape-client)
  • Revision ID: marco@ceppi.net-20130529220120-5attgp6hl5e6i60j
add-landscape-relation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash -eu
 
2
 
 
3
source lib/test-helpers.sh
 
4
 
 
5
test_setup() {
 
6
    echo "INFO: Setup Test Environment"
 
7
    juju deploy ubuntu
 
8
    juju deploy --repository . local:landscape-client
 
9
    juju add-relation ubuntu landscape-client
 
10
}
 
11
 
 
12
teardown() {
 
13
    echo "INFO: Starting Teardown"
 
14
    juju destroy-service ubuntu || /bin/true
 
15
    juju destroy-service landscape-client || /bin/true
 
16
}
 
17
 
 
18
assert_command_on_unit() {
 
19
    # Assert the command succeeds on the unit
 
20
    # $1 = unit to contact
 
21
    # $2 = command
 
22
    if ! juju ssh $1 "$2"; then
 
23
        error "CMD: $2 failed in $(diagnose)"
 
24
        exit 1
 
25
    fi
 
26
}
 
27
 
 
28
run_command_on_unit() {
 
29
    juju ssh $1 "$2"
 
30
}
 
31
 
 
32
assert_config() {
 
33
    # $1 = config
 
34
    # $2 and on = list of strings to run through egrep
 
35
    config=$1
 
36
    shift
 
37
    while [ $# -gt 0 ]; do
 
38
        if ! echo "$config" | egrep "$1"; then
 
39
            error "Config incorrect or missing: $1\n$(diagnose)"
 
40
            exit 1
 
41
        fi
 
42
        shift
 
43
    done
 
44
}
 
45
 
 
46
 
 
47
start-test "landscape-client add relation verify deploy"
 
48
 
 
49
teardown
 
50
test_setup
 
51
 
 
52
# Ensure ubuntu started, and landscape-client is related without error
 
53
jitsu watch --failfast \
 
54
    ubuntu --state=started -r "ubuntu landscape-client" \
 
55
    landscape-client --state=started
 
56
 
 
57
 
 
58
# Ensure all ubuntu service units look as expected (unregistered)
 
59
for i in $(jitsu get-service-info ubuntu public-address); do
 
60
    unit=$(echo $i | cut -d: -f1)
 
61
    host=$(echo $i | cut -d: -f2)
 
62
    assert_command_on_unit $unit "ps -ef | grep -v /usr/bin/landscape-client"
 
63
    assert_command_on_unit $unit "test -e /etc/landscape/client.conf"
 
64
    assert_command_on_unit $unit "sudo cat /etc/landscape/client.conf"
 
65
    assert_command_on_unit $unit "sudo grep computer_title /etc/landscape/client.conf | grep $unit"
 
66
done
 
67
 
 
68
# Set appropriate config for testing
 
69
juju set --config lib/test-config.yaml landscape-client
 
70
 
 
71
# We expect error since we aren't actually going to register the client
 
72
jitsu watch \
 
73
    landscape-client --state=configure-error
 
74
 
 
75
# Ensure all ubuntu service units look as expected (registration-attempt)
 
76
for i in $(jitsu get-service-info ubuntu public-address); do
 
77
    unit=$(echo $i | cut -d: -f1)
 
78
    host=$(echo $i | cut -d: -f2)
 
79
    assert_command_on_unit $unit "ps -ef | grep -v /usr/bin/landscape-client"
 
80
    assert_command_on_unit $unit "test -e /etc/landscape/client.conf"
 
81
    config=$(run_command_on_unit $unit "sudo cat /etc/landscape/client.conf")
 
82
    assert_config "$config" \
 
83
        "ping_url = http://foo.example.com/ping" \
 
84
        "data_path = /var/lib/landscape/client" \
 
85
        "computer_title = $unit" \
 
86
        "tags = foo,bar,baz" \
 
87
        "registration_password = foo-registration-key" \
 
88
        "url = https://foo.example.com/message-system" \
 
89
        "include_manager_plugins = ScriptExecution" \
 
90
        "script_users = ALL" \
 
91
        "registration_key = foo-registration-key" \
 
92
        "account_name = foo-account-name"
 
93
done
 
94
 
 
95
end-test "Deployed Successfully"