From 6a5963882db22e7516b666b651247e0090767e30 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Fri, 10 Jul 2015 10:46:39 +0200 Subject: [PATCH] LU-6356 tests: fix sanity-krb5 test_151 is updated because it was relying on the fact that a target cannot start if it cannot reaches MGS, which is no longer the case. Now start the target, and look at import state of the mgc connection, thanks to the newly added wait_mgc_import_state() routine in the test framework. Signed-off-by: Sebastien Buisson Change-Id: I8a846f1dfefe5d1d2310295bdd5172feb04739ef Reviewed-on: http://review.whamcloud.com/15556 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/tests/sanity-krb5.sh | 22 ++++++++++++-- lustre/tests/test-framework.sh | 68 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 84 insertions(+), 6 deletions(-) diff --git a/lustre/tests/sanity-krb5.sh b/lustre/tests/sanity-krb5.sh index 5306591..f116cbf 100755 --- a/lustre/tests/sanity-krb5.sh +++ b/lustre/tests/sanity-krb5.sh @@ -761,23 +761,39 @@ test_151() { # umount everything, modules still loaded stopall + # start mgs + start mgs $(mgsdevname 1) $MDS_MOUNT_OPTS + # mount mgs with default flavor, in current framework it means mgs+mdt1. # the connection of mgc of mdt1 to mgs is expected fail. DEVNAME=$(mdsdevname 1) - start mds1 $DEVNAME $MDS_MOUNT_OPTS && + start mds1 $DEVNAME $MDS_MOUNT_OPTS + wait_mgc_import_state mds FULL 0 && error "mount with default flavor should have failed" + stop mds1 # mount with unauthorized flavor should fail save_opts=$MDS_MOUNT_OPTS + if [ -z "$MDS_MOUNT_OPTS" ]; then + MDS_MOUNT_OPTS="-o mgssec=null" + else MDS_MOUNT_OPTS="$MDS_MOUNT_OPTS,mgssec=null" - start mds1 $DEVNAME $MDS_MOUNT_OPTS && + fi + start mds1 $DEVNAME $MDS_MOUNT_OPTS + wait_mgc_import_state mds FULL 0 && error "mount with unauthorized flavor should have failed" MDS_MOUNT_OPTS=$save_opts + stop mds1 # mount with designated flavor should succeed save_opts=$MDS_MOUNT_OPTS + if [ -z "$MDS_MOUNT_OPTS" ]; then + MDS_MOUNT_OPTS="-o mgssec=krb5p" + else MDS_MOUNT_OPTS="$MDS_MOUNT_OPTS,mgssec=krb5p" - start mds1 $DEVNAME $MDS_MOUNT_OPTS || + fi + start mds1 $DEVNAME $MDS_MOUNT_OPTS + wait_mgc_import_state mds FULL 0 || error "mount with designated flavor should have succeeded" MDS_MOUNT_OPTS=$save_opts diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 529714d..d942691 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -5821,6 +5821,7 @@ _wait_import_state () { local expected=$1 local CONN_PROC=$2 local maxtime=${3:-$(max_recovery_time)} + local error_on_failure=${4:-1} local CONN_STATE local i=0 @@ -5833,9 +5834,12 @@ _wait_import_state () { # reconnect timeout and test can't see real disconnect [ "${CONN_STATE}" == "CONNECTING" ] && return 0 fi - [ $i -ge $maxtime ] && \ - error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \ + if [ $i -ge $maxtime ]; then + [ $error_on_failure -ne 0 ] && \ + error "can't put import for $CONN_PROC into ${expected}" \ + "state after $i sec, have ${CONN_STATE}" return 1 + fi sleep 1 # Add uniq for multi-mount case CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2 | uniq) @@ -5850,10 +5854,11 @@ wait_import_state() { local state=$1 local params=$2 local maxtime=${3:-$(max_recovery_time)} + local error_on_failure=${4:-1} local param for param in ${params//,/ }; do - _wait_import_state $state $param $maxtime || return + _wait_import_state $state $param $maxtime $error_on_failure || return done } @@ -5958,6 +5963,63 @@ wait_osc_import_state() { fi } +_wait_mgc_import_state() { + local facet=$1 + local expected=$2 + local error_on_failure=${3:-1} + local param="mgc.*.mgs_server_uuid" + local params=$param + local i=0 + + # 1. wait the deadline of client 1st request (it could be skipped) + # 2. wait the deadline of client 2nd request + local maxtime=$(( 2 * $(request_timeout $facet))) + + if [[ $facet == client* ]]; then + # During setup time, the osc might not be setup, it need wait + # until list_param can return valid value. And also if there + # are mulitple osc entries we should list all of them before + # go to wait. + params=$($LCTL list_param $param 2>/dev/null || true) + while [ -z "$params" ]; do + if [ $i -ge $maxtime ]; then + echo "can't get $param in $maxtime secs" + return 1 + fi + sleep 1 + i=$((i + 1)) + params=$($LCTL list_param $param 2>/dev/null || true) + done + fi + if ! do_rpc_nodes "$(facet_active_host $facet)" \ + wait_import_state $expected "$params" $maxtime \ + $error_on_failure; then + if [ $error_on_failure -ne 0 ]; then + error "import is not in ${expected} state" + fi + return 1 + fi + + return 0 +} + +wait_mgc_import_state() { + local facet=$1 + local expected=$2 + local error_on_failure=${3:-1} + local num + + if [[ $facet = mds ]]; then + for num in $(seq $MDSCOUNT); do + _wait_mgc_import_state mds$num "$expected" \ + $error_on_failure || return + done + else + _wait_mgc_import_state "$facet" "$expected" + $error_on_failure || return + fi +} + get_clientmdc_proc_path() { echo "${1}-mdc-*" } -- 1.8.3.1