glusterfs

Форк
0
/
bug-1161311.t 
164 строки · 4.6 Кб
1
#!/bin/bash
2

3
SCRIPT_TIMEOUT=350
4

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.rc
18
. $(dirname $0)/../../volume.rc
19

20
cleanup
21
TEST truncate -s 10GB $B0/brick1
22
TEST truncate -s 10GB $B0/brick2
23
TEST truncate -s 10GB $B0/brick3
24

25
TEST LO1=`SETUP_LOOP $B0/brick1`
26
TEST MKFS_LOOP $LO1
27

28
TEST LO2=`SETUP_LOOP $B0/brick2`
29
TEST MKFS_LOOP $LO2
30

31
TEST LO3=`SETUP_LOOP $B0/brick3`
32
TEST MKFS_LOOP $LO3
33

34
TEST mkdir -p $B0/${V0}1 $B0/${V0}2  $B0/${V0}3
35

36

37
TEST MOUNT_LOOP $LO1 $B0/${V0}1
38
TEST MOUNT_LOOP $LO2 $B0/${V0}2
39
TEST MOUNT_LOOP $LO3 $B0/${V0}3
40

41
checksticky () {
42
	i=0;
43
	while [ ! -k $1 ]; do
44
		sleep 1
45
		i=$((i+1));
46
		# Try for 10 seconds to get the sticky bit state
47
		# else fail the test, as we may never see it
48
		if [[ $i == 10 ]]; then
49
			return $i
50
		fi
51
		echo "Waiting... $i"
52
	done
53
        echo "Done... got out @ $i"
54
	return 0
55
}
56

57

58
TEST glusterd
59
TEST pidof glusterd
60
TEST $CLI volume info;
61

62
TEST $CLI volume create $V0 $H0:$B0/${V0}{1..3};
63

64
EXPECT "$V0" volinfo_field $V0 'Volume Name';
65
EXPECT 'Created' volinfo_field $V0 'Status';
66
EXPECT '3' brick_count $V0
67

68
TEST $CLI volume set $V0 parallel-readdir on
69
TEST $CLI volume start $V0;
70
EXPECT 'Started' volinfo_field $V0 'Status';
71

72
## Mount FUSE with caching disabled (read-write)
73
TEST glusterfs -s $H0 --volfile-id $V0 $M0;
74

75
# Create a directories to hold the links
76
TEST mkdir $M0/dir1
77
TEST mkdir -p $M0/dir2/dir3
78

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.
84
TEST fallocate -l 8G $M0/dir1/FILE2
85

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
90
TEST mv $M0/dir1/FILE2 $M0/dir1/FILE1
91

92
brick_loc=$(get_backend_paths $M0/dir1/FILE1)
93

94
# unmount and remount the volume
95
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
96
TEST glusterfs -s $H0 --volfile-id $V0 $M0;
97

98
# Start the rebalance
99
TEST $CLI volume rebalance $V0 start force
100

101
# Wait for FILE to get the sticky bit on, so that file is under
102
# active rebalance, before creating the links
103
TEST checksticky $brick_loc
104

105
# Create the links
106
## FILE3 FILE5 FILE7 have hashes, c8c91469 566d26ce 22ce7eba
107
## Which fall into separate bricks on a 3 brick layout
108
cd $M0
109
TEST ln ./dir1/FILE1 ./dir1/FILE7
110
TEST ln ./dir1/FILE1 ./dir1/FILE5
111
TEST ln ./dir1/FILE1 ./dir1/FILE3
112

113
TEST ln ./dir1/FILE1 ./dir2/FILE7
114
TEST ln ./dir1/FILE1 ./dir2/FILE5
115
TEST ln ./dir1/FILE1 ./dir2/FILE3
116

117
TEST ln ./dir1/FILE1 ./dir2/dir3/FILE7
118
TEST ln ./dir1/FILE1 ./dir2/dir3/FILE5
119
TEST ln ./dir1/FILE1 ./dir2/dir3/FILE3
120
cd /
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
124
TEST checksticky $brick_loc
125

126
# Wait for rebalance to complete
127
EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0
128

129
# Check if all files are clean and migrated right
130
## stat on the original file should show linkcount of 10
131
linkcountsrc=$(stat -c %h $M0/dir1/FILE1)
132
TEST [[ $linkcountsrc == 10 ]]
133

134
## inode and size of every file should be same as original file
135
inodesrc=$(stat -c %i $M0/dir1/FILE1)
136
TEST [[ $(stat -c %i $M0/dir1/FILE3) == $inodesrc ]]
137
TEST [[ $(stat -c %i $M0/dir1/FILE5) == $inodesrc ]]
138
TEST [[ $(stat -c %i $M0/dir1/FILE7) == $inodesrc ]]
139

140
TEST [[ $(stat -c %i $M0/dir2/FILE3) == $inodesrc ]]
141
TEST [[ $(stat -c %i $M0/dir2/FILE5) == $inodesrc ]]
142
TEST [[ $(stat -c %i $M0/dir2/FILE7) == $inodesrc ]]
143

144
TEST [[ $(stat -c %i $M0/dir2/dir3/FILE3) == $inodesrc ]]
145
TEST [[ $(stat -c %i $M0/dir2/dir3/FILE5) == $inodesrc ]]
146
TEST [[ $(stat -c %i $M0/dir2/dir3/FILE7) == $inodesrc ]]
147

148
# Check, newer link creations
149
cd $M0
150
TEST ln ./dir1/FILE1 ./FILE1
151
TEST ln ./dir2/FILE3 ./FILE3
152
TEST ln ./dir2/dir3/FILE5 ./FILE5
153
TEST ln ./dir1/FILE7 ./FILE7
154
cd /
155
linkcountsrc=$(stat -c %h $M0/dir1/FILE1)
156
TEST [[ $linkcountsrc == 14 ]]
157

158

159
# Stop the volume
160
TEST $CLI volume stop $V0;
161

162
UMOUNT_LOOP ${B0}/${V0}{1..3}
163
rm -f ${B0}/brick{1..3}
164
cleanup;
165

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

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

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

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