glusterfs

Форк
0
/
geo-rep.rc 
496 строк · 11.6 Кб
1
# clang-format off
2
GEO_REP_TIMEOUT=120
3
CHECK_MOUNT_TIMEOUT=50
4
#check for mount point
5
function check_mounted () {
6
  df | grep $1 | wc -l
7
}
8

9
function check_status_num_rows()
10
{
11
    local search_key=$1
12
    $GEOREP_CLI $primary $secondary status | grep -F "$search_key" | wc -l
13
}
14

15
function check_fanout_status_num_rows()
16
{
17
    local search_key=$1
18
    $GEOREP_CLI $primary status | grep -F "$search_key" | wc -l
19
}
20

21
function check_fanout_status_detail_num_rows()
22
{
23
    local search_key=$1
24
    $GEOREP_CLI $primary status detail | grep -F "$search_key" | wc -l
25
}
26

27
function check_all_status_num_rows()
28
{
29
    local search_key=$1
30
    $GEOREP_CLI status | grep -F "$search_key" | wc -l
31
}
32

33
function check_all_status_detail_num_rows()
34
{
35
    local search_key=$1
36
    $GEOREP_CLI status detail | grep -F "$search_key" | wc -l
37
}
38

39
function verify_checkpoint_met()
40
{
41
    local primary=$1
42
    local secondary=$2
43
    $GEOREP_CLI $primary $secondary status detail| grep -F "Yes" | wc -l
44
}
45

46
function check_keys_distributed()
47
{
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
50
    echo $?
51
}
52

53
function check_common_secret_file()
54
{
55
    stat /var/lib/glusterd/geo-replication/primary_secondary_common_secret.pem.pub
56
    echo $?
57
}
58

59
function create_rename_symlink_case()
60
{
61
    mkdir ${primary_mnt}/MUL_REN_SYMLINK
62
    cd ${primary_mnt}/MUL_REN_SYMLINK
63
    mkdir sym_dir1
64
    ln -s "sym_dir1" sym1
65
    mv sym1 sym2
66
    mv sym2 sym3
67
    mv sym3 sym4
68
    cd -
69
}
70

71
function create_data()
72
{
73
    prefix=$1
74

75
    # GF_FOP_MKNOD
76
    # GF_FOP_MKDIR
77
    # GF_FOP_UNLINK
78
    # GF_FOP_RMDIR
79
    # GF_FOP_SYMLINK
80
    # GF_FOP_RENAME
81
    # GF_FOP_LINK
82
    # GF_FOP_SETXATTR
83
    # GF_FOP_REMOVEXATTR
84
    # GF_FOP_CREATE
85
    # GF_FOP_SETATTR
86

87
    # Regular file + data
88
    echo "HelloWorld!" > ${primary_mnt}/${prefix}_f1
89
    touch ${primary_mnt}/${prefix}_f2
90
    touch ${primary_mnt}/${prefix}_f3
91

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_ಸಂತಸ
96

97
    # dir
98
    mkdir ${primary_mnt}/${prefix}_d1
99
    mkdir ${primary_mnt}/${prefix}_d2
100
    mkdir ${primary_mnt}/${prefix}_d3
101

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_ನನ್ನ/ಸಂತಸ
107

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_ಸಂತಸ
111

112
    # Symlink
113
    cd ${primary_mnt}
114
    ln -s ${prefix}_f1 ${prefix}_sl1
115
    ln -s ${prefix}_f1 ${prefix}_sl1_ಸಂತಸ
116
    cd -
117

118
    # UNLINK
119
    rm ${primary_mnt}/${prefix}_f2
120
    rm ${primary_mnt}/${prefix}_f2_ಸಂತಸ
121

122
    # RMDIR
123
    rmdir ${primary_mnt}/${prefix}_d2
124
    rmdir ${primary_mnt}/${prefix}_d2_ಸಂತಸ
125

126
    # Rename - File
127
    mv ${primary_mnt}/${prefix}_f3 ${primary_mnt}/${prefix}_f4
128
    mv ${primary_mnt}/${prefix}_f3_ಸಂತಸ  ${primary_mnt}/${prefix}_f4_ಸಂತಸ
129

130
    # Rename - Dir
131
    mv ${primary_mnt}/${prefix}_d3 ${primary_mnt}/${prefix}_d4
132
    mv ${primary_mnt}/${prefix}_d3_ಸಂತಸ  ${primary_mnt}/${prefix}_d4_ಸಂತಸ
133

134
    # chown
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_ಸಂತಸ
139
}
140

