3
source lib/test-helpers.sh
6
echo "INFO: Setup Test Environment"
8
juju deploy --repository . local:landscape-client
9
juju add-relation ubuntu landscape-client
13
echo "INFO: Starting Teardown"
14
juju destroy-service ubuntu || /bin/true
15
juju destroy-service landscape-client || /bin/true
18
assert_command_on_unit() {
19
# Assert the command succeeds on the unit
20
# $1 = unit to contact
22
if ! juju ssh $1 "$2"; then
23
error "CMD: $2 failed in $(diagnose)"
28
run_command_on_unit() {
34
# $2 and on = list of strings to run through egrep
37
while [ $# -gt 0 ]; do
38
if ! echo "$config" | egrep "$1"; then
39
error "Config incorrect or missing: $1\n$(diagnose)"
47
start-test "landscape-client add relation verify deploy"
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
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"
68
# Set appropriate config for testing
69
juju set --config lib/test-config.yaml landscape-client
71
# We expect error since we aren't actually going to register the client
73
landscape-client --state=configure-error
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"
95
end-test "Deployed Successfully"