glusterfs
164 строки · 4.6 Кб
1#!/bin/bash
2
3SCRIPT_TIMEOUT=3504
5# This tests for hard link preservation for files that are linked, when the
6# file is undergoing migration
7
8# --- Improvements and other tests ---
9## Fail rebalance of the large file for which links are created during P1/2
10### phases of migration
11## Start with multiple hard links to the file and then create more during P1/2
12### phases of migration
13## Test the same with NFS as the mount rather than FUSE
14## Create links when file is under P2 of migration specifically
15## Test with quota, to error out during hard link creation (if possible)
16
17. $(dirname $0)/../../include.rc18. $(dirname $0)/../../volume.rc19
20cleanup
21TEST truncate -s 10GB $B0/brick122TEST truncate -s 10GB $B0/brick223TEST truncate -s 10GB $B0/brick324
25TEST LO1=`SETUP_LOOP $B0/brick1`26TEST MKFS_LOOP $LO127
28TEST LO2=`SETUP_LOOP $B0/brick2`29TEST MKFS_LOOP $LO230
31TEST LO3=`SETUP_LOOP $B0/brick3`32TEST MKFS_LOOP $LO333
34TEST mkdir -p $B0/${V0}1 $B0/${V0}2 $B0/${V0}335
36
37TEST MOUNT_LOOP $LO1 $B0/${V0}138TEST MOUNT_LOOP $LO2 $B0/${V0}239TEST MOUNT_LOOP $LO3 $B0/${V0}340
41checksticky () {42i=0;43while [ ! -k $1 ]; do44sleep 145i=$((i+1));46# Try for 10 seconds to get the sticky bit state47# else fail the test, as we may never see it48if [[ $i == 10 ]]; then49return $i50fi51echo "Waiting... $i"52done53echo "Done... got out @ $i"54return 055}
56
57
58TEST glusterd
59TEST pidof glusterd
60TEST $CLI volume info;61
62TEST $CLI volume create $V0 $H0:$B0/${V0}{1..3};63
64EXPECT "$V0" volinfo_field $V0 'Volume Name';65EXPECT 'Created' volinfo_field $V0 'Status';66EXPECT '3' brick_count $V067
68TEST $CLI volume set $V0 parallel-readdir on69TEST $CLI volume start $V0;70EXPECT 'Started' volinfo_field $V0 'Status';71
72## Mount FUSE with caching disabled (read-write)
73TEST glusterfs -s $H0 --volfile-id $V0 $M0;74
75# Create a directories to hold the links
76TEST mkdir $M0/dir177TEST mkdir -p $M0/dir2/dir378
79# Create a large file (8 GB), so that rebalance takes time
80# Since we really don't care about the contents of the file, we use fallocate
81# to generate the file much faster. We could also use truncate, which is even
82# faster, but rebalance could take advantage of an sparse file and migrate it
83# in an optimized way, but we don't want a fast migration.
84TEST fallocate -l 8G $M0/dir1/FILE285
86# Rename the file to create a linkto, for rebalance to
87# act on the file
88## FILE1 and FILE2 hashes are, 678b1c4a e22c1ada, so they fall
89## into separate bricks when brick count is 3
90TEST mv $M0/dir1/FILE2 $M0/dir1/FILE191
92brick_loc=$(get_backend_paths $M0/dir1/FILE1)93
94# unmount and remount the volume
95EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M096TEST glusterfs -s $H0 --volfile-id $V0 $M0;97
98# Start the rebalance
99TEST $CLI volume rebalance $V0 start force100
101# Wait for FILE to get the sticky bit on, so that file is under
102# active rebalance, before creating the links
103TEST checksticky $brick_loc104
105# Create the links
106## FILE3 FILE5 FILE7 have hashes, c8c91469 566d26ce 22ce7eba
107## Which fall into separate bricks on a 3 brick layout
108cd $M0109TEST ln ./dir1/FILE1 ./dir1/FILE7110TEST ln ./dir1/FILE1 ./dir1/FILE5111TEST ln ./dir1/FILE1 ./dir1/FILE3112
113TEST ln ./dir1/FILE1 ./dir2/FILE7114TEST ln ./dir1/FILE1 ./dir2/FILE5115TEST ln ./dir1/FILE1 ./dir2/FILE3116
117TEST ln ./dir1/FILE1 ./dir2/dir3/FILE7118TEST ln ./dir1/FILE1 ./dir2/dir3/FILE5119TEST ln ./dir1/FILE1 ./dir2/dir3/FILE3120cd /121
122# Ideally for this test to have done its job, the file should still be
123# under migration, so check the sticky bit again
124TEST checksticky $brick_loc125
126# Wait for rebalance to complete
127EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0128
129# Check if all files are clean and migrated right
130## stat on the original file should show linkcount of 10
131linkcountsrc=$(stat -c %h $M0/dir1/FILE1)132TEST [[ $linkcountsrc == 10 ]]133
134## inode and size of every file should be same as original file
135inodesrc=$(stat -c %i $M0/dir1/FILE1)136TEST [[ $(stat -c %i $M0/dir1/FILE3) == $inodesrc ]]137TEST [[ $(stat -c %i $M0/dir1/FILE5) == $inodesrc ]]138TEST [[ $(stat -c %i $M0/dir1/FILE7) == $inodesrc ]]139
140TEST [[ $(stat -c %i $M0/dir2/FILE3) == $inodesrc ]]141TEST [[ $(stat -c %i $M0/dir2/FILE5) == $inodesrc ]]142TEST [[ $(stat -c %i $M0/dir2/FILE7) == $inodesrc ]]143
144TEST [[ $(stat -c %i $M0/dir2/dir3/FILE3) == $inodesrc ]]145TEST [[ $(stat -c %i $M0/dir2/dir3/FILE5) == $inodesrc ]]146TEST [[ $(stat -c %i $M0/dir2/dir3/FILE7) == $inodesrc ]]147
148# Check, newer link creations
149cd $M0150TEST ln ./dir1/FILE1 ./FILE1151TEST ln ./dir2/FILE3 ./FILE3152TEST ln ./dir2/dir3/FILE5 ./FILE5153TEST ln ./dir1/FILE7 ./FILE7154cd /155linkcountsrc=$(stat -c %h $M0/dir1/FILE1)156TEST [[ $linkcountsrc == 14 ]]157
158
159# Stop the volume
160TEST $CLI volume stop $V0;161
162UMOUNT_LOOP ${B0}/${V0}{1..3}163rm -f ${B0}/brick{1..3}164cleanup;165