Vishal Pandey dbd94d5bee features/worm: new config option to manage deletion of Worm files.
Add a new configuration option worm-files-deletable to
 file-level Worm in order to control behaviour of Worm files upon deletion.

Steps to Test:
1. Add all the configuration options to a volume to activate file-level-worm
2. Option features.worm-files-deletable is set to 1 by default.
3. Create a new file and wait for the retention time to expire.
4. After retention time expires, do an truncate, rename, unlink, link
   or write to send the file in Worm state.
5. After that do `rm -f filename`.
6. The file is successfully removed.
7. Repeat from step 2 by setting features.worm-files-deletable 0.
   This time deletion should not be successful.

Change-Id: Ibc89861ee296e065330b93a9f9606be5da40af31
BUG: 1508898
Signed-off-by: Vishal Pandey <vishpandey2014@gmail.com>
2017-11-20 11:41:27 +00:00

79 lines
1.9 KiB
Bash
Executable File

#!/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 for mv over WORM/Reatined state
TEST `echo "worm 1" > $M0/file1`
TEST chmod 0444 $M0/file1
TEST `echo "worm 2" > $M0/file2`
TEST ! mv $M0/file2 $M0/file1
TEST rm -f $M0/file2
sleep 10
TEST rm -f $M0/file1
## Test for state transition over write.
TEST `echo "worm 1" > $M0/file3`
sleep 5
TEST `echo "worm 2" >> $M0/file3`
EXPECT 'worm 1' cat $M0/file3
TEST ! rm -f $M0/file3
## Test for checking if Worm files are undeletable after setting worm-files-deletable as 0.
TEST $CLI volume set $V0 features.worm-files-deletable 0
TEST `echo "worm 1" > $M0/file4`
TEST chmod 0444 $M0/file4
sleep 10
TEST `echo "worm 1" >> $M0/file4`
TEST ! rm -f $M0/file4
TEST $CLI volume stop $V0
EXPECT 'Stopped' volinfo_field $V0 'Status'
cleanup;