141
function create_data_hang()
142
{
143
    prefix=$1
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.
150
    for i in {1..1000}
151
    do
152
        echo "test data" > file$i
153
        mv -f file$i file
154
    done
155
    cd -
156
}
157

158
function chown_file_ok()
159
{
160
    local file_owner=$(stat --format "%u:%g" "$1")
161
    if test "X$file_owner" != "X1000:1000"; then echo 1; else echo 0; fi
162
}
163

164
function regular_file_ok()
165
{
166
    local file_type=$(stat --format "%F" "$1")
167
    if test "X$file_type" != "Xregular file"; then echo 1; else echo 0; fi
168
}
169

170
function directory_ok()
171
{
172
    file_type=$(stat --format "%F" "$1")
173
    if test "X$file_type" != "Xdirectory"; then echo 1; else echo 0; fi
174
}
175

176
function unlink_ok()
177
{
178
    stat "$1" > /dev/null 2>&1
179
    rc=$?
180
    echo $rc
181
}
182

183
function hardlink_file_ok()
184
{
185
    orig_file=$1
186
    link_file=$2
187

188
    orig_inode=$(stat --format "%i" "$orig_file")
189
    rc=$?
190
    if test $rc != 0; then
191
        echo $rc
192
    else
193
        link_inode=$(stat --format "%i" "$link_file")
194
        rc=$?
195
        if test $rc != 0; then
196
            echo $rc
197
        else
198
            if test $orig_inode != $link_inode; then
199
                echo 1
200
            else
201
                echo 0
202
            fi
203
        fi
204
    fi
205
}
206

207
function data_ok()
208
{
209
    path=$1
210
    data1="$2"
211
    data2=$(cat $path)
212
    echo "data1:$data1"
213
    echo "data2:$data2"
214
    if test "X$data1" != "X$data2"; then
215
        echo 1
216
    else
217
        echo 0
218
    fi
219
}
220

221
function arequal_checksum()
222
{
223
    primary=$1
224
    secondary=$2
225
    ret=$(diff <(arequal-checksum -p $primary) <(arequal-checksum -p $secondary) | wc -l)
226
    echo x$ret
227
}
228

229
function symlink_ok()
230
{
231
    local orig_file_name=$1
232
    local symlink_file=$2
233

234
    local file_type=$(stat --format "%F" "$symlink_file")
235
    if test "X$file_type" != "Xsymbolic link"; then
236
        echo 1
237
    else
238
        local fname=$(readlink $symlink_file)
239
        if test "X$fname" != "X$orig_file_name"; then
240
            echo 2
241
        else
242
            echo 0
243
        fi
244
    fi
245

246
}
247

248
function rename_file_ok()
249
{
250
    old_name=$1
251
    new_name=$2
252

253
    if [ -f $old_name ]; then
254
        echo 1
255
    elif [ ! -f $new_name ]; then
256
        echo 2
257
    else
258
        echo 0
259
    fi
260
}
261

262
function rename_dir_ok()
263
{
264
    old_name=$1
265
    new_name=$2
266

267
    if [ -d $old_name ]; then
268
        echo 1
269
    elif [ ! -d $new_name ]; then
270
        echo 2
271
    else
272
        echo 0
273
    fi
274
}
275

276
function create_georep_session()
277
{
278
    $CLI system:: execute gsec_create
279
    rc=$?
280
    if test $rc != 0; then
281
        echo $rc
282
    else
283
        $CLI volume geo-rep $primary $secondary create push-pem
284
        rc=$?
285
        if test $rc != 0; then
286
            echo $rc
287
        else
288
            echo 0
289
        fi
290
    fi
291
}
292

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
296
# calls
297
function logrotate_simulate()
298
{
299
    file_name=$1
300
    declare -i rotate_count=$2
301

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"
306
        fi
307
        if [ -f "${source_file}" ]; then
308
                mv "${source_file}" "$file_name.$((rotate_count+1))"
309
        fi
310
        ((rotate_count--))
311
    done
312

313
    # logrotate causes gfid to be rellocated to a new file created
314
    # after an unlink and a blind rename later causes georep session
315
    # to go Faulty
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
318
    # the rename syscall
319
    touch $file_name
320
    rotate_count=$2
321
    unlink_file_name="$file_name.$((rotate_count+1))"
322
    unlink $unlink_file_name 2>/dev/null
323
}
324

325
function create_rename()
326
{
327
    file_name=$1
328
    echo $file_name > $file_name
329
    mv $file_name $file_name.bak
330
}
331

