glusterfs

Форк
0
92 строки · 2.3 Кб
1
#!/bin/bash
2

3
# Test that the rsync and "extra" regexes cause rename-in-place without
4
# creating linkfiles, when they're supposed to.  Without the regex we'd have a
5
# 1/4 chance of each file being assigned to the right place, so with 16 files
6
# we have a 1/2^32 chance of getting the correct result by accident.
7

8
. $(dirname $0)/../../include.rc
9
. $(dirname $0)/../../volume.rc
10

11
function count_linkfiles {
12
	local i
13
	local count=0
14
	for i in $(seq $2 $3); do
15
		x=$(find $1$i -perm -1000 | wc -l)
16
		# Divide by two because of the .glusterfs links.
17
		count=$((count+x/2))
18
	done
19
	echo $count
20
}
21

22
# This function only exists to get around quoting difficulties in TEST.
23
function set_regex {
24
	$CLI volume set $1 cluster.extra-hash-regex '^foo(.+)bar$'
25
}
26

27
cleanup;
28

29
TEST glusterd
30
TEST pidof glusterd
31

32
mkdir -p $H0:$B0/${V0}0
33
mkdir -p $H0:$B0/${V0}1
34
mkdir -p $H0:$B0/${V0}2
35
mkdir -p $H0:$B0/${V0}3
36

37
# Create and start a volume.
38
TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 \
39
			    $H0:$B0/${V0}2 $H0:$B0/${V0}3
40
TEST $CLI volume start $V0
41
EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status';
42

43
# Mount it.
44
TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0
45

46
# Make sure the rsync regex works, by verifying that no linkfiles are
47
# created.
48
rm -f $M0/file*
49
for i in $(seq 0 15); do
50
	fn=$(printf file%x $i)
51
	tmp_fn=$(printf .%s.%d $fn $RANDOM)
52
	echo testing > $M0/$tmp_fn
53
	mv $M0/$tmp_fn $M0/$fn
54
done
55
lf=$(count_linkfiles $B0/$V0 0 3)
56
TEST [ "$lf" -eq "0" ]
57

58
# Make sure that linkfiles *are* created for normal files.
59
rm -f $M0/file*
60
for i in $(seq 0 15); do
61
	fn=$(printf file%x $i)
62
	tmp_fn=$(printf foo%sbar $fn)
63
	echo testing > $M0/$tmp_fn
64
	mv $M0/$tmp_fn $M0/$fn
65
done
66
lf=$(count_linkfiles $B0/$V0 0 3)
67
TEST [ "$lf" -ne "0" ]
68

69
# Make sure that setting an extra regex suppresses the linkfiles.
70
TEST set_regex $V0
71
rm -f $M0/file*
72
for i in $(seq 0 15); do
73
	fn=$(printf file%x $i)
74
	tmp_fn=$(printf foo%sbar $fn)
75
	echo testing > $M0/$tmp_fn
76
	mv $M0/$tmp_fn $M0/$fn
77
done
78
lf=$(count_linkfiles $B0/$V0 0 3)
79
TEST [ "$lf" -eq "0" ]
80

81
# Re-test the rsync regex, to make sure the extra one didn't break it.
82
rm -f $M0/file*
83
for i in $(seq 0 15); do
84
	fn=$(printf file%x $i)
85
	tmp_fn=$(printf .%s.%d $fn $RANDOM)
86
	echo testing > $M0/$tmp_fn
87
	mv $M0/$tmp_fn $M0/$fn
88
done
89
lf=$(count_linkfiles $B0/$V0 0 3)
90
TEST [ "$lf" -eq "0" ]
91

92
cleanup
93

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

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

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

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