Skip to content

Commit 1052718

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 51cb4f9 commit 1052718

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

pkg/minikube/constants/constants.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ const (
161161
// MountUIDFlag is the flag used to set the mount UID
162162
MountUIDFlag = "uid"
163163

164+
// FSType9p is 9p filesystem type
165+
FSType9p = "9p"
166+
// FSTypeVirtiofs is virtiofs filesystem type
167+
FSTypeVirtiofs = "virtiofs"
168+
164169
// Mirror CN
165170
AliyunMirror = "registry.cn-hangzhou.aliyuncs.com/google_containers"
166171
)

test/integration/mount_start_test.go

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

3135
const (
@@ -139,26 +143,47 @@ func validateMount(ctx context.Context, t *testing.T, profile string) {
139143
}
140144

141145
args = sshArgs
142-
args = append(args, "mount", "|", "grep", "9p")
146+
args = append(args, "findmnt", "--json", guestPath)
143147
rr, err = Run(t, exec.CommandContext(ctx, Target(), args...))
144148
if err != nil {
145-
t.Fatalf("failed to get mount information: %v", err)
149+
t.Fatalf("command failed %q: %v", rr.Command(), err)
150+
}
151+
152+
result, err := findmnt.ParseOutput(rr.Stdout.Bytes())
153+
if err != nil {
154+
t.Fatalf("failed to parse output %s: %v", rr.Stdout.String(), err)
155+
}
156+
157+
if len(result.Filesystems) == 0 {
158+
t.Fatalf("no filesystems found")
146159
}
147160

161+
fs := result.Filesystems[0]
162+
if fs.FSType == constants.FSTypeVirtiofs {
163+
t.Logf("Options not supported yet for %q filesystem", fs.FSType)
164+
return
165+
}
166+
167+
if fs.FSType != constants.FSType9p {
168+
t.Fatalf("unexpected filesystem %q", fs.FSType)
169+
}
170+
171+
options := strings.Split(fs.Options, ",")
172+
148173
flags := []struct {
149174
key string
150175
expected string
151176
}{
152-
{"gid", mountGID},
177+
{"dfltgid", mountGID},
178+
{"dfltuid", mountUID},
153179
{"msize", mountMSize},
154180
{"port", mountPort()},
155-
{"uid", mountUID},
156181
}
157182

158183
for _, flag := range flags {
159184
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())
185+
if !slices.Contains(options, want) {
186+
t.Errorf("wanted %s to be: %q; got: %q", flag.key, want, options)
162187
}
163188
}
164189
}

0 commit comments

Comments
 (0)