mirror of
https://github.com/gluster/glusterfs.git
synced 2026-02-06 00:49:30 +01:00
worm: allow Self-heal-Daemon to perform some operations
The Self-Heal-Daemon should be allowed to trigger unlink, link, trauncate, rename and write operation. The value of frame->root->pid can be used to detect internal (by SHD) operations. Change-Id: I7526148100bef1e2837d69df5c119dc97d91fffd BUG: 1423413 Signed-off-by: David Spisla <david.spisla@iternity.com> Reviewed-on: https://review.gluster.org/16661 Tested-by: jiffin tony Thottan <jthottan@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
This commit is contained in:
committed by
Niels de Vos
parent
6b8df081b4
commit
1b01bdcc8e
75
tests/features/worm_sh.t
Normal file
75
tests/features/worm_sh.t
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
. $(dirname $0)/../include.rc
|
||||
. $(dirname $0)/../volume.rc
|
||||
cleanup;
|
||||
|
||||
TEST glusterd
|
||||
TEST pidof glusterd
|
||||
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
|
||||
TEST $CLI volume start $V0
|
||||
TEST $CLI volume set $V0 cluster.data-self-heal off
|
||||
TEST $CLI volume set $V0 cluster.metadata-self-heal off
|
||||
TEST $CLI volume set $V0 cluster.entry-self-heal off
|
||||
|
||||
TEST $CLI volume set $V0 self-heal-daemon off
|
||||
TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0;
|
||||
|
||||
## Enable file level WORM
|
||||
TEST $CLI volume set $V0 features.worm-file-level 1
|
||||
TEST $CLI volume set $V0 features.default-retention-period 100
|
||||
TEST $CLI volume set $V0 features.auto-commit-period 5
|
||||
|
||||
## Tests for manual transition to WORM/Retained state
|
||||
TEST `echo "worm1" > $M0/file1`
|
||||
TEST chmod 0444 $M0/file1
|
||||
sleep 5
|
||||
TEST `echo "worm2" > $M0/file2`
|
||||
TEST chmod 0444 $M0/file2
|
||||
sleep 5
|
||||
TEST `echo "worm3" > $M0/file3`
|
||||
TEST chmod 0444 $M0/file3
|
||||
sleep 5
|
||||
|
||||
## Stopp one of the bricks
|
||||
TEST kill_brick $V0 $H0 $B0/${V0}1
|
||||
|
||||
## Manipulate the WORMed-Files
|
||||
TEST $CLI volume set $V0 features.worm-file-level 0
|
||||
sleep 5
|
||||
|
||||
TEST chmod 0777 $M0/file1
|
||||
TEST `echo "test" >> $M0/file1`
|
||||
TEST `echo "test" >> $M0/file3`
|
||||
TEST `rm -rf $M0/file2`
|
||||
|
||||
## Metadata changes
|
||||
TEST setfattr -n user.test -v qwerty $M0/file3
|
||||
sleep 5
|
||||
|
||||
## Enable file level WORM again
|
||||
TEST $CLI volume set $V0 features.worm-file-level 1
|
||||
|
||||
## Restart volume and trigger self-heal
|
||||
TEST $CLI volume stop $V0 force
|
||||
TEST $CLI volume start $V0 force
|
||||
TEST $CLI volume set $V0 self-heal-daemon on
|
||||
EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status
|
||||
EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0
|
||||
EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1
|
||||
TEST $CLI volume heal $V0
|
||||
|
||||
# Wait for heal to complete
|
||||
EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0
|
||||
|
||||
# Check if entry-heal has happened
|
||||
TEST diff <(ls $B0/${V0}0 | sort) <(ls $B0/${V0}1 | sort)
|
||||
|
||||
# Test if data was healed
|
||||
TEST diff $B0/${V0}0/file1 $B0/${V0}1/file1
|
||||
TEST diff $B0/${V0}0/file3 $B0/${V0}1/file3
|
||||
|
||||
# Test if metadata was healed and exists on both the bricks
|
||||
EXPECT "qwerty" get_text_xattr user.test $B0/${V0}1/file3
|
||||
EXPECT "qwerty" get_text_xattr user.test $B0/${V0}0/file3
|
||||
|
||||
cleanup;
|
||||
@@ -57,7 +57,7 @@ worm_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
|
||||
GF_ASSERT (priv);
|
||||
if (is_readonly_or_worm_enabled (this))
|
||||
goto out;
|
||||
if (!priv->worm_file) {
|
||||
if (!priv->worm_file || (frame->root->pid < 0)) {
|
||||
op_errno = 0;
|
||||
goto out;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ worm_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
|
||||
if (is_readonly_or_worm_enabled (this)) {
|
||||
goto out;
|
||||
}
|
||||
if (!priv->worm_file) {
|
||||
if (!priv->worm_file || (frame->root->pid < 0)) {
|
||||
op_errno = 0;
|
||||
goto out;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ worm_rename (call_frame_t *frame, xlator_t *this,
|
||||
GF_ASSERT (priv);
|
||||
if (is_readonly_or_worm_enabled (this))
|
||||
goto out;
|
||||
if (!priv->worm_file) {
|
||||
if (!priv->worm_file || (frame->root->pid < 0)) {
|
||||
op_errno = 0;
|
||||
goto out;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ worm_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
|
||||
GF_ASSERT (priv);
|
||||
if (is_readonly_or_worm_enabled (this))
|
||||
goto out;
|
||||
if (!priv->worm_file) {
|
||||
if (!priv->worm_file || (frame->root->pid < 0)) {
|
||||
op_errno = 0;
|
||||
goto out;
|
||||
}
|
||||
@@ -396,7 +396,7 @@ worm_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
|
||||
priv = this->private;
|
||||
GF_ASSERT (priv);
|
||||
if (!priv->worm_file) {
|
||||
if (!priv->worm_file || (frame->root->pid < 0)) {
|
||||
op_errno = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user