+ #
+ # after set to flavor0, start multop which use flavor0 rpc, and let
+ # server drop the reply; then switch to flavor1, the resend should be
+ # completed using flavor1. To exercise the code of switching ctx/sec
+ # for a resend request.
+ #
+ log ">>>>>>>>>>>>>>> Testing $flavor0 -> $flavor1 <<<<<<<<<<<<<<<<<<<"
+
+ set_rule $FSNAME any cli2mdt $flavor0
+ wait_flavor cli2mdt $flavor0
+ rm -f $filename || error "remove old $filename failed"
+
+#MDS_REINT = 36
+#define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
+ do_facet $SINGLEMDS lctl set_param fail_val=36
+ do_facet $SINGLEMDS lctl set_param fail_loc=0x513
+ log "starting multiop"
+ multiop $filename m &
+ multiop_pid=$!
+ echo "multiop pid=$multiop_pid"
+ sleep 1
+
+ set_rule $FSNAME any cli2mdt $flavor1
+ wait_flavor cli2mdt $flavor1
+
+ num=`ps --no-headers -p $multiop_pid 2>/dev/null | wc -l`
+ [ $num -eq 1 ] || error "multiop($multiop_pid) already ended ($num)"
+ echo "process $multiop_pid is still hanging there... OK"
+
+ do_facet $SINGLEMDS lctl set_param fail_loc=0
+ log "waiting for multiop ($multiop_pid) to finish"
+ wait $multiop_pid || error "multiop returned error"
+}
+
+test_101()
+{
+ # started from default flavors
+ restore_to_default_flavor
+
+ switch_sec_test null plain
+ switch_sec_test plain krb5n
+ switch_sec_test krb5n krb5a
+ switch_sec_test krb5a krb5i
+ switch_sec_test krb5i krb5p
+ switch_sec_test krb5p null
+ switch_sec_test null krb5p
+ switch_sec_test krb5p krb5i
+ switch_sec_test krb5i plain
+ switch_sec_test plain krb5p
+}
+run_test 101 "switch ctx/sec for resending request"
+
+error_102()
+{
+ local err_str=$1
+
+ killall -9 dbench
+ sleep 1
+
+ error $err_str
+}
+
+test_102() {
+ # started from default flavors
+ restore_to_default_flavor
+
+ # run dbench background
+ start_dbench
+
+ echo "Testing null->krb5n->krb5a->krb5i->krb5p->plain->null"
+ set_rule $FSNAME any any krb5n
+ set_rule $FSNAME any any krb5a
+ set_rule $FSNAME any any krb5i
+ set_rule $FSNAME any any krb5p
+ set_rule $FSNAME any any plain
+ set_rule $FSNAME any any null
+
+ check_dbench
+ wait_flavor all2all null || error_dbench "1"
+ check_dbench
+
+ echo "waiting for 15s and check again"
+ sleep 15
+ check_dbench
+
+ echo "Testing null->krb5i->null->krb5i->null..."
+ for ((i=0; i<10; i++)); do
+ set_rule $FSNAME any any krb5i
+ set_rule $FSNAME any any null
+ done
+ set_rule $FSNAME any any krb5i
+
+ check_dbench
+ wait_flavor all2all krb5i || error_dbench "2"
+ check_dbench
+
+ echo "waiting for 15s and check again"
+ sleep 15
+ check_dbench
+
+ stop_dbench
+}
+run_test 102 "survive from insanely fast flavor switch"
+
+test_150() {
+ local save_opts
+ local count
+ local clients=$CLIENTS
+
+ [ -z $clients ] && clients=$HOSTNAME
+
+ # started from default flavors
+ restore_to_default_flavor
+
+ # at this time no rules has been set on mgs; mgc use null
+ # flavor connect to mgs.
+ count=`flvr_cnt_mgc2mgs null`
+ [ $count -eq 1 ] || error "$count mgc connection use null flavor"
+
+ zconf_umount_clients $clients $MOUNT || return 1
+
+ # mount client with conflict flavor - should fail
+ save_opts=$MOUNTOPT
+ MOUNTOPT="$MOUNTOPT,mgssec=krb5p"
+ zconf_mount_clients $clients $MOUNT && \
+ error "mount with conflict flavor should have failed"
+ MOUNTOPT=$save_opts
+
+ # mount client with same flavor - should succeed
+ save_opts=$MOUNTOPT
+ MOUNTOPT="$MOUNTOPT,mgssec=null"
+ zconf_mount_clients $clients $MOUNT || \
+ error "mount with same flavor should have succeeded"
+ MOUNTOPT=$save_opts
+ zconf_umount_clients $clients $MOUNT || return 2
+
+ # mount client with default flavor - should succeed
+ zconf_mount_clients $clients $MOUNT || \
+ error "mount with default flavor should have succeeded"