diff options
| author | Kotresh HR <khiremat@redhat.com> | 2018-06-27 08:26:44 -0400 | 
|---|---|---|
| committer | Nigel Babu <nigelb@redhat.com> | 2018-07-02 06:09:10 +0000 | 
| commit | 957e2963cfd960caa49edc0e6aba738167b33ec5 (patch) | |
| tree | e47ce2db4ced72ba271722363ec468d4feaab905 | |
| parent | b3c2116d99a5c049e4ee0f88f35440258b49496e (diff) | |
tests/geo-rep: Add symlink rename test case
Added a test case of symlink rename and directory
creation with the name same as original symlink
file. Also fixed few other issues in geo-rep.rc
fixes: bz#1595726
Change-Id: I8e6acd3e742f3a0104cd37b87d1c0e0c902679b5
Signed-off-by: Kotresh HR <khiremat@redhat.com>
| -rw-r--r-- | tests/00-geo-rep/georep-basic-dr-rsync.t | 20 | ||||
| -rw-r--r-- | tests/00-geo-rep/georep-basic-dr-tarssh.t | 19 | ||||
| -rw-r--r-- | tests/geo-rep.rc | 100 | 
3 files changed, 104 insertions, 35 deletions
diff --git a/tests/00-geo-rep/georep-basic-dr-rsync.t b/tests/00-geo-rep/georep-basic-dr-rsync.t index 683506684de..661e734a861 100644 --- a/tests/00-geo-rep/georep-basic-dr-rsync.t +++ b/tests/00-geo-rep/georep-basic-dr-rsync.t @@ -3,7 +3,6 @@  . $(dirname $0)/../include.rc  . $(dirname $0)/../volume.rc  . $(dirname $0)/../geo-rep.rc -. $(dirname $0)/../env.rc  AREQUAL_PATH=$(dirname $0)/../utils  test "`uname -s`" != "Linux" && { @@ -157,6 +156,25 @@ EXPECT_WITHIN $GEO_REP_TIMEOUT 0 hardlink_rename_ok ${slave_mnt}/hardlink_rename  #Stop Geo-rep  TEST $GEOREP_CLI $master $slave stop +#Symlink testcase: Rename symlink and create dir with same name +TEST mkdir ${master_mnt}/symlink_test1 +TEST touch ${master_mnt}/symlink_test1/file1 +TEST ln -s "./file1" ${master_mnt}/symlink_test1/sym_link +TEST mv ${master_mnt}/symlink_test1/sym_link ${master_mnt}/symlink_test1/rn_sym_link +TEST mkdir ${master_mnt}/symlink_test1/sym_link + +#Start Geo-rep +TEST $GEOREP_CLI $master $slave start + +#Check for hardlink rename case. It should not create src file again on +# changelog reprocessing. Refer BUG1296174 +EXPECT_WITHIN $GEO_REP_TIMEOUT 0 hardlink_rename_ok ${slave_mnt}/hardlink_rename_test_file +#symlink rename mkdir +EXPECT_WITHIN $GEO_REP_TIMEOUT 0 symlink_rename_mkdir_ok ${slave_mnt}/symlink_test1 + +#Stop Geo-rep +TEST $GEOREP_CLI $master $slave stop +  #Delete Geo-rep  TEST $GEOREP_CLI $master $slave delete diff --git a/tests/00-geo-rep/georep-basic-dr-tarssh.t b/tests/00-geo-rep/georep-basic-dr-tarssh.t index 81b2a0b21ce..4a6e910e619 100644 --- a/tests/00-geo-rep/georep-basic-dr-tarssh.t +++ b/tests/00-geo-rep/georep-basic-dr-tarssh.t @@ -159,6 +159,25 @@ EXPECT_WITHIN $GEO_REP_TIMEOUT 0 hardlink_rename_ok ${slave_mnt}/hardlink_rename  #Stop Geo-rep  TEST $GEOREP_CLI $master $slave stop +#Symlink testcase: Rename symlink and create dir with same name +TEST mkdir ${master_mnt}/symlink_test1 +TEST touch ${master_mnt}/symlink_test1/file1 +TEST ln -s "./file1" ${master_mnt}/symlink_test1/sym_link +TEST mv ${master_mnt}/symlink_test1/sym_link ${master_mnt}/symlink_test1/rn_sym_link +TEST mkdir ${master_mnt}/symlink_test1/sym_link + +#Start Geo-rep +TEST $GEOREP_CLI $master $slave start + +#Check for hardlink rename case. It should not create src file again on +# changelog reprocessing. Refer BUG1296174 +EXPECT_WITHIN $GEO_REP_TIMEOUT 0 hardlink_rename_ok ${slave_mnt}/hardlink_rename_test_file +#symlink rename mkdir +EXPECT_WITHIN $GEO_REP_TIMEOUT 0 symlink_rename_mkdir_ok ${slave_mnt}/symlink_test1 + +#Stop Geo-rep +TEST $GEOREP_CLI $master $slave stop +  #Delete Geo-rep  TEST $GEOREP_CLI $master $slave delete diff --git a/tests/geo-rep.rc b/tests/geo-rep.rc index a1dfaf8104b..51c63b3a07a 100644 --- a/tests/geo-rep.rc +++ b/tests/geo-rep.rc @@ -92,17 +92,20 @@ function hardlink_file_ok()      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 echo $rc; fi - -    if test $orig_inode != $link_inode -    then -        echo 1 +    if test $rc != 0; then +        echo $rc      else -        echo 0 +        link_inode=$(stat --format "%i" "$link_file") +        rc=$? +        if test $rc != 0; then +            echo $rc +        else +            if test $orig_inode != $link_inode; then +                echo 1 +            else +                echo 0 +            fi +        fi      fi  } @@ -113,8 +116,7 @@ function data_ok()      data2=$(cat $path)      echo "data1:$data1"      echo "data2:$data2" -    if test "X$data1" != "X$data2" -    then +    if test "X$data1" != "X$data2"; then          echo 1      else          echo 0 @@ -134,10 +136,17 @@ function symlink_ok()      local symlink_file=$2      local file_type=$(stat --format "%F" "$symlink_file") -    if test "X$file_type" != "Xsymbolic link"; then echo 1;else echo 0; fi +    if test "X$file_type" != "Xsymbolic link"; then +        echo 1 +    else +        local fname=$(readlink $symlink_file) +        if test "X$fname" != "X$orig_file_name"; then +            echo 1 +        else +            echo 0 +        fi +    fi -    local fname=$(readlink $symlink_file) -    if test "X$fname" != "X$orig_file_name"; then echo 1;else echo 0; fi  }  function rename_ok() @@ -145,27 +154,30 @@ function rename_ok()      old_name=$1      new_name=$2 -    if [ -f $old_name ] -    then +    if [ -f $old_name ]; then          echo 1 -    fi - -    if [ ! -f $new_name ] -    then +    elif [ ! -f $new_name ]; then          echo 1 +    else +        echo 0      fi -    echo 0  }  function create_georep_session()  {      $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 +    if test $rc != 0; then +        echo $rc +    else +        $CLI volume geo-rep $master $slave create push-pem +        rc=$? +        if test $rc != 0; then +            echo $rc +        else +            echo 0 +        fi +    fi  }  # logrotate_simulate should be called (rotate_count + 1) times to cause @@ -214,9 +226,10 @@ function create_rename_ok()      # 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 +        echo 1 +    else +        echo 0      fi -    echo 0  }  function hardlink_rename() @@ -224,16 +237,35 @@ function hardlink_rename()      file_name=$1      echo $file_name > $file_name      ln $file_name $file_name.hl -    mv $file_name.hl $file_name +    mv $file_name.hl $file_name.hl1  }  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 "$file_name.hl" ]; then -            echo 1 +    # to one of its links on changelog reprocessing +    if [ ! -f "$file_name" ]; then +        echo 1 +    elif [ ! -f "$file_name.hl1" ]; then +        echo 1 +    elif [ -f "$file_name.hl" ]; then +        echo 1 +    else +        echo 0 +    fi +} + +function symlink_rename_mkdir_ok() +{ +    sym_dir=$1 +    if [ ! -f $sym_dir/file1 ]; then +        echo 1 +    elif [ ! -h $sym_dir/rn_sym_link ]; then +        echo 1 +    elif [ ! -d $sym_dir/sym_link ]; then +        echo 1 +    else +        echo 0      fi -    echo 0  }  | 
