VM: set recovery policy to restart

- Update proc to select restart policy for VM
 - Update testrelpol to test the supported modes of recovery for VM
 - Small code cleanups in testrelpol as well.

Change-Id: I6958e100865c2429b9435f3f7cc7d018046378c3
This commit is contained in:
Lionel Sambuc 2015-01-26 15:09:05 +01:00 committed by David van Moolenbroek
parent 95cb93971a
commit 8b0f8559ee
2 changed files with 67 additions and 38 deletions

View file

@ -130,7 +130,7 @@ service_get_policies(struct policies * pol, index_t slot)
{ .label = "rs", .policy_str = "restart" },
{ .label = "sched", .policy_str = "restart" },
{ .label = "vfs", .policy_str = "restart" },
{ .label = "vm", .policy_str = "" },
{ .label = "vm", .policy_str = "restart" },
//{ .label = "", .policy_str = "" },
};

View file

@ -69,6 +69,31 @@ wait_for_service() {
done
}
#######################################################################
# Service management routines
#######################################################################
prepare_service() {
local label service
service=$1
label=$2
flags=$(get_value flags ${service})
echo $flags | grep -q 'r' || return 0
echo $flags | grep -q 'R' && return 0
service clone $label
return 1
}
cleanup_service() {
local label
label=$1
service unclone $label
}
#######################################################################
# POLICY: restart
#######################################################################
@ -133,7 +158,7 @@ pol_reset() {
}
#######################################################################
# Live update test
# Live update tests
#######################################################################
lu_test_one() {
local label=$1
@ -146,7 +171,6 @@ lu_test_one() {
service ${lu_opts} update ${prog} -label ${label} -maxtime ${lu_maxtime} -state ${lu_state}
if [ $? -ne $result ]
then
echo not ok
return 1
else
return 0
@ -165,16 +189,32 @@ lu_test() {
endpoint_pre=$(get_value endpoint ${service})
lu_test_one ${label} self 0 || return
if ! echo "vm pm vfs rs" | grep -q ${label}
# Test live update "prepare only"
if ! echo "pm rs vfs vm" | grep -q ${label}
then
lu_opts="-o" lu_test_one ${label} self 0 || return
fi
# Test live update initialization crash
if ! echo "vm" | grep -q ${label}
then
lu_opts="-x" lu_test_one ${label} self 200 || return
if ! echo "rs" | grep -q ${label}
fi
# Test live update initialization failure
if ! echo "rs vm" | grep -q ${label}
then
lu_opts="-y" lu_test_one ${label} self 78 || return
fi
# Test live update initialization timeout
if ! echo "rs vm" | grep -q ${label}
then
lu_maxtime="1HZ" lu_opts="-z" lu_test_one ${label} self 4 || return
fi
# Test live update from SEF_LU_STATE_EVAL state
lu_maxtime="1HZ" lu_state="5" lu_test_one ${label} self 4 || return
restarts_post=$(get_value restarts ${service})
@ -196,7 +236,8 @@ multi_lu_test_one() {
local labels="$*"
local ret=0
local index=0
local once_index=1
local once_index=2
local force_unsafe=""
lu_opts=${lu_opts:-}
lu_maxtime=${lu_maxtime:-3HZ}
@ -207,13 +248,26 @@ multi_lu_test_one() {
for label in ${labels}
do
index=`expr $index + 1`
force_unsafe=""
if [ "x$label" = "xvm" ]
then
# VM doesn't support safe LU, nor rollbacks for now
force_unsafe="-u"
if echo "${lu_opts_once}" | grep -q -E -- '-(x|y|z)'
then
continue
fi
fi
if [ $index -eq $once_index ]
then
service ${lu_opts_once} -q update self -label ${label} -maxtime ${lu_maxtime_once} -state ${lu_state_once} || ret=1
service ${lu_opts_once} ${force_unsafe} -q update self -label ${label} -maxtime ${lu_maxtime_once} -state ${lu_state_once} || ret=1
else
service ${lu_opts} -q update self -label ${label} -maxtime ${lu_maxtime} -state ${lu_state} || ret=1
service ${lu_opts} ${force_unsafe} -q update self -label ${label} -maxtime ${lu_maxtime} -state ${lu_state} || ret=1
fi
index=`expr $index + 1`
done
service sysctl upd_run
if [ $? -ne $result ]
@ -239,31 +293,6 @@ multi_lu_test() {
echo ok
}
#######################################################################
# Service management routines
#######################################################################
prepare_service() {
local label service
service=$1
label=$2
flags=$(get_value flags ${service})
echo $flags | grep -q 'r' || return 0
echo $flags | grep -q 'R' && return 0
service clone $label
return 1
}
cleanup_service() {
local label
label=$1
service unclone $label
}
#######################################################################
# main()
#######################################################################