diff options
author | Kotresh HR <khiremat@redhat.com> | 2017-08-11 04:55:18 -0400 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-01-05 07:08:10 +0000 |
commit | 60a992e69a7cf5a588f5139709d325125d6f04fb (patch) | |
tree | d96c997f90174e7c0936b38aab5732cbef096e88 /tests/geo-rep.rc | |
parent | 78d67da17356b48cf1d5a6595764650d5b200ba7 (diff) |
tests: Enable geo-rep test cases
This patch re-enables the geo-rep test cases.
Along with it does following optimizations.
1. Use EXPECT_WITHIN instead of sleep
2. Clean up geo-rep ssh key after test
3. Changes to gverify.sh and S56glusterd-geo-rep-create-post.sh
to use the given ssh identity file for geo-rep create
4. Make gluster-command-dir configurable and introduce
slave-gluster-command-dir which points the parent directory
of gluster binaries in master and slave respectively.
Change-Id: Ia7696278d9dd3ba04224dcd7c3564088ca970b04
BUG: 1480491
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'tests/geo-rep.rc')
-rw-r--r-- | tests/geo-rep.rc | 277 |
1 files changed, 142 insertions, 135 deletions
diff --git a/tests/geo-rep.rc b/tests/geo-rep.rc index 1a44b4a3941..cdad4f1cb62 100644 --- a/tests/geo-rep.rc +++ b/tests/geo-rep.rc @@ -1,18 +1,14 @@ -function check_status() -{ - local search_key=$1 - $GEOREP_CLI $master $slave status detail | egrep -i "$search_key" -} +GEO_REP_TIMEOUT=60 function check_status_num_rows() { - local search_key=$1 - $GEOREP_CLI $master $slave status detail | egrep -i "$search_key" | wc -l + local search_key=$1 + $GEOREP_CLI $master $slave status detail | egrep -i "$search_key" | wc -l } function create_data() { - prefix=$1 + prefix=$1 # GF_FOP_MKNOD # GF_FOP_MKDIR @@ -26,139 +22,150 @@ function create_data() # GF_FOP_CREATE # GF_FOP_SETATTR - # Regular file - touch ${master_mnt}/${prefix}_f1 - touch ${master_mnt}/${prefix}_f2 - touch ${master_mnt}/${prefix}_f3 + # Regular file + touch ${master_mnt}/${prefix}_f1 + touch ${master_mnt}/${prefix}_f2 + touch ${master_mnt}/${prefix}_f3 - # dir - mkdir ${master_mnt}/${prefix}_d1 - mkdir ${master_mnt}/${prefix}_d2 - touch ${master_mnt}/${prefix}_d3 + # dir + mkdir ${master_mnt}/${prefix}_d1 + mkdir ${master_mnt}/${prefix}_d2 + touch ${master_mnt}/${prefix}_d3 - # Hardlink - ln ${master_mnt}/${prefix}_f1 ${master_mnt}/${prefix}_hl1 + # Hardlink + ln ${master_mnt}/${prefix}_f1 ${master_mnt}/${prefix}_hl1 - # Symlink - cd ${master_mnt} - ln -s ${prefix}_f1 ${prefix}_sl1 - cd - + # Symlink + cd ${master_mnt} + ln -s ${prefix}_f1 ${prefix}_sl1 + cd - - # data - echo "HelloWorld!" >> ${master_mnt}/${prefix}_f1 + # data + echo "HelloWorld!" >> ${master_mnt}/${prefix}_f1 - # UNLINK - rm ${master_mnt}/${prefix}_f2 + # UNLINK + rm ${master_mnt}/${prefix}_f2 - # RMDIR - rmdir ${master_mnt}/${prefix}_d2 + # RMDIR + rmdir ${master_mnt}/${prefix}_d2 - # Rename - File - mv ${master_mnt}/${prefix}_f3 ${master_mnt}/${prefix}_f4 + # Rename - File + mv ${master_mnt}/${prefix}_f3 ${master_mnt}/${prefix}_f4 - # Rename - Dir - mv ${master_mnt}/${prefix}_d3 ${master_mnt}/${prefix}_d4 + # Rename - Dir + mv ${master_mnt}/${prefix}_d3 ${master_mnt}/${prefix}_d4 - # chown - touch ${master_mnt}/${prefix}_chown_f1 - chown 1000:1000 ${master_mnt}/${prefix}_chown_f1 + # chown + touch ${master_mnt}/${prefix}_chown_f1 + chown 1000:1000 ${master_mnt}/${prefix}_chown_f1 } function chown_file_ok() { - local file_owner=$(stat --format "%u:%g" "$1" 2>/dev/null) - if test "X$file_owner" != "X1000:1000"; then return 1;fi + local file_owner=$(stat --format "%u:%g" "$1") + if test "X$file_owner" != "X1000:1000"; then echo 1; else echo 0; fi } function regular_file_ok() { - local file_type=$(stat --format "%F" "$1") - if test "X$file_type" != "Xregular file"; then return 1; fi + local file_type=$(stat --format "%F" "$1") + if test "X$file_type" != "Xregular file"; then echo 1; else echo 0; fi } function directory_ok() { - file_type=$(stat --format "%F" "$1") - if test "X$file_type" != "Xdirectory"; then return 1; fi + file_type=$(stat --format "%F" "$1") + if test "X$file_type" != "Xdirectory"; then echo 1; else echo 0; fi } function unlink_ok() { - stat "$1" stat ./case > /dev/null 2>&1 - rc=$? - if test $rc != 0; then return 0; fi - return 1; + stat "$1" > /dev/null 2>&1 + rc=$? + echo $rc } function hardlink_file_ok() { - orig_file=$1 - link_file=$2 + orig_file=$1 + link_file=$2 - orig_inode=$(stat --format "%i" "$orig_file") - rc=$? - if test $rc != 0; then return $rc; fi + orig_inode=$(stat --format "%i" "$orig_file") + rc=$? + if test $rc != 0; then echo $rc; fi - link_inode=$(stat --format "%i" "$link_file") - rc=$? - if test $rc != 0; then return $rc; fi + link_inode=$(stat --format "%i" "$link_file") + rc=$? + if test $rc != 0; then echo $rc; fi - if test $orig_inode != $link_inode - then - return 1 - fi + if test $orig_inode != $link_inode + then + echo 1 + else + echo 0 + fi } function data_ok() { - path=$1 - data1="$2" - data2=$(cat $path) - echo "data1:$data1" - echo "data2:$data2" - if test "X$data1" != "X$data2" - then - return 1 - fi + path=$1 + data1="$2" + data2=$(cat $path) + echo "data1:$data1" + echo "data2:$data2" + if test "X$data1" != "X$data2" + then + echo 1 + else + echo 0 + fi } -function symlink_ok() +function arequal_checksum() { - local orig_file_name=$1 - local symlink_file=$2 + master=$1 + slave=$2 + diff <(arequal-checksum -p $master) <(arequal-checksum -p $slave) | wc -l +} +function symlink_ok() +{ + local orig_file_name=$1 + local symlink_file=$2 - local file_type=$(stat --format "%F" "$symlink_file") - if test "X$file_type" != "Xsymbolic link"; then return 1; fi + local file_type=$(stat --format "%F" "$symlink_file") + if test "X$file_type" != "Xsymbolic link"; then echo 1;else echo 0; fi - local fname=$(readlink $symlink_file) - if test "X$fname" != "X$orig_file_name"; then return 1; fi + local fname=$(readlink $symlink_file) + if test "X$fname" != "X$orig_file_name"; then echo 1;else echo 0; fi } function rename_ok() { - old_name=$1 - new_name=$2 + old_name=$1 + new_name=$2 - if [ -f $old_name ] - then - return 1 - fi + if [ -f $old_name ] + then + echo 1 + fi - if [ ! -f $new_name ] - then - return 1 - fi + if [ ! -f $new_name ] + then + echo 1 + fi + echo 0 } function create_georep_session() { - $CLI system:: execute gsec_create - rc=$? - if test $rc != 0; then return $rc; fi - $CLI volume geo-rep $master $slave create push-pem - rc=$? - if test $rc != 0; then return $rc; fi + $CLI system:: execute gsec_create + rc=$? + if test $rc != 0; then echo $rc; fi + $CLI volume geo-rep $master $slave create push-pem + rc=$? + if test $rc != 0; then echo $rc; fi + echo 0 } # logrotate_simulate should be called (rotate_count + 1) times to cause @@ -167,66 +174,66 @@ function create_georep_session() # calls function logrotate_simulate() { - file_name=$1 - declare -i rotate_count=$2 - - while [ $rotate_count -ge 0 ]; do - source_file="${master_mnt}/$file_name.$((rotate_count))" - if [ $rotate_count -eq 0 ]; then - source_file="${master_mnt}/$file_name" - fi - if [ -f "${source_file}" ]; then - mv "${source_file}" "${master_mnt}/$file_name.$((rotate_count+1))" - fi - ((rotate_count--)) - done - - # logrotate causes gfid to be rellocated to a new file created - # after an unlink and a blind rename later causes georep session - # to go Faulty - # this should not happen if source basename on slave is tested - # to be linked with its own gfid as on master, before invoking - # the rename syscall - touch ${master_mnt}/$file_name - rotate_count=$2 - unlink_file_name="${master_mnt}/$file_name.$((rotate_count+1))" - unlink $unlink_file_name + file_name=$1 + declare -i rotate_count=$2 + + while [ $rotate_count -ge 0 ]; do + source_file="$file_name.$((rotate_count))" + if [ $rotate_count -eq 0 ]; then + source_file="$file_name" + fi + if [ -f "${source_file}" ]; then + mv "${source_file}" "$file_name.$((rotate_count+1))" + fi + ((rotate_count--)) + done + + # logrotate causes gfid to be rellocated to a new file created + # after an unlink and a blind rename later causes georep session + # to go Faulty + # this should not happen if source basename on slave is tested + # to be linked with its own gfid as on master, before invoking + # the rename syscall + touch $file_name + rotate_count=$2 + unlink_file_name="$file_name.$((rotate_count+1))" + unlink $unlink_file_name 2>/dev/null } function create_rename() { - file_name=$1 - echo $file_name > ${master_mnt}/$file_name - mv ${master_mnt}/$file_name ${master_mnt}/$file_name.bak + file_name=$1 + echo $file_name > $file_name + mv $file_name $file_name.bak } function create_rename_ok() { - file_name=$1 - # after a log replay, we don't expect the original file - # to be recreated i.e. a dangling entry without a corresponding - # back-end gfid link should not exist on the slave - if [ -f "${slave_mnt}/$file_name" ]; then - return 1 - fi - return 0 + file_name=$1 + # after a log replay, we don't expect the original file + # to be recreated i.e. a dangling entry without a corresponding + # back-end gfid link should not exist on the slave + if [ -f "$file_name" ]; then + echo 1 + fi + echo 0 } function hardlink_rename() { - file_name=$1 - echo $file_name > ${master_mnt}/$file_name - ln ${master_mnt}/$file_name ${master_mnt}/$file_name.hl - mv ${master_mnt}/$file_name.hl ${master_mnt}/$file_name + file_name=$1 + echo $file_name > $file_name + ln $file_name $file_name.hl + mv $file_name.hl $file_name } function hardlink_rename_ok() { - file_name=$1 - # the hardlink file should not exist on the slave after renaming - # to one of its links - if [ -f "${slave_mnt}/$file_name.hl" ]; then - return 1 - fi - return 0 + file_name=$1 + # the hardlink file should not exist on the slave after renaming + # to one of its links + if [ -f "$file_name.hl" ]; then + echo 1 + fi + echo 0 } |