Skip to content

Commit 865b7d5

Browse files
committed
test: Support virtiofs mounts
Use findmnt command to get the mounted filesystem details cleanly. We use the actual mount fstype instead of driver name check so we can switch drivers to virtiofs without changing the test. For virtiofs mount we skip options validation since we don't support setting virtiofs options yet, and the options are not the same as 9p options. For 9p mounts the uid= and gid= flags were fixed to match the real flags (dfltuid=,dfltgid=). The issue was hidden by imprecise string matching.
1 parent 3b115a3 commit 865b7d5

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

test/integration/mount_start_test.go

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ import (
2222
"context"
2323
"fmt"
2424
"os/exec"
25+
"slices"
2526
"strconv"
2627
"strings"
2728
"testing"
2829
"time"
30+
31+
"k8s.io/minikube/test/integration/findmnt"
2932
)
3033

3134
const (
@@ -139,26 +142,47 @@ func validateMount(ctx context.Context, t *testing.T, profile string) {
139142
}
140143

141144
args = sshArgs
142-
args = append(args, "mount", "|", "grep", "9p")
145+
args = append(args, "findmnt", "--json", guestPath)
143146
rr, err = Run(t, exec.CommandContext(ctx, Target(), args...))
144147
if err != nil {
145148
t.Fatalf("failed to get mount information: %v", err)
146149
}
147150

151+
result, err := findmnt.ParseOutput(rr.Stdout.Bytes())
152+
if err != nil {
153+
t.Fatalf("failed to parse command output %q: %s", rr.Command(), rr.Output())
154+
}
155+
156+
if len(result.Filesystems) == 0 {
157+
t.Fatalf("no filesystems found")
158+
}
159+
160+
fs := result.Filesystems[0]
161+
if fs.FSType == "virtiofs" {
162+
t.Logf("virtiofs options not supported yet")
163+
return
164+
}
165+
166+
if fs.FSType != "9p" {
167+
t.Fatalf("unexpected filesystem: %q", fs.FSType)
168+
}
169+
170+
options := strings.Split(fs.Options, ",")
171+
148172
flags := []struct {
149173
key string
150174
expected string
151175
}{
152-
{"gid", mountGID},
176+
{"dfltgid", mountGID},
177+
{"dfltuid", mountUID},
153178
{"msize", mountMSize},
154179
{"port", mountPort()},
155-
{"uid", mountUID},
156180
}
157181

158182
for _, flag := range flags {
159183
want := fmt.Sprintf("%s=%s", flag.key, flag.expected)
160-
if !strings.Contains(rr.Output(), want) {
161-
t.Errorf("wanted %s to be: %q; got: %q", flag.key, want, rr.Output())
184+
if !slices.Contains(options, want) {
185+
t.Errorf("wanted %s to be: %q; got: %q", flag.key, want, options)
162186
}
163187
}
164188
}

0 commit comments

Comments
 (0)