From 081e7938c8711aa7ce8a2955bb34767b697cf8b9 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Tue, 3 Nov 2015 21:07:00 +0530 Subject: tests/tier: Move common functions to tier.rc Move common functions in tier .t files to tier.rc > Change-Id: Ibc312d987be9d93e7cc7fc47d0bf598bb1c944c2 > Signed-off-by: N Balachandran > Reviewed-on: http://review.gluster.org/12404 > Tested-by: Gluster Build System > Reviewed-by: Dan Lambright > Tested-by: Dan Lambright (cherry picked from commit 594a03b030577bf0ed6960199e920cc5fa7e7afc) Change-Id: Ie13bb86f85575164e62120e29bbbedb7789b0af5 BUG: 1277590 Signed-off-by: N Balachandran Reviewed-on: http://review.gluster.org/12497 Tested-by: Gluster Build System Reviewed-by: Dan Lambright Tested-by: Dan Lambright --- ...1214222-directories_miising_after_attach_tier.t | 71 ------------------ ...1214222-directories_missing_after_attach_tier.t | 55 ++++++++++++++ tests/basic/tier/fops-during-migration.t | 11 +-- tests/basic/tier/legacy-many.t | 67 ++--------------- tests/basic/tier/locked_file_migration.t | 36 +-------- tests/basic/tier/tier.t | 48 +----------- tests/tier.rc | 85 ++++++++++++++++++++++ 7 files changed, 149 insertions(+), 224 deletions(-) delete mode 100755 tests/basic/tier/bug-1214222-directories_miising_after_attach_tier.t create mode 100755 tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t create mode 100644 tests/tier.rc (limited to 'tests') diff --git a/tests/basic/tier/bug-1214222-directories_miising_after_attach_tier.t b/tests/basic/tier/bug-1214222-directories_miising_after_attach_tier.t deleted file mode 100755 index 6199463b36d..00000000000 --- a/tests/basic/tier/bug-1214222-directories_miising_after_attach_tier.t +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash - -. $(dirname $0)/../../include.rc -. $(dirname $0)/../../volume.rc - -LAST_BRICK=3 -CACHE_BRICK_FIRST=4 -CACHE_BRICK_LAST=5 -DEMOTE_TIMEOUT=12 -PROMOTE_TIMEOUT=5 - -function confirm_tier_removed { - $CLI system getspec $V0 | grep $1 - if [ $? == 0 ]; then - echo "1" - else - echo "0" - fi -} - -function confirm_vol_stopped { - $CLI volume stop $1 - if [ $? == 0 ]; then - echo "0" - else - echo "1" - fi -} - -LAST_BRICK=1 -CACHE_BRICK=2 -DEMOTE_TIMEOUT=12 -PROMOTE_TIMEOUT=5 -MIGRATION_TIMEOUT=10 -cleanup - - -TEST glusterd -TEST pidof glusterd - -TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK} -TEST $CLI volume start $V0 -TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0; - -# Basic operations. -cd $M0 -TEST stat . -TEST mkdir d1 -TEST [ -d d1 ] -TEST touch file1 -TEST [ -e file1 ] - -TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST -TEST $CLI volume set $V0 features.ctr-enabled on - -#check whether the directory's and files are present on mount or not. -TEST [ -d d1 ] -TEST [ -e file1 ] - -cd -EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0; - -TEST $CLI volume detach-tier $V0 start -TEST $CLI volume detach-tier $V0 commit - -EXPECT "0" confirm_tier_removed ${V0}${CACHE_BRICK_FIRST} - -EXPECT_WITHIN $REBALANCE_TIMEOUT "0" confirm_vol_stopped $V0 - - -cleanup diff --git a/tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t b/tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t new file mode 100755 index 00000000000..8aa1380ae46 --- /dev/null +++ b/tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t @@ -0,0 +1,55 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../tier.rc + +LAST_BRICK=3 +CACHE_BRICK_FIRST=4 +CACHE_BRICK_LAST=5 +DEMOTE_TIMEOUT=12 +PROMOTE_TIMEOUT=5 + + +LAST_BRICK=1 +CACHE_BRICK=2 +DEMOTE_TIMEOUT=12 +PROMOTE_TIMEOUT=5 +MIGRATION_TIMEOUT=10 +cleanup + + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK} +TEST $CLI volume start $V0 +TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0; + +# Basic operations. +cd $M0 +TEST stat . +TEST mkdir d1 +TEST [ -d d1 ] +TEST touch file1 +TEST [ -e file1 ] + +TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST +TEST $CLI volume set $V0 features.ctr-enabled on + +#check whether the directory's and files are present on mount or not. +TEST [ -d d1 ] +TEST [ -e file1 ] + +cd +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0; + +TEST $CLI volume detach-tier $V0 start +TEST $CLI volume detach-tier $V0 commit + +EXPECT "0" confirm_tier_removed ${V0}${CACHE_BRICK_FIRST} + +EXPECT_WITHIN $REBALANCE_TIMEOUT "0" confirm_vol_stopped $V0 + + +cleanup diff --git a/tests/basic/tier/fops-during-migration.t b/tests/basic/tier/fops-during-migration.t index ce25f0acc32..aa868847738 100755 --- a/tests/basic/tier/fops-during-migration.t +++ b/tests/basic/tier/fops-during-migration.t @@ -2,6 +2,7 @@ . $(dirname $0)/../../include.rc . $(dirname $0)/../../volume.rc +. $(dirname $0)/../../tier.rc NUM_BRICKS=3 @@ -10,16 +11,6 @@ PROMOTE_FREQ=5 TEST_STR="Testing write and truncate fops on tier migration" -function is_sticky_set () { - echo $1 - if [ -k $1 ]; - then - echo "yes" - else - echo "no" - fi -} - # Creates a tiered volume with pure distribute hot and cold tiers # Both hot and cold tiers will have an equal number of bricks. diff --git a/tests/basic/tier/legacy-many.t b/tests/basic/tier/legacy-many.t index 17275494aba..2c7ff3e5407 100644 --- a/tests/basic/tier/legacy-many.t +++ b/tests/basic/tier/legacy-many.t @@ -2,6 +2,8 @@ . $(dirname $0)/../../include.rc . $(dirname $0)/../../volume.rc +. $(dirname $0)/../../tier.rc + LAST_BRICK=3 CACHE_BRICK_FIRST=4 @@ -15,64 +17,6 @@ TEST_DIR="test_files" NUM_FILES=20 -# Grab md5sum without file path (failed attempt notifications are discarded) -function fingerprint { - md5sum $1 2> /dev/null | grep --only-matching -m 1 '^[0-9a-f]*' -} - -# Create a large number of files. Store their md5 signatures. -function create_many_files { - mkdir ${TEST_DIR} - for i in `seq 1 $NUM_FILES`; do - dd if=/dev/urandom of=./${TEST_DIR}/i$i bs=1048576 count=1; - id[i]=$(fingerprint "./${TEST_DIR}/i$i"); - done -} - -function confirm_tier_removed { - $CLI system getspec $V0 | grep $1 - if [ $? == 0 ]; then - echo "1" - else - echo "0" - fi -} - -function confirm_vol_stopped { - $CLI volume stop $1 - if [ $? == 0 ]; then - echo "0" - else - echo "1" - fi -} - -function check_counters { - index=0 - ret=0 - rm -f /tmp/tc*.txt - echo "0" > /tmp/tc2.txt - - $CLI volume rebalance $V0 tier status | grep localhost > /tmp/tc.txt - - promote=`cat /tmp/tc.txt |awk '{print $2}'` - demote=`cat /tmp/tc.txt |awk '{print $3}'` - if [ "${promote}" != "${1}" ]; then - echo "1" > /tmp/tc2.txt - - elif [ "${demote}" != "${2}" ]; then - echo "2" > /tmp/tc2.txt - fi - - # temporarily disable non-Linux tests. - case $OSTYPE in - NetBSD | FreeBSD | Darwin) - echo "0" > /tmp/tc2.txt - ;; - esac - cat /tmp/tc2.txt -} - function read_all { for file in * do @@ -96,8 +40,9 @@ TEST $CLI volume set $V0 features.ctr-enabled on TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0; # Create a number of "legacy" files before attaching tier -cd $M0 -TEST create_many_files +mkdir $M0/${TEST_DIR} +cd $M0/${TEST_DIR} +TEST create_many_files tfile $NUM_FILES wait # Attach tier @@ -116,7 +61,7 @@ TEST read_all # Test to make sure files were promoted as expected sleep $DEMOTE_TIMEOUT -EXPECT_WITHIN $DEMOTE_TIMEOUT "0" check_counters 20 0 +EXPECT_WITHIN $DEMOTE_TIMEOUT "0" check_counters $NUM_FILES 0 cd; cleanup diff --git a/tests/basic/tier/locked_file_migration.t b/tests/basic/tier/locked_file_migration.t index c3ba1b27749..7a03d1e3d36 100755 --- a/tests/basic/tier/locked_file_migration.t +++ b/tests/basic/tier/locked_file_migration.t @@ -2,6 +2,7 @@ . $(dirname $0)/../../include.rc . $(dirname $0)/../../volume.rc +. $(dirname $0)/../../tier.rc NUM_BRICKS=3 @@ -11,41 +12,6 @@ DEMOTE_TIMEOUT=15 TEST_STR="Testing write and truncate fops on tier migration" -function is_sticky_set () { - echo $1 - if [ -k $1 ]; - then - echo "yes" - else - echo "no" - fi -} - -function check_counters { - index=0 - ret=0 - rm -f /tmp/tc*.txt - echo "0" > /tmp/tc2.txt - $CLI volume rebalance $V0 tier status | grep localhost > /tmp/tc.txt - - promote=`cat /tmp/tc.txt |awk '{print $2}'` - demote=`cat /tmp/tc.txt |awk '{print $3}'` - if [ "${promote}" != "${1}" ]; then - echo "1" > /tmp/tc2.txt - - elif [ "${demote}" != "${2}" ]; then - echo "2" > /tmp/tc2.txt - fi - - # temporarily disable non-Linux tests. - case $OSTYPE in - NetBSD | FreeBSD | Darwin) - echo "0" > /tmp/tc2.txt - ;; - esac - cat /tmp/tc2.txt -} - # Creates a tiered volume with pure distribute hot and cold tiers # Both hot and cold tiers will have an equal number of bricks. diff --git a/tests/basic/tier/tier.t b/tests/basic/tier/tier.t index bc5e4ce004c..5bb2dc95164 100755 --- a/tests/basic/tier/tier.t +++ b/tests/basic/tier/tier.t @@ -2,6 +2,7 @@ . $(dirname $0)/../../include.rc . $(dirname $0)/../../volume.rc +. $(dirname $0)/../../tier.rc LAST_BRICK=3 CACHE_BRICK_FIRST=4 @@ -20,10 +21,6 @@ function sleep_first_cycle { sleep $mod } -# Grab md5sum without file path (failed attempt notifications are discarded). -function fingerprint { - md5sum $1 2> /dev/null | grep --only-matching -m 1 '^[0-9a-f]*' -} function file_on_slow_tier { found=0 @@ -79,49 +76,6 @@ function file_on_fast_tier { fi } -function confirm_tier_removed { - $CLI system getspec $V0 | grep $1 - if [ $? == 0 ]; then - echo "1" - else - echo "0" - fi -} - -function confirm_vol_stopped { - $CLI volume stop $1 - if [ $? == 0 ]; then - echo "0" - else - echo "1" - fi -} - -function check_counters { - index=0 - ret=0 - rm -f /tmp/tc*.txt - echo "0" > /tmp/tc2.txt - - $CLI volume rebalance $V0 tier status | grep localhost > /tmp/tc.txt - - promote=`cat /tmp/tc.txt |awk '{print $2}'` - demote=`cat /tmp/tc.txt |awk '{print $3}'` - if [ "${promote}" != "${1}" ]; then - echo "1" > /tmp/tc2.txt - - elif [ "${demote}" != "${2}" ]; then - echo "2" > /tmp/tc2.txt - fi - - # temporarily disable non-Linux tests. - case $OSTYPE in - NetBSD | FreeBSD | Darwin) - echo "0" > /tmp/tc2.txt - ;; - esac - cat /tmp/tc2.txt -} cleanup diff --git a/tests/tier.rc b/tests/tier.rc new file mode 100644 index 00000000000..393d712f3bb --- /dev/null +++ b/tests/tier.rc @@ -0,0 +1,85 @@ +#!/bin/bash + +# Common tier functions + +# Check if a file is being migrated +# by checking for the presence of +# the sticky bit +# Args: $1 : path to file + +function is_sticky_set () { + echo $1 + if [ -k $1 ]; + then + echo "yes" + else + echo "no" + fi +} + + +function check_counters { + index=0 + ret=0 + rm -f /tmp/tc*.txt + echo "0" > /tmp/tc2.txt + $CLI volume rebalance $V0 tier status | grep localhost > /tmp/tc.txt + + promote=`cat /tmp/tc.txt |awk '{print $2}'` + demote=`cat /tmp/tc.txt |awk '{print $3}'` + if [ "${promote}" != "${1}" ]; then + echo "1" > /tmp/tc2.txt + + elif [ "${demote}" != "${2}" ]; then + echo "2" > /tmp/tc2.txt + fi + + # temporarily disable non-Linux tests. + case $OSTYPE in + NetBSD | FreeBSD | Darwin) + echo "0" > /tmp/tc2.txt + ;; + esac + cat /tmp/tc2.txt +} + + +# Grab md5sum without file path (failed attempt notifications are discarded) +function fingerprint { + md5sum $1 2> /dev/null | grep --only-matching -m 1 '^[0-9a-f]*' +} + + + +# Create a large number of files in the current directory. +# $1 : file name prefix. Will create files $2-1 to $2-$3 +# $2 : number of files + +function create_many_files { + filename=$1 + num=$2 + + for i in `seq 1 $num`; do + dd if=/dev/urandom of=./${dirname}/${filename}$i bs=104857 count=1; + done +} + + +function confirm_tier_removed { + $CLI system getspec $V0 | grep $1 + if [ $? == 0 ]; then + echo "1" + else + echo "0" + fi +} + +function confirm_vol_stopped { + $CLI volume stop $1 + if [ $? == 0 ]; then + echo "0" + else + echo "1" + fi +} + -- cgit