332
function create_rename_ok()
333
{
334
    file_name=$1
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
339
        echo 1
340
    else
341
        echo 0
342
    fi
343
}
344

345
function hardlink_rename()
346
{
347
    file_name=$1
348
    echo $file_name > $file_name
349
    ln $file_name $file_name.hl
350
    mv $file_name.hl $file_name.hl1
351
}
352

353
function hardlink_rename_ok()
354
{
355
    file_name=$1
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
359
        echo 1
360
    elif [ ! -f "$file_name.hl1" ]; then
361
        echo 2
362
    elif [ -f "$file_name.hl" ]; then
363
        echo 3
364
    else
365
        echo 0
366
    fi
367
}
368

369
function create_symlink_rename_mkdir_data()
370
{
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
376
}
377
function verify_symlink_rename_mkdir_data()
378
{
379
    sym_dir=$1
380
    if [ ! -f $sym_dir/file1 ]; then
381
        echo 1
382
    elif [ ! -h $sym_dir/rn_sym_link ]; then
383
        echo 2
384
    elif [ ! -d $sym_dir/sym_link ]; then
385
        echo 3
386
    else
387
        echo 0
388
    fi
389
}
390

391
function create_rsnapshot_data()
392
{
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
401
}
402

403
function verify_rsnapshot_data()
404
{
405
    dir="$1/rsnapshot_symlinkbug"
406
    dir0="$1/rsnapshot_symlinkbug.0"
407
    dir1="$1/rsnapshot_symlinkbug.1"
408
    if [ ! -d "$dir" ]; then
409
        echo 1
410
    elif [ ! -h $dir/a_symlink ]; then
411
        echo 2
412
    elif test "X$(readlink $dir/a_symlink)" != "X/does/not/exist2"; then
413
        echo 3
414
    elif [ ! -h $dir0/a_symlink ]; then
415
        echo 4
416
    elif test "X$(readlink $dir0/a_symlink)" != "X/does/not/exist"; then
417
        echo 5
418
    elif [ ! -h $dir1/a_symlink ]; then
419
        echo 6
420
    elif test "X$(readlink $dir1/a_symlink)" != "X/does/not/exist2"; then
421
        echo 7
422
    else
423
        echo 0
424
    fi
425
}
426

427
function create_hardlink_rename_data()
428
{
429
    dir=${primary_mnt}/hardlink_rename_issue
430
    mkdir $dir
431
    echo "test_data" > $dir/f1
432
    ln $dir/f1 $dir/f2
433
    mv $dir/f2 $dir/f3
434
    unlink $dir/f1
435
}
436

437
function verify_hardlink_rename_data()
438
{
439
    dir=$1/hardlink_rename_issue
440
    if [ ! -d $dir ]; then
441
        echo 1
442
    elif [ -f $dir/f1 ]; then
443
        echo 2
444
    elif [ -f $dir/f2 ]; then
445
        echo 3
446
    elif [ ! -f $dir/f3 ]; then
447
        echo 4
448
    elif test "Xtest_data" != "X$(cat $dir/f3)"; then
449
        echo 5
450
    else
451
        echo 0
452
    fi
453
}
454

455
function check_secondary_read_only()
456
{
457
    volum=$1
458
    gluster volume info $1 | grep 'features.read-only: on'
459
    echo $?
460
}
461

462
function create_rename_with_existing_destination()
463
{
464
    dir=$1/rename_with_existing_destination
465
    mkdir $dir
466
    for i in {1..5}
467
    do
468
        echo "Data_set$i" > $dir/data_set$i
469
        mv $dir/data_set$i $dir/data_set -f
470
    done
471
}
472

473
function verify_rename_with_existing_destination()
474
{
475
    dir=$1/rename_with_existing_destination
476

477
    if [ ! -d $dir ]; then
478
        echo 1
479
    elif [ ! -f $dir/data_set ]; then
480
        echo 2
481
    elif [ -f $dir/data_set1 ]; then
482
        echo 3
483
    elif [ -f $dir/data_set2 ]; then
484
        echo 4
485
    elif [ -f $dir/data_set3 ]; then
486
        echo 5
487
    elif [ -f $dir/data_set4 ]; then
488
        echo 6
489
    elif [ -f $dir/data_set5 ]; then
490
        echo 7
491
    elif test "XData_set5" != "X$(cat $dir/data_set)"; then
492
        echo 8
493
    else
494
        echo 0
495
    fi
496
}
497

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.