| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
start_service() { |
| 6 |
name=$1 |
| 7 |
if ! service $name start; then |
| 8 |
set +e |
| 9 |
service $name status |
| 10 |
if [ -x /bin/journalctl ]; then |
| 11 |
journalctl -b -u $name |
| 12 |
elif [ -f /var/log/syslog ]; then |
| 13 |
grep $name /var/log/syslog |
| 14 |
fi |
| 15 |
exit 1 |
| 16 |
fi |
| 17 |
} |
| 18 |
|
| 19 |
crm_status_wait() { |
| 20 |
match=$1 |
| 21 |
log=$AUTOPKGTEST_TMP/crm.status |
| 22 |
n=0 |
| 23 |
printf "Waiting for '$match':" |
| 24 |
while ! crm status | tee $log | grep -q "$match"; do |
| 25 |
if [ "$n" -eq 120 ]; then |
| 26 |
printf " failed.\n" |
| 27 |
cat $log |
| 28 |
return 1 |
| 29 |
fi |
| 30 |
sleep 1 |
| 31 |
n=$((n+1)) |
| 32 |
printf " $n" |
| 33 |
done |
| 34 |
printf " done.\n" |
| 35 |
} |
| 36 |
|
| 37 |
printf "=== keygen ===\n" |
| 38 |
booth-keygen |
| 39 |
cat <<EOF | tee /etc/booth/booth.conf |
| 40 |
authfile = /etc/booth/authkey |
| 41 |
site = 127.0.0.1 |
| 42 |
ticket = "ticket-A" |
| 43 |
EOF |
| 44 |
|
| 45 |
printf "\n=== cluster ===\n" |
| 46 |
start_service corosync |
| 47 |
start_service pacemaker |
| 48 |
crm_status_wait 'Online:.*node1' |
| 49 |
|
| 50 |
printf "\n=== configure ===\n" |
| 51 |
crm configure property stonith-enabled=false 2>&1 |
| 52 |
crm configure property no-quorum-policy=ignore 2>&1 |
| 53 |
crm configure primitive booth ocf:pacemaker:booth-site \ |
| 54 |
op start timeout=100s 2>&1 |
| 55 |
crm configure primitive dummy ocf:heartbeat:Dummy 2>&1 |
| 56 |
crm configure rsc_ticket ticket-A_dummy ticket-A: dummy 2>&1 |
| 57 |
crm configure show |
| 58 |
crm_status_wait 'booth.*Started' |
| 59 |
crm status |
| 60 |
|
| 61 |
printf "\n=== booth ===\n" |
| 62 |
booth status |
| 63 |
booth list |
| 64 |
|
| 65 |
printf "\n=== grant ===\n" |
| 66 |
crm --force site ticket grant ticket-A |
| 67 |
crm_status_wait 'dummy.*Started' |
| 68 |
crm site ticket show ticket-A |
| 69 |
|
| 70 |
printf "\n=== revoke ===\n" |
| 71 |
crm site ticket standby ticket-A |
| 72 |
crm_status_wait 'dummy.*Stopped' |
| 73 |
crm --force site ticket revoke ticket-A |
| 74 |
crm site ticket show ticket-A |