Skip to content

Commit

Permalink
Tweak test
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Jan 29, 2025
1 parent 87d6132 commit 9ddc845
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go/test/endtoend/backup/vtctlbackup/backup_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
18 changes: 0 additions & 18 deletions go/test/endtoend/cluster/cluster_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ package cluster

import (
"context"
"errors"
"fmt"
"os"
"os/exec"
"path"
"reflect"
"strings"
Expand Down Expand Up @@ -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)
}
18 changes: 18 additions & 0 deletions go/test/endtoend/cluster/vttablet_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9ddc845

Please sign in to comment.