5
function check_mounted () {
9
function check_status_num_rows()
12
$GEOREP_CLI $primary $secondary status | grep -F "$search_key" | wc -l
15
function check_fanout_status_num_rows()
18
$GEOREP_CLI $primary status | grep -F "$search_key" | wc -l
21
function check_fanout_status_detail_num_rows()
24
$GEOREP_CLI $primary status detail | grep -F "$search_key" | wc -l
27
function check_all_status_num_rows()
30
$GEOREP_CLI status | grep -F "$search_key" | wc -l
33
function check_all_status_detail_num_rows()
36
$GEOREP_CLI status detail | grep -F "$search_key" | wc -l
39
function verify_checkpoint_met()
43
$GEOREP_CLI $primary $secondary status detail| grep -F "Yes" | wc -l
46
function check_keys_distributed()
48
local search_key=$(cat /var/lib/glusterd/geo-replication/primary_secondary_common_secret.pem.pub)
49
grep -F "$search_key" ~/.ssh/authorized_keys > /dev/null
53
function check_common_secret_file()
55
stat /var/lib/glusterd/geo-replication/primary_secondary_common_secret.pem.pub
59
function create_rename_symlink_case()
61
mkdir ${primary_mnt}/MUL_REN_SYMLINK
62
cd ${primary_mnt}/MUL_REN_SYMLINK
88
echo "HelloWorld!" > ${primary_mnt}/${prefix}_f1
89
touch ${primary_mnt}/${prefix}_f2
90
touch ${primary_mnt}/${prefix}_f3
92
# non-ascii filename test
93
echo "Hello non-ascii" > ${primary_mnt}/${prefix}_f1_ಸಂತಸ
94
touch ${primary_mnt}/${prefix}_f2_ಸಂತಸ
95
touch ${primary_mnt}/${prefix}_f3_ಸಂತಸ
98
mkdir ${primary_mnt}/${prefix}_d1
99
mkdir ${primary_mnt}/${prefix}_d2
100
mkdir ${primary_mnt}/${prefix}_d3
102
# non-ascii dir and filename test
103
mkdir ${primary_mnt}/${prefix}_d1_ನನ್ನ
104
mkdir ${primary_mnt}/${prefix}_d2_ಸಂತಸ
105
mkdir ${primary_mnt}/${prefix}_d3_ಸಂತಸ
106
echo "Hello non-ascii" > ${primary_mnt}/${prefix}_d1_ನನ್ನ/ಸಂತಸ
108
# Hardlink + non-ascii name
109
ln ${primary_mnt}/${prefix}_f1 ${primary_mnt}/${prefix}_hl1
110
ln ${primary_mnt}/${prefix}_f1 ${primary_mnt}/${prefix}_hl1_ಸಂತಸ
114
ln -s ${prefix}_f1 ${prefix}_sl1
115
ln -s ${prefix}_f1 ${prefix}_sl1_ಸಂತಸ
119
rm ${primary_mnt}/${prefix}_f2
120
rm ${primary_mnt}/${prefix}_f2_ಸಂತಸ
123
rmdir ${primary_mnt}/${prefix}_d2
124
rmdir ${primary_mnt}/${prefix}_d2_ಸಂತಸ
127
mv ${primary_mnt}/${prefix}_f3 ${primary_mnt}/${prefix}_f4
128
mv ${primary_mnt}/${prefix}_f3_ಸಂತಸ ${primary_mnt}/${prefix}_f4_ಸಂತಸ
131
mv ${primary_mnt}/${prefix}_d3 ${primary_mnt}/${prefix}_d4
132
mv ${primary_mnt}/${prefix}_d3_ಸಂತಸ ${primary_mnt}/${prefix}_d4_ಸಂತಸ
135
touch ${primary_mnt}/${prefix}_chown_f1
136
chown 1000:1000 ${primary_mnt}/${prefix}_chown_f1
137
touch ${primary_mnt}/${prefix}_chown_f1_ಸಂತಸ
138
chown 1000:1000 ${primary_mnt}/${prefix}_chown_f1_ಸಂತಸ
141
function create_data_hang()
144
mkdir ${primary_mnt}/${prefix}
145
cd ${primary_mnt}/${prefix}
146
# ~1k files is required with 1 sync-job and hang happens if
147
# stderr buffer of tar/ssh executed with Popen is full (i.e., 64k).
148
# 64k is hit when ~800 files were not found while syncing data
149
# from primary. So around 1k files is required to hit the condition.
152
echo "test data" > file$i
158
function chown_file_ok()
160
local file_owner=$(stat --format "%u:%g" "$1")
161
if test "X$file_owner" != "X1000:1000"; then echo 1; else echo 0; fi
164
function regular_file_ok()
166
local file_type=$(stat --format "%F" "$1")
167
if test "X$file_type" != "Xregular file"; then echo 1; else echo 0; fi
170
function directory_ok()
172
file_type=$(stat --format "%F" "$1")
173
if test "X$file_type" != "Xdirectory"; then echo 1; else echo 0; fi
178
stat "$1" > /dev/null 2>&1
183
function hardlink_file_ok()
188
orig_inode=$(stat --format "%i" "$orig_file")
190
if test $rc != 0; then
193
link_inode=$(stat --format "%i" "$link_file")
195
if test $rc != 0; then
198
if test $orig_inode != $link_inode; then
214
if test "X$data1" != "X$data2"; then
221
function arequal_checksum()
225
ret=$(diff <(arequal-checksum -p $primary) <(arequal-checksum -p $secondary) | wc -l)
231
local orig_file_name=$1
232
local symlink_file=$2
234
local file_type=$(stat --format "%F" "$symlink_file")
235
if test "X$file_type" != "Xsymbolic link"; then
238
local fname=$(readlink $symlink_file)
239
if test "X$fname" != "X$orig_file_name"; then
248
function rename_file_ok()
253
if [ -f $old_name ]; then
255
elif [ ! -f $new_name ]; then
262
function rename_dir_ok()
267
if [ -d $old_name ]; then
269
elif [ ! -d $new_name ]; then
276
function create_georep_session()
278
$CLI system:: execute gsec_create
280
if test $rc != 0; then
283
$CLI volume geo-rep $primary $secondary create push-pem
285
if test $rc != 0; then
293
# logrotate_simulate should be called (rotate_count + 1) times to cause
294
# an unlink and a gfid re-allocation.
295
# remember to keep the file name and rotate_count the same across the
297
function logrotate_simulate()
300
declare -i rotate_count=$2
302
while [ $rotate_count -ge 0 ]; do
303
source_file="$file_name.$((rotate_count))"
304
if [ $rotate_count -eq 0 ]; then
305
source_file="$file_name"
307
if [ -f "${source_file}" ]; then
308
mv "${source_file}" "$file_name.$((rotate_count+1))"
313
# logrotate causes gfid to be rellocated to a new file created
314
# after an unlink and a blind rename later causes georep session
316
# this should not happen if source basename on secondary is tested
317
# to be linked with its own gfid as on primary, before invoking
321
unlink_file_name="$file_name.$((rotate_count+1))"
322
unlink $unlink_file_name 2>/dev/null
325
function create_rename()
328
echo $file_name > $file_name
329
mv $file_name $file_name.bak
332
function create_rename_ok()
335
# after a log replay, we don't expect the original file
336
# to be recreated i.e. a dangling entry without a corresponding
337
# back-end gfid link should not exist on the secondary
338
if [ -f "$file_name" ]; then
345
function hardlink_rename()
348
echo $file_name > $file_name
349
ln $file_name $file_name.hl
350
mv $file_name.hl $file_name.hl1
353
function hardlink_rename_ok()
356
# the hardlink file should not exist on the secondary after renaming
357
# to one of its links on changelog reprocessing
358
if [ ! -f "$file_name" ]; then
360
elif [ ! -f "$file_name.hl1" ]; then
362
elif [ -f "$file_name.hl" ]; then
369
function create_symlink_rename_mkdir_data()
371
mkdir ${primary_mnt}/symlink_test1
372
touch ${primary_mnt}/symlink_test1/file1
373
ln -s "./file1" ${primary_mnt}/symlink_test1/sym_link
374
mv ${primary_mnt}/symlink_test1/sym_link ${primary_mnt}/symlink_test1/rn_sym_link
375
mkdir ${primary_mnt}/symlink_test1/sym_link
377
function verify_symlink_rename_mkdir_data()
380
if [ ! -f $sym_dir/file1 ]; then
382
elif [ ! -h $sym_dir/rn_sym_link ]; then
384
elif [ ! -d $sym_dir/sym_link ]; then
391
function create_rsnapshot_data()
393
rm -rf /tmp/rsnapshot_symlinkbug
394
mkdir /tmp/rsnapshot_symlinkbug
395
ln -f -s /does/not/exist /tmp/rsnapshot_symlinkbug/a_symlink
396
rsync -a /tmp/rsnapshot_symlinkbug ${primary_mnt}/
397
cp -al ${primary_mnt}/rsnapshot_symlinkbug ${primary_mnt}/rsnapshot_symlinkbug.0
398
ln -f -s /does/not/exist2 /tmp/rsnapshot_symlinkbug/a_symlink
399
rsync -a /tmp/rsnapshot_symlinkbug ${primary_mnt}/
400
cp -al ${primary_mnt}/rsnapshot_symlinkbug ${primary_mnt}/rsnapshot_symlinkbug.1
403
function verify_rsnapshot_data()
405
dir="$1/rsnapshot_symlinkbug"
406
dir0="$1/rsnapshot_symlinkbug.0"
407
dir1="$1/rsnapshot_symlinkbug.1"
408
if [ ! -d "$dir" ]; then
410
elif [ ! -h $dir/a_symlink ]; then
412
elif test "X$(readlink $dir/a_symlink)" != "X/does/not/exist2"; then
414
elif [ ! -h $dir0/a_symlink ]; then
416
elif test "X$(readlink $dir0/a_symlink)" != "X/does/not/exist"; then
418
elif [ ! -h $dir1/a_symlink ]; then
420
elif test "X$(readlink $dir1/a_symlink)" != "X/does/not/exist2"; then
427
function create_hardlink_rename_data()
429
dir=${primary_mnt}/hardlink_rename_issue
431
echo "test_data" > $dir/f1
437
function verify_hardlink_rename_data()
439
dir=$1/hardlink_rename_issue
440
if [ ! -d $dir ]; then
442
elif [ -f $dir/f1 ]; then
444
elif [ -f $dir/f2 ]; then
446
elif [ ! -f $dir/f3 ]; then
448
elif test "Xtest_data" != "X$(cat $dir/f3)"; then
455
function check_secondary_read_only()
458
gluster volume info $1 | grep 'features.read-only: on'
462
function create_rename_with_existing_destination()
464
dir=$1/rename_with_existing_destination
468
echo "Data_set$i" > $dir/data_set$i
469
mv $dir/data_set$i $dir/data_set -f
473
function verify_rename_with_existing_destination()
475
dir=$1/rename_with_existing_destination
477
if [ ! -d $dir ]; then
479
elif [ ! -f $dir/data_set ]; then
481
elif [ -f $dir/data_set1 ]; then
483
elif [ -f $dir/data_set2 ]; then
485
elif [ -f $dir/data_set3 ]; then
487
elif [ -f $dir/data_set4 ]; then
489
elif [ -f $dir/data_set5 ]; then
491
elif test "XData_set5" != "X$(cat $dir/data_set)"; then