summaryrefslogtreecommitdiffstats
path: root/tests/basic/fencing/fencing-crash-conistency.t
blob: 0c69411e90cc48cf32df700e8c2769469c51909c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash

. $(dirname $0)/../../include.rc
. $(dirname $0)/../../volume.rc

cleanup;

# with lock enforcement flag write should fail with out lock

TEST glusterd
TEST pidof glusterd
TEST $CLI volume info;

TEST $CLI volume create $V0 $H0:$B0/${V0}1
EXPECT 'Created' volinfo_field $V0 'Status';
TEST $CLI volume start $V0;
EXPECT 'Started' volinfo_field $V0 'Status';
TEST $CLI volume set $V0 performance.write-behind off
TEST glusterfs -s $H0 --volfile-id $V0 $M0

TEST touch $M0/file

#write should pass
TEST "echo "test" > $M0/file"
TEST "truncate -s 0 $M0/file"

#enable mandatory locking
TEST $CLI volume set $V0 locks.mandatory-locking forced
TEST $CLI volume set $V0 enforce-mandatory-lock on

#write should pass
TEST "echo "test" >> $M0/file"
TEST "truncate -s 0 $M0/file"

#enforce lock on the file
TEST setfattr -n trusted.glusterfs.enforce-mandatory-lock -v 1 $M0/file

#write should fail
TEST ! "echo "test" >> $M0/file"
TEST ! "truncate -s 0 $M0/file"

#remove lock enforcement flag
TEST setfattr -x trusted.glusterfs.enforce-mandatory-lock $M0/file

#write should pass
TEST "echo "test" >> $M0/file"
TEST "truncate -s 0 $M0/file"

#enforce lock on the file
TEST setfattr -n trusted.glusterfs.enforce-mandatory-lock -v 1 $M0/file
#kill brick
TEST kill_brick $V0 $H0 $B0/${V0}1

TEST $CLI volume start $V0 force

# wait one second for the brick to come online
sleep 2
#write should fail (lock xlator gets lock enforcement info from disk)
TEST ! "echo "test" >> $M0/file"
TEST ! "truncate -s 0 $M0/file"

cleanup;