summaryrefslogtreecommitdiffstats
path: root/tests/features/worm.t
blob: 407b49a79ce7b14c1ad36d42b02c53e552c1fe20 (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
#!/bin/bash

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

cleanup;

TEST glusterd
TEST pidof glusterd

TEST $CLI volume create $V0 $H0:$B0/${V0}1

EXPECT "$V0" volinfo_field $V0 'Volume Name'
EXPECT 'Created' volinfo_field $V0 'Status'

TEST $CLI volume start $V0
EXPECT 'Started' volinfo_field $V0 'Status'

## Mount FUSE with caching disabled (read-write)
TEST $GFS -s $H0 --volfile-id $V0 $M0

## Tests for the volume level WORM
TEST `echo "File 1" > $M0/file1`
TEST touch $M0/file2

## Enable the volume level WORM
TEST $CLI volume set $V0 features.worm 1
TEST ! mv $M0/file1 $M0/file11
TEST `echo "block" > $M0/file2`

## Disable the volume level WORM and delete the legacy files
TEST $CLI volume set $V0 features.worm 0
TEST rm -f $M0/*

## Enable file level WORM
TEST $CLI volume set $V0 features.worm-file-level 1
TEST $CLI volume set $V0 features.default-retention-period 10
TEST $CLI volume set $V0 features.auto-commit-period 5

## Tests for manual transition to WORM/Retained state
TEST `echo "worm 1" > $M0/file1`
TEST chmod 0444 $M0/file1
sleep 5
TEST `echo "line 1" > $M0/file1`
TEST ! mv $M0/file1 $M0/file2
sleep 10
TEST ! link $M0/file1 $M0/file2
sleep 5
TEST rm -f $M0/file1

TEST $CLI volume stop $V0
EXPECT 'Stopped' volinfo_field $V0 'Status'

cleanup;