forked from kubernetes/minikube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update mount implementation, add mount integration tests, and check t…
…hat path exists.
- Loading branch information
1 parent
12e41ae
commit 8e801e3
Showing
60 changed files
with
1,596 additions
and
2,604 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
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,112 @@ | ||
// +build integration | ||
|
||
/* | ||
Copyright 2016 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 ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"k8s.io/kubernetes/pkg/api" | ||
commonutil "k8s.io/minikube/pkg/util" | ||
"k8s.io/minikube/test/integration/util" | ||
) | ||
|
||
func testMounting(t *testing.T) { | ||
t.Parallel() | ||
minikubeRunner := util.MinikubeRunner{ | ||
Args: *args, | ||
BinaryPath: *binaryPath, | ||
T: t} | ||
|
||
tempDir, err := ioutil.TempDir("", "mounttest") | ||
if err != nil { | ||
t.Fatalf("Unexpected error while creating tempDir: %s", err) | ||
} | ||
defer os.RemoveAll(tempDir) | ||
|
||
mountCmd := fmt.Sprintf("mount %s", tempDir) | ||
cmd := minikubeRunner.RunDaemon(mountCmd) | ||
defer cmd.Process.Kill() | ||
|
||
kubectlRunner := util.NewKubectlRunner(t) | ||
podName := "busybox" | ||
podPath, _ := filepath.Abs("testdata/busybox-mount-test.yaml") | ||
|
||
// Write file in mounted dir from host | ||
expected := "test\n" | ||
files := []string{"fromhost", "fromhostremove"} | ||
for _, file := range files { | ||
path := filepath.Join(tempDir, file) | ||
err = ioutil.WriteFile(path, []byte(expected), 0644) | ||
if err != nil { | ||
t.Fatalf("Unexpected error while writing file %s: %s.", path, err) | ||
} | ||
} | ||
mountTest := func() error { | ||
if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil { | ||
return err | ||
} | ||
defer kubectlRunner.RunCommand([]string{"delete", "-f", podPath}) | ||
|
||
p := &api.Pod{} | ||
for p.Status.Phase != "Running" { | ||
p = kubectlRunner.GetPod(podName, "default") | ||
} | ||
|
||
path := filepath.Join(tempDir, "frompod") | ||
out, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
return &commonutil.RetriableError{Err: err} | ||
} | ||
// test that file written from pod can be read from host echo test > /mount-9p/frompod; in pod | ||
if string(out) != expected { | ||
t.Fatalf("Expected file %s to contain text %s, was %s.", path, expected, out) | ||
} | ||
|
||
// test that file written from host was read in by the pod via cat /mount-9p/fromhost; | ||
if out, err = kubectlRunner.RunCommand([]string{"logs", podName}); err != nil { | ||
return &commonutil.RetriableError{Err: err} | ||
} | ||
if string(out) != expected { | ||
t.Fatalf("Expected file %s to contain text %s, was %s.", path, expected, out) | ||
} | ||
|
||
// test that fromhostremove was deleted by the pod from the mount via rm /mount-9p/fromhostremove | ||
path = filepath.Join(tempDir, "fromhostremove") | ||
if _, err := os.Stat(path); err == nil { | ||
t.Fatalf("Expected file %s to be removed", path, expected, out) | ||
} | ||
|
||
// test that frompodremove can be deleted on the host | ||
path = filepath.Join(tempDir, "frompodremove") | ||
if err := os.Remove(path); err != nil { | ||
t.Fatalf("Unexpected error removing file %s: %s", path, err) | ||
} | ||
|
||
return nil | ||
} | ||
if err := commonutil.RetryAfter(40, mountTest, 5*time.Second); err != nil { | ||
t.Fatal("mountTest failed with error:", err) | ||
} | ||
|
||
} |
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,19 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: busybox | ||
spec: | ||
containers: | ||
- image: busybox:glibc | ||
command: [ "/bin/sh", "-c", "--" ] | ||
args: [ "cat /mount-9p/fromhost; echo test > /mount-9p/frompod; rm /mount-9p/fromhostremove; echo test > /mount-9p/frompodremove;" ] | ||
name: busybox | ||
volumeMounts: | ||
- mountPath: /mount-9p | ||
name: test-volume | ||
volumes: | ||
- name: test-volume | ||
hostPath: | ||
# directory location on host | ||
path: /mount-9p | ||
|
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,2 @@ | ||
*.orig | ||
*.rej |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
This is go9p done in a way that I can understand. | ||
|
||
To install: | ||
export GOPATH=~rminnich/go | ||
go get -a /k8s.io/minikube/third_party/go9p | ||
go get -a /k8s.io/minikube/third_party/go9p/ufs | ||
go install -a /k8s.io/minikube/third_party/go9p/ufs | ||
|
||
~/go/bin/ufs | ||
|
||
|
Oops, something went wrong.