add tests for new start mount flags

pull/12930/head
Steven Powell 2021-11-19 16:58:42 -08:00
parent 5ddb53f57b
commit 4369ccc2ca
1 changed files with 50 additions and 2 deletions

View File

@ -21,10 +21,20 @@ package integration
import (
"context"
"fmt"
"os/exec"
"strings"
"testing"
)
const (
mountGID = "0"
mountMSize = "6543"
mountMode = "777"
mountPort = "46464"
mountUID = "0"
)
// TestMountStart tests using the mount command on start
func TestMountStart(t *testing.T) {
if NoneDriver() {
@ -72,7 +82,7 @@ func TestMountStart(t *testing.T) {
func validateStartWithMount(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)
args := []string{"start", "-p", profile, "--memory=2048", "--mount"}
args := []string{"start", "-p", profile, "--memory=2048", "--mount", "--mount-gid", mountGID, "--mount-msize", mountMSize, "--mount-mode", mountMode, "--mount-port", mountPort, "--mount-uid", mountUID}
args = append(args, StartArgs()...)
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
@ -84,11 +94,49 @@ func validateStartWithMount(ctx context.Context, t *testing.T, profile string) {
func validateMount(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)
args := []string{"-p", profile, "ssh", "ls", "/minikube-host"}
sshArgs := []string{"-p", profile, "ssh"}
args := sshArgs
args = append(args, "ls", "/minikube-host")
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
t.Fatalf("mount failed: %q : %v", rr.Command(), err)
}
args = sshArgs
args = append(args, "stat", "--format", "'%a'", "/minikube-host")
rr, err = Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
t.Fatalf("failed to get directory mode: %v", err)
}
if !strings.Contains(rr.Output(), mountMode) {
t.Errorf("wanted mode to be %q; got: %q", mountMode, rr.Output())
}
args = sshArgs
args = append(args, "mount", "|", "grep", "9p")
rr, err = Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
t.Fatalf("failed to get mount information: %v", err)
}
flags := []struct {
key string
expected string
}{
{"gid", mountGID},
{"msize", mountMSize},
{"port", mountPort},
{"uid", mountUID},
}
for _, flag := range flags {
want := fmt.Sprintf("%s=%s", flag.key, flag.expected)
if !strings.Contains(rr.Output(), want) {
t.Errorf("wanted gid to be: %q; got: %q", want, rr.Output())
}
}
}
// validateMountStop stops a cluster