diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t (renamed from tests/basic/tier/bug-1214222-directories_miising_after_attach_tier.t) | 18 | ||||
-rwxr-xr-x | tests/basic/tier/fops-during-migration.t | 11 | ||||
-rw-r--r-- | tests/basic/tier/legacy-many.t | 67 | ||||
-rwxr-xr-x | tests/basic/tier/locked_file_migration.t | 36 | ||||
-rwxr-xr-x | tests/basic/tier/tier.t | 48 | ||||
-rw-r--r-- | tests/tier.rc | 85 |
6 files changed, 95 insertions, 170 deletions
diff --git a/tests/basic/tier/bug-1214222-directories_miising_after_attach_tier.t b/tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t index 6199463b36d..8aa1380ae46 100755 --- a/tests/basic/tier/bug-1214222-directories_miising_after_attach_tier.t +++ b/tests/basic/tier/bug-1214222-directories_missing_after_attach_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 @@ -9,23 +10,6 @@ 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 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 67927047729..fedd3bde1c9 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 +} + |