mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-29 21:29:24 +00:00
test/e2e
This commit is contained in:
@@ -20,8 +20,8 @@ import (
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/apimachinery/registered"
|
||||
"k8s.io/kubernetes/pkg/util/uuid"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
@@ -40,80 +40,80 @@ var _ = framework.KubeDescribe("EmptyDir volumes", func() {
|
||||
|
||||
Context("when FSGroup is specified [Feature:FSGroup]", func() {
|
||||
It("new files should be created with FSGroup ownership when container is root", func() {
|
||||
doTestSetgidFSGroup(f, testImageRootUid, api.StorageMediumMemory)
|
||||
doTestSetgidFSGroup(f, testImageRootUid, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
It("new files should be created with FSGroup ownership when container is non-root", func() {
|
||||
doTestSetgidFSGroup(f, testImageNonRootUid, api.StorageMediumMemory)
|
||||
doTestSetgidFSGroup(f, testImageNonRootUid, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
It("files with FSGroup ownership should support (root,0644,tmpfs)", func() {
|
||||
doTest0644FSGroup(f, testImageRootUid, api.StorageMediumMemory)
|
||||
doTest0644FSGroup(f, testImageRootUid, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
It("volume on default medium should have the correct mode using FSGroup", func() {
|
||||
doTestVolumeModeFSGroup(f, testImageRootUid, api.StorageMediumDefault)
|
||||
doTestVolumeModeFSGroup(f, testImageRootUid, v1.StorageMediumDefault)
|
||||
})
|
||||
|
||||
It("volume on tmpfs should have the correct mode using FSGroup", func() {
|
||||
doTestVolumeModeFSGroup(f, testImageRootUid, api.StorageMediumMemory)
|
||||
doTestVolumeModeFSGroup(f, testImageRootUid, v1.StorageMediumMemory)
|
||||
})
|
||||
})
|
||||
|
||||
It("volume on tmpfs should have the correct mode [Conformance]", func() {
|
||||
doTestVolumeMode(f, testImageRootUid, api.StorageMediumMemory)
|
||||
doTestVolumeMode(f, testImageRootUid, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
It("should support (root,0644,tmpfs) [Conformance]", func() {
|
||||
doTest0644(f, testImageRootUid, api.StorageMediumMemory)
|
||||
doTest0644(f, testImageRootUid, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
It("should support (root,0666,tmpfs) [Conformance]", func() {
|
||||
doTest0666(f, testImageRootUid, api.StorageMediumMemory)
|
||||
doTest0666(f, testImageRootUid, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
It("should support (root,0777,tmpfs) [Conformance]", func() {
|
||||
doTest0777(f, testImageRootUid, api.StorageMediumMemory)
|
||||
doTest0777(f, testImageRootUid, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
It("should support (non-root,0644,tmpfs) [Conformance]", func() {
|
||||
doTest0644(f, testImageNonRootUid, api.StorageMediumMemory)
|
||||
doTest0644(f, testImageNonRootUid, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
It("should support (non-root,0666,tmpfs) [Conformance]", func() {
|
||||
doTest0666(f, testImageNonRootUid, api.StorageMediumMemory)
|
||||
doTest0666(f, testImageNonRootUid, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
It("should support (non-root,0777,tmpfs) [Conformance]", func() {
|
||||
doTest0777(f, testImageNonRootUid, api.StorageMediumMemory)
|
||||
doTest0777(f, testImageNonRootUid, v1.StorageMediumMemory)
|
||||
})
|
||||
|
||||
It("volume on default medium should have the correct mode [Conformance]", func() {
|
||||
doTestVolumeMode(f, testImageRootUid, api.StorageMediumDefault)
|
||||
doTestVolumeMode(f, testImageRootUid, v1.StorageMediumDefault)
|
||||
})
|
||||
|
||||
It("should support (root,0644,default) [Conformance]", func() {
|
||||
doTest0644(f, testImageRootUid, api.StorageMediumDefault)
|
||||
doTest0644(f, testImageRootUid, v1.StorageMediumDefault)
|
||||
})
|
||||
|
||||
It("should support (root,0666,default) [Conformance]", func() {
|
||||
doTest0666(f, testImageRootUid, api.StorageMediumDefault)
|
||||
doTest0666(f, testImageRootUid, v1.StorageMediumDefault)
|
||||
})
|
||||
|
||||
It("should support (root,0777,default) [Conformance]", func() {
|
||||
doTest0777(f, testImageRootUid, api.StorageMediumDefault)
|
||||
doTest0777(f, testImageRootUid, v1.StorageMediumDefault)
|
||||
})
|
||||
|
||||
It("should support (non-root,0644,default) [Conformance]", func() {
|
||||
doTest0644(f, testImageNonRootUid, api.StorageMediumDefault)
|
||||
doTest0644(f, testImageNonRootUid, v1.StorageMediumDefault)
|
||||
})
|
||||
|
||||
It("should support (non-root,0666,default) [Conformance]", func() {
|
||||
doTest0666(f, testImageNonRootUid, api.StorageMediumDefault)
|
||||
doTest0666(f, testImageNonRootUid, v1.StorageMediumDefault)
|
||||
})
|
||||
|
||||
It("should support (non-root,0777,default) [Conformance]", func() {
|
||||
doTest0777(f, testImageNonRootUid, api.StorageMediumDefault)
|
||||
doTest0777(f, testImageNonRootUid, v1.StorageMediumDefault)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -122,11 +122,11 @@ const (
|
||||
volumeName = "test-volume"
|
||||
)
|
||||
|
||||
func doTestSetgidFSGroup(f *framework.Framework, image string, medium api.StorageMedium) {
|
||||
func doTestSetgidFSGroup(f *framework.Framework, image string, medium v1.StorageMedium) {
|
||||
var (
|
||||
volumePath = "/test-volume"
|
||||
filePath = path.Join(volumePath, "test-file")
|
||||
source = &api.EmptyDirVolumeSource{Medium: medium}
|
||||
source = &v1.EmptyDirVolumeSource{Medium: medium}
|
||||
pod = testPodWithVolume(testImageRootUid, volumePath, source)
|
||||
)
|
||||
|
||||
@@ -146,16 +146,16 @@ func doTestSetgidFSGroup(f *framework.Framework, image string, medium api.Storag
|
||||
"content of file \"/test-volume/test-file\": mount-tester new file",
|
||||
"owner GID of \"/test-volume/test-file\": 123",
|
||||
}
|
||||
if medium == api.StorageMediumMemory {
|
||||
if medium == v1.StorageMediumMemory {
|
||||
out = append(out, "mount type of \"/test-volume\": tmpfs")
|
||||
}
|
||||
f.TestContainerOutput(msg, pod, 0, out)
|
||||
}
|
||||
|
||||
func doTestVolumeModeFSGroup(f *framework.Framework, image string, medium api.StorageMedium) {
|
||||
func doTestVolumeModeFSGroup(f *framework.Framework, image string, medium v1.StorageMedium) {
|
||||
var (
|
||||
volumePath = "/test-volume"
|
||||
source = &api.EmptyDirVolumeSource{Medium: medium}
|
||||
source = &v1.EmptyDirVolumeSource{Medium: medium}
|
||||
pod = testPodWithVolume(testImageRootUid, volumePath, source)
|
||||
)
|
||||
|
||||
@@ -171,17 +171,17 @@ func doTestVolumeModeFSGroup(f *framework.Framework, image string, medium api.St
|
||||
out := []string{
|
||||
"perms of file \"/test-volume\": -rwxrwxrwx",
|
||||
}
|
||||
if medium == api.StorageMediumMemory {
|
||||
if medium == v1.StorageMediumMemory {
|
||||
out = append(out, "mount type of \"/test-volume\": tmpfs")
|
||||
}
|
||||
f.TestContainerOutput(msg, pod, 0, out)
|
||||
}
|
||||
|
||||
func doTest0644FSGroup(f *framework.Framework, image string, medium api.StorageMedium) {
|
||||
func doTest0644FSGroup(f *framework.Framework, image string, medium v1.StorageMedium) {
|
||||
var (
|
||||
volumePath = "/test-volume"
|
||||
filePath = path.Join(volumePath, "test-file")
|
||||
source = &api.EmptyDirVolumeSource{Medium: medium}
|
||||
source = &v1.EmptyDirVolumeSource{Medium: medium}
|
||||
pod = testPodWithVolume(image, volumePath, source)
|
||||
)
|
||||
|
||||
@@ -199,16 +199,16 @@ func doTest0644FSGroup(f *framework.Framework, image string, medium api.StorageM
|
||||
"perms of file \"/test-volume/test-file\": -rw-r--r--",
|
||||
"content of file \"/test-volume/test-file\": mount-tester new file",
|
||||
}
|
||||
if medium == api.StorageMediumMemory {
|
||||
if medium == v1.StorageMediumMemory {
|
||||
out = append(out, "mount type of \"/test-volume\": tmpfs")
|
||||
}
|
||||
f.TestContainerOutput(msg, pod, 0, out)
|
||||
}
|
||||
|
||||
func doTestVolumeMode(f *framework.Framework, image string, medium api.StorageMedium) {
|
||||
func doTestVolumeMode(f *framework.Framework, image string, medium v1.StorageMedium) {
|
||||
var (
|
||||
volumePath = "/test-volume"
|
||||
source = &api.EmptyDirVolumeSource{Medium: medium}
|
||||
source = &v1.EmptyDirVolumeSource{Medium: medium}
|
||||
pod = testPodWithVolume(testImageRootUid, volumePath, source)
|
||||
)
|
||||
|
||||
@@ -221,17 +221,17 @@ func doTestVolumeMode(f *framework.Framework, image string, medium api.StorageMe
|
||||
out := []string{
|
||||
"perms of file \"/test-volume\": -rwxrwxrwx",
|
||||
}
|
||||
if medium == api.StorageMediumMemory {
|
||||
if medium == v1.StorageMediumMemory {
|
||||
out = append(out, "mount type of \"/test-volume\": tmpfs")
|
||||
}
|
||||
f.TestContainerOutput(msg, pod, 0, out)
|
||||
}
|
||||
|
||||
func doTest0644(f *framework.Framework, image string, medium api.StorageMedium) {
|
||||
func doTest0644(f *framework.Framework, image string, medium v1.StorageMedium) {
|
||||
var (
|
||||
volumePath = "/test-volume"
|
||||
filePath = path.Join(volumePath, "test-file")
|
||||
source = &api.EmptyDirVolumeSource{Medium: medium}
|
||||
source = &v1.EmptyDirVolumeSource{Medium: medium}
|
||||
pod = testPodWithVolume(image, volumePath, source)
|
||||
)
|
||||
|
||||
@@ -246,17 +246,17 @@ func doTest0644(f *framework.Framework, image string, medium api.StorageMedium)
|
||||
"perms of file \"/test-volume/test-file\": -rw-r--r--",
|
||||
"content of file \"/test-volume/test-file\": mount-tester new file",
|
||||
}
|
||||
if medium == api.StorageMediumMemory {
|
||||
if medium == v1.StorageMediumMemory {
|
||||
out = append(out, "mount type of \"/test-volume\": tmpfs")
|
||||
}
|
||||
f.TestContainerOutput(msg, pod, 0, out)
|
||||
}
|
||||
|
||||
func doTest0666(f *framework.Framework, image string, medium api.StorageMedium) {
|
||||
func doTest0666(f *framework.Framework, image string, medium v1.StorageMedium) {
|
||||
var (
|
||||
volumePath = "/test-volume"
|
||||
filePath = path.Join(volumePath, "test-file")
|
||||
source = &api.EmptyDirVolumeSource{Medium: medium}
|
||||
source = &v1.EmptyDirVolumeSource{Medium: medium}
|
||||
pod = testPodWithVolume(image, volumePath, source)
|
||||
)
|
||||
|
||||
@@ -271,17 +271,17 @@ func doTest0666(f *framework.Framework, image string, medium api.StorageMedium)
|
||||
"perms of file \"/test-volume/test-file\": -rw-rw-rw-",
|
||||
"content of file \"/test-volume/test-file\": mount-tester new file",
|
||||
}
|
||||
if medium == api.StorageMediumMemory {
|
||||
if medium == v1.StorageMediumMemory {
|
||||
out = append(out, "mount type of \"/test-volume\": tmpfs")
|
||||
}
|
||||
f.TestContainerOutput(msg, pod, 0, out)
|
||||
}
|
||||
|
||||
func doTest0777(f *framework.Framework, image string, medium api.StorageMedium) {
|
||||
func doTest0777(f *framework.Framework, image string, medium v1.StorageMedium) {
|
||||
var (
|
||||
volumePath = "/test-volume"
|
||||
filePath = path.Join(volumePath, "test-file")
|
||||
source = &api.EmptyDirVolumeSource{Medium: medium}
|
||||
source = &v1.EmptyDirVolumeSource{Medium: medium}
|
||||
pod = testPodWithVolume(image, volumePath, source)
|
||||
)
|
||||
|
||||
@@ -296,36 +296,36 @@ func doTest0777(f *framework.Framework, image string, medium api.StorageMedium)
|
||||
"perms of file \"/test-volume/test-file\": -rwxrwxrwx",
|
||||
"content of file \"/test-volume/test-file\": mount-tester new file",
|
||||
}
|
||||
if medium == api.StorageMediumMemory {
|
||||
if medium == v1.StorageMediumMemory {
|
||||
out = append(out, "mount type of \"/test-volume\": tmpfs")
|
||||
}
|
||||
f.TestContainerOutput(msg, pod, 0, out)
|
||||
}
|
||||
|
||||
func formatMedium(medium api.StorageMedium) string {
|
||||
if medium == api.StorageMediumMemory {
|
||||
func formatMedium(medium v1.StorageMedium) string {
|
||||
if medium == v1.StorageMediumMemory {
|
||||
return "tmpfs"
|
||||
}
|
||||
|
||||
return "node default medium"
|
||||
}
|
||||
|
||||
func testPodWithVolume(image, path string, source *api.EmptyDirVolumeSource) *api.Pod {
|
||||
func testPodWithVolume(image, path string, source *v1.EmptyDirVolumeSource) *v1.Pod {
|
||||
podName := "pod-" + string(uuid.NewUUID())
|
||||
return &api.Pod{
|
||||
return &v1.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: registered.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
APIVersion: registered.GroupOrDie(v1.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: podName,
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Name: containerName,
|
||||
Image: image,
|
||||
VolumeMounts: []api.VolumeMount{
|
||||
VolumeMounts: []v1.VolumeMount{
|
||||
{
|
||||
Name: volumeName,
|
||||
MountPath: path,
|
||||
@@ -333,16 +333,16 @@ func testPodWithVolume(image, path string, source *api.EmptyDirVolumeSource) *ap
|
||||
},
|
||||
},
|
||||
},
|
||||
SecurityContext: &api.PodSecurityContext{
|
||||
SELinuxOptions: &api.SELinuxOptions{
|
||||
SecurityContext: &v1.PodSecurityContext{
|
||||
SELinuxOptions: &v1.SELinuxOptions{
|
||||
Level: "s0",
|
||||
},
|
||||
},
|
||||
RestartPolicy: api.RestartPolicyNever,
|
||||
Volumes: []api.Volume{
|
||||
RestartPolicy: v1.RestartPolicyNever,
|
||||
Volumes: []v1.Volume{
|
||||
{
|
||||
Name: volumeName,
|
||||
VolumeSource: api.VolumeSource{
|
||||
VolumeSource: v1.VolumeSource{
|
||||
EmptyDir: source,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user