|
|
e7e33b |
From b565fb6402af40789762ee281baf2b074c1532e1 Mon Sep 17 00:00:00 2001
|
|
|
e7e33b |
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
|
|
|
e7e33b |
Date: Fri, 27 May 2016 23:17:32 +0200
|
|
|
e7e33b |
Subject: [PATCH 4/4] test: live_test: offer alternatives to crm (pcs + native)
|
|
|
e7e33b |
|
|
|
e7e33b |
Note that existing use of crm_ticket can be eventually also extended
|
|
|
e7e33b |
with higher-level CLI tool usage, following the same pattern.
|
|
|
e7e33b |
---
|
|
|
e7e33b |
test/live_test.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++------
|
|
|
e7e33b |
1 file changed, 55 insertions(+), 6 deletions(-)
|
|
|
e7e33b |
|
|
|
e7e33b |
diff --git a/test/live_test.sh b/test/live_test.sh
|
|
|
e7e33b |
index 5ee918e..b7f27eb 100755
|
|
|
e7e33b |
--- a/test/live_test.sh
|
|
|
e7e33b |
+++ b/test/live_test.sh
|
|
|
e7e33b |
@@ -50,6 +50,9 @@ logf=test_booth.log
|
|
|
e7e33b |
SSH_OPTS="-o StrictHostKeyChecking=no -l root"
|
|
|
e7e33b |
iprules=/usr/share/booth/tests/test/booth_path
|
|
|
e7e33b |
: ${HA_LOGFACILITY:="syslog"}
|
|
|
e7e33b |
+cli_driver=native
|
|
|
e7e33b |
+which crm >/dev/null 2>&1 && cli_driver=crm || :
|
|
|
e7e33b |
+which pcs >/dev/null 2>&1 && cli_driver=pcs || :
|
|
|
e7e33b |
|
|
|
e7e33b |
get_site() {
|
|
|
e7e33b |
local n=$1
|
|
|
e7e33b |
@@ -159,7 +162,26 @@ runcmd() {
|
|
|
e7e33b |
return $rc
|
|
|
e7e33b |
}
|
|
|
e7e33b |
manage_site() {
|
|
|
e7e33b |
- runcmd $1 crm -w resource $2 booth
|
|
|
e7e33b |
+ local action=$2 resource=booth cmd
|
|
|
e7e33b |
+ case "$action" in
|
|
|
e7e33b |
+ start)
|
|
|
e7e33b |
+ case "$cli_driver" in
|
|
|
e7e33b |
+ native) action=Started;;
|
|
|
e7e33b |
+ pcs) action=enable;;
|
|
|
e7e33b |
+ esac;;
|
|
|
e7e33b |
+ stop)
|
|
|
e7e33b |
+ case "$cli_driver" in
|
|
|
e7e33b |
+ native) action=Stopped;;
|
|
|
e7e33b |
+ pcs) action=disable;;
|
|
|
e7e33b |
+ esac;;
|
|
|
e7e33b |
+ esac
|
|
|
e7e33b |
+
|
|
|
e7e33b |
+ case "$cli_driver" in
|
|
|
e7e33b |
+ native) cmd="crm_resource --wait --resource \"$resource\" --set-parameter target-role --meta --parameter-value \"$action\"";;
|
|
|
e7e33b |
+ crm) cmd="crm -w resource \"$action\" \"$resource\"";;
|
|
|
e7e33b |
+ pcs) cmd="pcs resource \"$action\" \"$resource\" --wait";;
|
|
|
e7e33b |
+ esac
|
|
|
e7e33b |
+ runcmd $1 $cmd
|
|
|
e7e33b |
}
|
|
|
e7e33b |
manage_arbitrator() {
|
|
|
e7e33b |
if ps 1 | grep -qws systemd; then
|
|
|
e7e33b |
@@ -211,9 +233,15 @@ cleanup_booth() {
|
|
|
e7e33b |
cleanup_dep_rsc() {
|
|
|
e7e33b |
local dep_rsc=`get_rsc`
|
|
|
e7e33b |
test -z "$dep_rsc" && return
|
|
|
e7e33b |
- local h procs
|
|
|
e7e33b |
+ local cmd h procs
|
|
|
e7e33b |
+ case "$cli_driver" in
|
|
|
e7e33b |
+ native) cmd="crm_resource --cleanup --resource \"$dep_rsc\"; crm_resource --wait";;
|
|
|
e7e33b |
+ crm) cmd="crm -w resource cleanup \"$dep_rsc\"";;
|
|
|
e7e33b |
+ # XXX pcs does not support --wait here?
|
|
|
e7e33b |
+ pcs) cmd="pcs resource cleanup \"$dep_rsc\"; crm_resource --wait";;
|
|
|
e7e33b |
+ esac
|
|
|
e7e33b |
for h in $sites; do
|
|
|
e7e33b |
- runcmd $h crm -w resource cleanup $dep_rsc & procs="$! $procs"
|
|
|
e7e33b |
+ runcmd $h $cmd & procs="$! $procs"
|
|
|
e7e33b |
done >/dev/null 2>&1
|
|
|
e7e33b |
wait $procs
|
|
|
e7e33b |
}
|
|
|
e7e33b |
@@ -412,13 +440,34 @@ del_site_attr() {
|
|
|
e7e33b |
run_site $site geostore delete $1
|
|
|
e7e33b |
}
|
|
|
e7e33b |
break_external_prog() {
|
|
|
e7e33b |
- run_site $1 crm configure "location $PREFNAME `get_rsc` rule -inf: defined \#uname"
|
|
|
e7e33b |
+ local cmd
|
|
|
e7e33b |
+ case "$cli_driver" in
|
|
|
e7e33b |
+ native) cmd="cibadmin --create --scope constraints --xml-text=\""
|
|
|
e7e33b |
+ cmd="$cmd<rsc_location id='$PREFNAME' rsc='`get_rsc`'><rule id='rule_$PREFNAME' score='-INFINITY'>"
|
|
|
e7e33b |
+ cmd="$cmd<expression id='expr_$PREFNAME' attribute='#uname' operation='define'/>"
|
|
|
e7e33b |
+ cmd="$cmd</rule></rsc_location>\"";;
|
|
|
e7e33b |
+ crm) cmd="crm configure \"location $PREFNAME `get_rsc` rule -inf: defined \#uname\"";;
|
|
|
e7e33b |
+ pcs) cmd="pcs constraint location `get_rsc` rule id=$PREFNAME score=-INFINITY defined \#uname";;
|
|
|
e7e33b |
+ esac
|
|
|
e7e33b |
+ runcmd $1 $cmd
|
|
|
e7e33b |
}
|
|
|
e7e33b |
show_pref() {
|
|
|
e7e33b |
- run_site $1 crm configure show $PREFNAME > /dev/null
|
|
|
e7e33b |
+ local cmd
|
|
|
e7e33b |
+ case "$cli_driver" in
|
|
|
e7e33b |
+ native) cmd="cibadmin --query --xpath \"//rsc_location[@id = '$PREFNAME']\"";;
|
|
|
e7e33b |
+ crm) cmd="crm configure show $PREFNAME > /dev/null";;
|
|
|
e7e33b |
+ pcs) cmd="pcs constraint show --full | grep -q $PREFNAME";;
|
|
|
e7e33b |
+ esac
|
|
|
e7e33b |
+ runcmd $1 $cmd
|
|
|
e7e33b |
}
|
|
|
e7e33b |
repair_external_prog() {
|
|
|
e7e33b |
- run_site $1 crm configure delete $PREFNAME
|
|
|
e7e33b |
+ local cmd
|
|
|
e7e33b |
+ case "$cli_driver" in
|
|
|
e7e33b |
+ native) cmd="cibadmin --delete --xpath \"//rsc_location[@id = '$PREFNAME']\"";;
|
|
|
e7e33b |
+ crm) cmd="crm configure delete $PREFNAME";;
|
|
|
e7e33b |
+ pcs) cmd="pcs constraint remove $PREFNAME";;
|
|
|
e7e33b |
+ esac
|
|
|
e7e33b |
+ runcmd $1 $cmd
|
|
|
e7e33b |
}
|
|
|
e7e33b |
get_tkt() {
|
|
|
e7e33b |
grep "^ticket=" | head -1 | sed 's/ticket=//;s/"//g'
|
|
|
e7e33b |
--
|
|
|
e7e33b |
2.4.11
|
|
|
e7e33b |
|