-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12711 from spowelljr/fixMount
Fix mounting on non-default profile
- Loading branch information
Showing
4 changed files
with
119 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
//go:build integration | ||
// +build integration | ||
|
||
/* | ||
Copyright 2021 The Kubernetes Authors All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package integration | ||
|
||
import ( | ||
"context" | ||
"os/exec" | ||
"testing" | ||
) | ||
|
||
// TestMountStart tests using the mount command on start | ||
func TestMountStart(t *testing.T) { | ||
if NoneDriver() { | ||
t.Skip("skipping: none driver does not support mount") | ||
} | ||
|
||
MaybeParallel(t) | ||
|
||
type validateFunc func(context.Context, *testing.T, string) | ||
profile1 := UniqueProfileName("mount-start-1") | ||
profile2 := UniqueProfileName("mount-start-2") | ||
ctx, cancel := context.WithTimeout(context.Background(), Minutes(15)) | ||
defer Cleanup(t, profile1, cancel) | ||
defer Cleanup(t, profile2, cancel) | ||
|
||
// Serial tests | ||
t.Run("serial", func(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
validator validateFunc | ||
profile string | ||
}{ | ||
{"StartWithMountFirst", validateStartWithMount, profile1}, | ||
{"StartWithMountSecond", validateStartWithMount, profile2}, | ||
{"VerifyMountFirst", validateMount, profile1}, | ||
{"VerifyMountSecond", validateMount, profile2}, | ||
{"DeleteFirst", validateDelete, profile1}, | ||
{"VerifyMountPostDelete", validateMount, profile2}, | ||
} | ||
|
||
for _, test := range tests { | ||
if ctx.Err() == context.DeadlineExceeded { | ||
t.Fatalf("Unable to run more tests (deadline exceeded)") | ||
} | ||
|
||
t.Run(test.name, func(t *testing.T) { | ||
test.validator(ctx, t, test.profile) | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
// validateStartWithMount starts a cluster with mount enabled | ||
func validateStartWithMount(ctx context.Context, t *testing.T, profile string) { | ||
defer PostMortemLogs(t, profile) | ||
|
||
args := []string{"start", "-p", profile, "--memory=2048", "--mount"} | ||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) | ||
if err != nil { | ||
t.Fatalf("failed to start minikube with args: %q : %v", rr.Command(), err) | ||
} | ||
} | ||
|
||
// validateMount checks if the cluster has a folder mounted | ||
func validateMount(ctx context.Context, t *testing.T, profile string) { | ||
defer PostMortemLogs(t, profile) | ||
|
||
args := []string{"-p", profile, "ssh", "ls", "/minikube-host"} | ||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) | ||
if err != nil { | ||
t.Fatalf("mount failed: %q : %v", rr.Command(), err) | ||
} | ||
} |