From 9ddc845cca521457c360893f0910ae4e47a0caed Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 29 Jan 2025 17:17:38 -0500 Subject: [PATCH] Tweak test Signed-off-by: Matt Lord --- .../backup/vtctlbackup/backup_utils.go | 2 +- go/test/endtoend/cluster/cluster_util.go | 18 ------------------ go/test/endtoend/cluster/vttablet_process.go | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/go/test/endtoend/backup/vtctlbackup/backup_utils.go b/go/test/endtoend/backup/vtctlbackup/backup_utils.go index 3c6627dc9fe..f7e013f4ce4 100644 --- a/go/test/endtoend/backup/vtctlbackup/backup_utils.go +++ b/go/test/endtoend/backup/vtctlbackup/backup_utils.go @@ -431,7 +431,7 @@ func TestBackup(t *testing.T, setupType int, streamMode string, stripes int, cDe for _, ks := range localCluster.Keyspaces { for _, shard := range ks.Shards { for _, tablet := range shard.Vttablets { - cluster.ConfirmDataDirHasNoGlobalPerms(t, tablet) + tablet.VttabletProcess.ConfirmDataDirHasNoGlobalPerms(t) } } } diff --git a/go/test/endtoend/cluster/cluster_util.go b/go/test/endtoend/cluster/cluster_util.go index 3fcb8da22c7..18f78dcb3d0 100644 --- a/go/test/endtoend/cluster/cluster_util.go +++ b/go/test/endtoend/cluster/cluster_util.go @@ -18,10 +18,8 @@ package cluster import ( "context" - "errors" "fmt" "os" - "os/exec" "path" "reflect" "strings" @@ -511,19 +509,3 @@ func PrintFiles(t *testing.T, dir string, files ...string) { } } } - -// ConfirmDataDirHasNoGlobalPerms confirms that no files in the tablet's data directory -// have any global/other permissions set. -func ConfirmDataDirHasNoGlobalPerms(t *testing.T, tablet *Vttablet) { - datadir := tablet.VttabletProcess.Directory - if _, err := os.Stat(datadir); errors.Is(err, os.ErrNotExist) { - t.Logf("Data directory %s no longer exists, skipping permissions check", datadir) - return - } - // List any files which have any of the other bits set. - cmd := exec.Command("find", datadir, "-perm", "+00007") - out, err := cmd.CombinedOutput() - require.NoError(t, err, "Error running find command: %s", string(out)) - so := string(out) - require.Empty(t, so, "Found files with global permissions: %s", so) -} diff --git a/go/test/endtoend/cluster/vttablet_process.go b/go/test/endtoend/cluster/vttablet_process.go index 65c6fbeec26..5b542b65268 100644 --- a/go/test/endtoend/cluster/vttablet_process.go +++ b/go/test/endtoend/cluster/vttablet_process.go @@ -35,6 +35,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "vitess.io/vitess/go/constants/sidecar" "vitess.io/vitess/go/mysql" "vitess.io/vitess/go/sqltypes" @@ -711,6 +713,22 @@ func (vttablet *VttabletProcess) IsShutdown() bool { return vttablet.proc == nil } +// ConfirmDataDirHasNoGlobalPerms confirms that no files in the tablet's data directory +// have any global/world/other permissions enabled. +func (vttablet *VttabletProcess) ConfirmDataDirHasNoGlobalPerms(t *testing.T) { + datadir := vttablet.Directory + if _, err := os.Stat(datadir); errors.Is(err, os.ErrNotExist) { + t.Logf("Data directory %s no longer exists, skipping permissions check", datadir) + return + } + // List any files which have any of the other bits set. + cmd := exec.Command("find", datadir, "-perm", "+00007") + out, err := cmd.CombinedOutput() + require.NoError(t, err, "Error running find command: %s", string(out)) + so := string(out) + require.Empty(t, so, "Found files with global permissions: %s", so) +} + // VttabletProcessInstance returns a VttabletProcess handle for vttablet process // configured with the given Config. // The process must be manually started by calling setup()