glusterfs
130 строк · 3.5 Кб
1#!/bin/bash
2
3. $(dirname $0)/../../include.rc4. $(dirname $0)/../../volume.rc5. $(dirname $0)/../../dht.rc6
7## TO-DO: Fix the following once the dht du refresh interval issue is fixed:
8## 1. Do away with sleep(1).
9## 2. Do away with creation of empty files.
10
11cleanup;12
13QDD=$(dirname $0)/quota14# compile the test write program and run it
15build_tester $(dirname $0)/../../basic/quota.c -o $QDD16
17TEST glusterd;18TEST pidof glusterd;19
20# Create 2 loop devices, one per brick.
21TEST truncate -s 100M $B0/brick122TEST truncate -s 100M $B0/brick223
24TEST L1=`SETUP_LOOP $B0/brick1`25TEST MKFS_LOOP $L126
27TEST L2=`SETUP_LOOP $B0/brick2`28TEST MKFS_LOOP $L229
30TEST mkdir -p $B0/${V0}{1,2}31
32TEST MOUNT_LOOP $L1 $B0/${V0}133TEST MOUNT_LOOP $L2 $B0/${V0}234
35# Create a plain distribute volume with 2 subvols.
36TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2};37
38TEST $CLI volume start $V0;39EXPECT "Started" volinfo_field $V0 'Status';40
41TEST $CLI volume quota $V0 enable;42
43TEST $CLI volume set $V0 features.quota-deem-statfs on44
45TEST $CLI volume quota $V0 limit-usage / 150MB;46
47TEST $CLI volume set $V0 cluster.min-free-disk 50%48
49TEST glusterfs -s $H0 --volfile-id=$V0 $M050
51# Make sure quota-deem-statfs is working as expected
52EXPECT "150M" echo `df -h $M0 -P | tail -1 | awk {'print $2'}`53
54# Create a new file 'foo' under the root of the volume, which hashes to subvol-0
55# of DHT, that consumes 40M
56TEST $QDD $M0/foo 256 16057
58TEST stat $B0/${V0}1/foo59TEST ! stat $B0/${V0}2/foo60
61# Create a new file 'bar' under the root of the volume, which hashes to subvol-1
62# of DHT, that consumes 40M
63TEST $QDD $M0/bar 256 16064
65TEST ! stat $B0/${V0}1/bar66TEST stat $B0/${V0}2/bar67
68# Touch a zero-byte file on the root of the volume to make sure the statfs data
69# on DHT is refreshed
70sleep 1;71TEST touch $M0/empty1;72
73# At this point, the available space on each subvol {60M,60M} is greater than
74# their min-free-disk {50M,50M}, but if this bug still exists, then
75# the total available space on the volume as perceived by DHT should be less
76# than min-free-disk, i.e.,
77#
78# consumed space returned per subvol by quota = (40M + 40M) = 80M
79#
80# Therefore, consumed space per subvol computed by DHT WITHOUT the fix would be:
81# (80M/150M)*100 = 53%
82#
83# Available space per subvol as perceived by DHT with the bug = 47%
84# which is less than min-free-disk
85
86# Now I create a file that hashes to subvol-1 (counting from 0) of DHT.
87# If this bug still exists,then DHT should be routing this creation to subvol-0.
88# If this bug is fixed, then DHT should be routing the creation to subvol-1 only
89# as it has more than min-free-disk space available.
90
91TEST $QDD $M0/file 1 192sleep 1;93TEST ! stat $B0/${V0}1/file94TEST stat $B0/${V0}2/file95
96# Touch another zero-byte file on the root of the volume to refresh statfs
97# values stored by DHT.
98
99TEST touch $M0/empty2;100
101# Now I create a new file that hashes to subvol-0, at the end of which, there
102# will be less than min-free-disk space available on it.
103TEST $QDD $M0/fil 256 80104sleep 1;105TEST stat $B0/${V0}1/fil106TEST ! stat $B0/${V0}2/fil107
108# Touch to refresh statfs info cached by DHT
109
110TEST touch $M0/empty3;111
112# Now I create a file that hashes to subvol-0 but since it has less than
113# min-free-disk space available, its data will be cached on subvol-1.
114
115TEST $QDD $M0/zz 256 20116
117TEST stat $B0/${V0}1/zz118TEST stat $B0/${V0}2/zz119
120EXPECT "$V0-client-1" dht_get_linkto_target "$B0/${V0}1/zz"121
122EXPECT "1" is_dht_linkfile "$B0/${V0}1/zz"123
124force_umount $M0125TEST $CLI volume stop $V0126UMOUNT_LOOP ${B0}/${V0}{1,2}127rm -f ${B0}/brick{1,2}128
129rm -f $QDD130cleanup
131