From: Sebastien Buisson Date: Sat, 30 Apr 2016 16:27:57 +0000 (+0200) Subject: LU-7846 tests: test for nodemap fileset in sanity-sec X-Git-Tag: 2.8.55~12 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=5042d4c8ecad287276e04c52c6a1fee9c9b597a9 LU-7846 tests: test for nodemap fileset in sanity-sec Add new tests in sanity-sec.sh to test for fileset in nodemap. Test-Parameters: testlist=sanity-sec Signed-off-by: Sebastien Buisson Change-Id: I7903d0282d15df84e1f48028d3f44094cac20e98 Reviewed-on: http://review.whamcloud.com/19895 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Kit Westneat Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/sanity-sec.sh b/lustre/tests/sanity-sec.sh index 39a167e..9f3446f 100755 --- a/lustre/tests/sanity-sec.sh +++ b/lustre/tests/sanity-sec.sh @@ -969,20 +969,21 @@ wait_nm_sync() { local is_sync local out1=$(do_facet mgs $LCTL get_param nodemap.${proc_param}) local out2 - local mgs_ip=$(host_nids_address $mgs_HOST $NETTYPE) + local mgs_ip=$(host_nids_address $mgs_HOST $NETTYPE | cut -d' ' -f1) local i # wait up to 10 seconds for other servers to sync with mgs for i in $(seq 1 10); do for node in $(all_server_nodes); do - local node_ip=$(host_nids_address $node $NETTYPE) + local node_ip=$(host_nids_address $node $NETTYPE | + cut -d' ' -f1) - is_sync=true - [ $node_ip == $mgs_ip ] && continue + is_sync=true + [ $node_ip == $mgs_ip ] && continue - out2=$(do_node $node_ip $LCTL get_param \ - nodemap.$proc_param 2>/dev/null) - [ "$out1" != "$out2" ] && is_sync=false && break + out2=$(do_node $node_ip $LCTL get_param \ + nodemap.$proc_param 2>/dev/null) + [ "$out1" != "$out2" ] && is_sync=false && break done $is_sync && break sleep 1 @@ -1072,6 +1073,72 @@ fops_test_setup() { wait_nm_sync c0 trusted_nodemap } +# fileset test directory needs to be initialized on a privileged client +fileset_test_setup() { + local admin=$(do_facet mgs $LCTL get_param -n nodemap.c0.admin_nodemap) + local trust=$(do_facet mgs $LCTL get_param -n \ + nodemap.c0.trusted_nodemap) + + do_facet mgs $LCTL nodemap_modify --name c0 --property admin --value 1 + do_facet mgs $LCTL nodemap_modify --name c0 --property trusted --value 1 + + wait_nm_sync c0 admin_nodemap + wait_nm_sync c0 trusted_nodemap + + # create directory and populate it for subdir mount + do_node ${clients_arr[0]} mkdir $MOUNT/$subdir || + error "unable to create dir $MOUNT/$subdir" + do_node ${clients_arr[0]} touch $MOUNT/$subdir/this_is_$subdir || + error "unable to create file $MOUNT/$subdir/this_is_$subdir" + do_node ${clients_arr[0]} mkdir $MOUNT/$subdir/$subsubdir || + error "unable to create dir $MOUNT/$subdir/$subsubdir" + do_node ${clients_arr[0]} touch \ + $MOUNT/$subdir/$subsubdir/this_is_$subsubdir || + error "unable to create file \ + $MOUNT/$subdir/$subsubdir/this_is_$subsubdir" + + do_facet mgs $LCTL nodemap_modify --name c0 \ + --property admin --value $admin + do_facet mgs $LCTL nodemap_modify --name c0 \ + --property trusted --value $trust + + # flush MDT locks to make sure they are reacquired before test + do_node ${clients_arr[0]} $LCTL set_param \ + ldlm.namespaces.$FSNAME-MDT*.lru_size=clear + + wait_nm_sync c0 admin_nodemap + wait_nm_sync c0 trusted_nodemap +} + +# fileset test directory needs to be initialized on a privileged client +fileset_test_cleanup() { + local admin=$(do_facet mgs $LCTL get_param -n nodemap.c0.admin_nodemap) + local trust=$(do_facet mgs $LCTL get_param -n \ + nodemap.c0.trusted_nodemap) + + do_facet mgs $LCTL nodemap_modify --name c0 --property admin --value 1 + do_facet mgs $LCTL nodemap_modify --name c0 --property trusted --value 1 + + wait_nm_sync c0 admin_nodemap + wait_nm_sync c0 trusted_nodemap + + # cleanup directory created for subdir mount + do_node ${clients_arr[0]} rm -rf $MOUNT/$subdir || + error "unable to remove dir $MOUNT/$subdir" + + do_facet mgs $LCTL nodemap_modify --name c0 \ + --property admin --value $admin + do_facet mgs $LCTL nodemap_modify --name c0 \ + --property trusted --value $trust + + # flush MDT locks to make sure they are reacquired before test + do_node ${clients_arr[0]} $LCTL set_param \ + ldlm.namespaces.$FSNAME-MDT*.lru_size=clear + + wait_nm_sync c0 admin_nodemap + wait_nm_sync c0 trusted_nodemap +} + do_create_delete() { local run_u=$1 local key=$2 @@ -1209,6 +1276,7 @@ test_fops_chmod_dir() { # if only one client, and non-admin, need to flip admin everytime if [ "$num_clients" == "1" ]; then + test_fops_admin_client=$clients test_fops_admin_val=$(do_facet mgs $LCTL get_param -n \ nodemap.c0.admin_nodemap) if [ "$test_fops_admin_val" != "1" ]; then @@ -1346,6 +1414,15 @@ nodemap_test_cleanup() { rc=$? [[ $rc != 0 ]] && error "removing fops nodemaps failed $rc" + do_facet mgs $LCTL nodemap_modify --name default \ + --property admin --value 0 + do_facet mgs $LCTL nodemap_modify --name default \ + --property trusted --value 0 + wait_nm_sync default trusted_nodemap + + do_facet mgs $LCTL nodemap_activate 0 + wait_nm_sync active 0 + return 0 } @@ -1590,18 +1667,51 @@ test_24() { run_test 24 "check nodemap proc files for LBUGs and Oopses" test_25() { + local tmpfile=$(mktemp) + local tmpfile2=$(mktemp) + local subdir=c0dir + nodemap_version_check || return 0 + + # stop clients for this test + zconf_umount_clients $CLIENTS $MOUNT || + error "unable to umount clients $CLIENTS" + nodemap_test_setup trap nodemap_test_cleanup EXIT - local tmpfile=$(mktemp) + + # create a new, empty nodemap, and add fileset info to it + do_facet mgs $LCTL nodemap_add test26 || + error "unable to create nodemap test26" + do_facet mgs $LCTL set_param -P nodemap.test26.fileset=/$subdir || + error "unable to add fileset info to nodemap test26" + + wait_nm_sync test26 id + do_facet mgs $LCTL nodemap_info > $tmpfile + do_facet mds $LCTL nodemap_info > $tmpfile2 + cleanup_and_setup_lustre + # stop clients for this test + zconf_umount_clients $CLIENTS $MOUNT || + error "unable to umount clients $CLIENTS" + diff -q <(do_facet mgs $LCTL nodemap_info) $tmpfile >& /dev/null || - error "nodemap_info diff after remount" + error "nodemap_info diff on MGS after remount" + diff -q <(do_facet mds $LCTL nodemap_info) $tmpfile2 >& /dev/null || + error "nodemap_info diff on MDS after remount" + + # cleanup nodemap + do_facet mgs $LCTL nodemap_del test26 || + error "cannot delete nodemap test26 from config" nodemap_test_cleanup - rm -f $tmpfile + # restart clients previously stopped + zconf_mount_clients $CLIENTS $MOUNT || + error "unable to mount clients $CLIENTS" + + rm -f $tmpfile $tmpfile2 } run_test 25 "test save and reload nodemap config" @@ -1618,6 +1728,66 @@ test_26() { } run_test 26 "test transferring very large nodemap" +test_27() { + local subdir=c0dir + local subsubdir=c0subdir + + nodemap_test_setup + trap nodemap_test_cleanup EXIT + + fileset_test_setup + + # add fileset info to nodemap + do_facet mgs $LCTL set_param nodemap.c0.fileset=/$subdir || + error "unable to set fileset info on nodemap c0" + do_facet mgs $LCTL set_param -P nodemap.c0.fileset=/$subdir || + error "unable to add fileset info to nodemap c0" + wait_nm_sync c0 fileset + + # re-mount client + zconf_umount_clients ${clients_arr[0]} $MOUNT || + error "unable to umount client ${clients_arr[0]}" + zconf_mount_clients ${clients_arr[0]} $MOUNT $MOUNT_OPTS || + error "unable to remount client ${clients_arr[0]}" + + # test mount point content + do_node ${clients_arr[0]} test -f $MOUNT/this_is_$subdir || + error "fileset not taken into account" + + # re-mount client with sub-subdir + zconf_umount_clients ${clients_arr[0]} $MOUNT || + error "unable to umount client ${clients_arr[0]}" + export FILESET=/$subsubdir + zconf_mount_clients ${clients_arr[0]} $MOUNT $MOUNT_OPTS || + error "unable to remount client ${clients_arr[0]}" + unset FILESET + + # test mount point content + do_node ${clients_arr[0]} test -f $MOUNT/this_is_$subsubdir || + error "subdir of fileset not taken into account" + + # remove fileset info from nodemap + do_facet mgs $LCTL nodemap_set_fileset --name c0 --fileset \'\' || + error "unable to delete fileset info on nodemap c0" + do_facet mgs $LCTL set_param -P nodemap.c0.fileset=\'\' || + error "unable to reset fileset info on nodemap c0" + wait_nm_sync c0 fileset + + # re-mount client + zconf_umount_clients ${clients_arr[0]} $MOUNT || + error "unable to umount client ${clients_arr[0]}" + zconf_mount_clients ${clients_arr[0]} $MOUNT $MOUNT_OPTS || + error "unable to remount client ${clients_arr[0]}" + + # test mount point content + do_node ${clients_arr[0]} test -d $MOUNT/$subdir || + error "fileset not cleared on nodemap c0" + + fileset_test_cleanup + nodemap_test_cleanup +} +run_test 27 "test fileset in nodemap" + log "cleanup: ======================================================" sec_unsetup() {