glusterfs

Форк
0
/
unhashed-auto.t 
125 строк · 3.5 Кб
1
#!/bin/bash
2

3
. $(dirname $0)/../include.rc
4
. $(dirname $0)/../volume.rc
5
. $(dirname $0)/../dht.rc
6

7
NFILES=100
8

9
touch_files () {
10
	for i in $(seq 1 $NFILES); do
11
		touch $(printf $M0/dir/file%02d $i)
12
	done
13
}
14

15
count_files () {
16
	found=0
17
	for i in $(seq 1 $NFILES); do
18
		if [ -f $(printf $M0/dir/file%02d $i) ]; then
19
			found=$((found+1))
20
		fi
21
	done
22
	echo "found $found files" > /dev/tty
23
	echo $found
24
}
25

26
wait_for_rebalance () {
27
	while true; do
28
		tmp=$(rebalance_completed)
29
		if [ $tmp -eq 1 ]; then
30
			sleep 1
31
		else
32
			break
33
		fi
34
	done
35
}
36

37
get_xattr () {
38
	cmd="getfattr --absolute-names --only-values -n trusted.glusterfs.dht"
39
	$cmd $1 | od -tx1 -An | tr -d ' '
40
}
41

42
get_xattr_hash () {
43
        cmd="getfattr --absolute-names --only-values -n trusted.glusterfs.dht"
44
        $cmd $1 | od -tx1 -An | awk '{printf("%s%s%s%s\n", $1, $2, $3, $4);}'
45
}
46

47
cleanup
48

49
TEST glusterd
50
TEST pidof glusterd
51
TEST $CLI volume info
52

53
TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}
54
EXPECT "$V0" volinfo_field $V0 'Volume Name'
55
EXPECT 'Created' volinfo_field $V0 'Status'
56

57
TEST $CLI volume set $V0 cluster.lookup-optimize ON
58

59
TEST $CLI volume start $V0
60
EXPECT 'Started' volinfo_field $V0 'Status'
61

62
# Create some files for later tests.
63
TEST $GFS -s $H0 --volfile-id $V0 $M0
64
TEST mkdir $M0/dir
65
TEST touch_files
66
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
67

68
# Add a brick and do the fix-layout part of rebalance to update directory layouts
69
# (including their directory commit hashes).
70
TEST $CLI volume add-brick $V0 $H0:$B0/${V0}3
71
EXPECT '3' brick_count $V0
72
TEST $CLI volume rebalance $V0 fix-layout start
73
TEST wait_for_rebalance
74

75
# Now for the sneaky part.  *Undo* the part of rebalance that updated the volume
76
# commit hash, forcing a false match between that and the directory commit hashes.
77
TEST setfattr -x trusted.glusterfs.dht.commithash $B0/${V0}1
78
TEST setfattr -x trusted.glusterfs.dht.commithash $B0/${V0}2
79
TEST setfattr -x trusted.glusterfs.dht.commithash $B0/${V0}3
80

81
# Mount and check that we do *not* see all of the files.  This indicates that we
82
# correctly skipped the broadcast lookup that would have found them.
83
TEST $GFS -s $H0 --volfile-id $V0 $M0
84
TEST [ $(count_files) -ne 100 ]
85
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
86

87
# Do the fix-layout again to generate a new volume commit hash.
88
TEST $CLI volume rebalance $V0 fix-layout start
89
TEST wait_for_rebalance
90

91
# Mount and check that we *do* see all of the files.  This indicates that we saw
92
# the mismatch and did the broadcast lookup this time.
93
TEST $GFS -s $H0 --volfile-id $V0 $M0
94
TEST [ $(count_files) -eq 100 ]
95
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
96

97
# Do a *full* rebalance and verify that the directory commit hash changed.
98
old_val=$(get_xattr $B0/${V0}1/dir)
99
TEST $CLI volume rebalance $V0 start
100
TEST wait_for_rebalance
101
new_val=$(get_xattr $B0/${V0}1/dir)
102
TEST [ ! x"$old_val" = x"$new_val" ]
103

104
# Force an anomoly on an existing layout and heal it
105
## The healed layout should not carry a commit-hash (or should carry 1 in the
106
## commit-hash)
107
TEST setfattr -x trusted.glusterfs.dht $B0/${V0}1/dir
108
TEST $GFS -s $H0 --volfile-id $V0 $M0
109
TEST [ -d $M0/dir ]
110
new_hash=$(get_xattr_hash $B0/${V0}1/dir)
111
TEST [ x"$new_hash" = x"00000001" ]
112
new_hash=$(get_xattr_hash $B0/${V0}2/dir)
113
TEST [ x"$new_hash" = x"00000001" ]
114

115
# Unset the option and check that newly created directories get 1 in the
116
# disk layout
117
TEST $CLI volume set $V0 cluster.lookup-optimize off
118
TEST mkdir $M0/dir1
119
new_hash=$(get_xattr_hash $B0/${V0}1/dir1)
120
TEST [ x"$new_hash" = x"00000001" ]
121
new_hash=$(get_xattr_hash $B0/${V0}2/dir1)
122
TEST [ x"$new_hash" = x"00000001" ]
123

124

125
cleanup
126

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

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

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

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