3
. $(dirname $0)/../../include.rc
4
. $(dirname $0)/../../volume.rc
10
function get_file_count {
16
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
17
TEST $CLI volume set $V0 features.shard on
18
TEST $CLI volume set $V0 features.shard-block-size 4MB
19
TEST $CLI volume set $V0 performance.quick-read off
20
TEST $CLI volume set $V0 performance.io-cache off
21
TEST $CLI volume set $V0 performance.read-ahead off
22
TEST $CLI volume set $V0 performance.write-behind off
23
TEST $CLI volume start $V0
25
TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0
28
TEST dd if=/dev/urandom of=$M0/dir/foo bs=4M count=5
29
gfid_new=$(get_gfid_string $M0/dir/foo)
31
# Ensure its shards dir is created now.
32
TEST stat $B0/${V0}0/.shard/$gfid_new.1
33
TEST stat $B0/${V0}1/.shard/$gfid_new.1
34
TEST stat $B0/${V0}0/.shard/$gfid_new.2
35
TEST stat $B0/${V0}1/.shard/$gfid_new.2
37
# Open a file and store descriptor in fd = 5
40
# Write something on the file using the open fd = 5
43
# Write on the descriptor should be succesful
46
# Unlink the same file which is opened in prev step
47
TEST unlink $M0/dir/foo
50
TEST ! stat $M0/dir/foo
51
TEST ! stat $B0/${V0}0/foo
52
TEST ! stat $B0/${V0}1/foo
54
# Write something on the file using the open fd = 5
57
# Write on the descriptor should be succesful
60
# Check ".shard/.remove_me"
61
EXPECT_WITHIN $FILE_COUNT_TIME 1 get_file_count $B0/${V0}0/.shard/.remove_me/$gfid_new
62
EXPECT_WITHIN $FILE_COUNT_TIME 1 get_file_count $B0/${V0}1/.shard/.remove_me/$gfid_new
67
###### To see the shards deleted, wait for 10 mins or repeat the same steps i.e open a file #####
68
###### write something to it, unlink it and close it. This will wake up the thread that is ######
69
###### responsible to delete the shards
75
TEST unlink $M0/dir/new
78
# Now check the ".shard/remove_me" and the gfid will not be there
79
EXPECT_WITHIN $FILE_COUNT_TIME 0 get_file_count $B0/${V0}0/.shard/.remove_me/$gfid_new
80
EXPECT_WITHIN $FILE_COUNT_TIME 0 get_file_count $B0/${V0}1/.shard/.remove_me/$gfid_new
82
# check for the absence of shards
83
TEST ! stat $B0/${V0}0/.shard/$gfid_new.1
84
TEST ! stat $B0/${V0}1/.shard/$gfid_new.1
85
TEST ! stat $B0/${V0}0/.shard/$gfid_new.2
86
TEST ! stat $B0/${V0}1/.shard/$gfid_new.2
88
#### Create the file with same name and check creation and deletion works fine ######
89
TEST dd if=/dev/urandom of=$M0/dir/foo bs=4M count=5
90
gfid_new=$(get_gfid_string $M0/dir/foo)
92
# Ensure its shards dir is created now.
93
TEST stat $B0/${V0}0/.shard/$gfid_new.1
94
TEST stat $B0/${V0}1/.shard/$gfid_new.1
95
TEST stat $B0/${V0}0/.shard/$gfid_new.2
96
TEST stat $B0/${V0}1/.shard/$gfid_new.2
98
TEST unlink $M0/dir/foo