mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-17 07:03:31 +00:00
e2e framework: move kubectl and pod helper code
This commit is contained in:
@@ -26,6 +26,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2etodopod "k8s.io/kubernetes/test/e2e/framework/todo/pod"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
|
||||
@@ -79,7 +80,7 @@ var _ = SIGDescribe("ConfigMap", func() {
|
||||
},
|
||||
}
|
||||
|
||||
f.TestContainerOutput("consume configMaps", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "consume configMaps", pod, 0, []string{
|
||||
"CONFIG_DATA_1=value-1",
|
||||
})
|
||||
})
|
||||
@@ -123,7 +124,7 @@ var _ = SIGDescribe("ConfigMap", func() {
|
||||
},
|
||||
}
|
||||
|
||||
f.TestContainerOutput("consume configMaps", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "consume configMaps", pod, 0, []string{
|
||||
"data-1=value-1", "data-2=value-2", "data-3=value-3",
|
||||
"p-data-1=value-1", "p-data-2=value-2", "p-data-3=value-3",
|
||||
})
|
||||
|
@@ -23,6 +23,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||
e2etodopod "k8s.io/kubernetes/test/e2e/framework/todo/pod"
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
)
|
||||
|
||||
@@ -57,7 +58,7 @@ var _ = SIGDescribe("Containers", func() {
|
||||
*/
|
||||
framework.ConformanceIt("should be able to override the image's default arguments (container cmd) [NodeConformance]", func() {
|
||||
pod := entrypointTestPod(f.Namespace.Name, "entrypoint-tester", "override", "arguments")
|
||||
f.TestContainerOutput("override arguments", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "override arguments", pod, 0, []string{
|
||||
"[/agnhost entrypoint-tester override arguments]",
|
||||
})
|
||||
})
|
||||
@@ -73,7 +74,7 @@ var _ = SIGDescribe("Containers", func() {
|
||||
pod := entrypointTestPod(f.Namespace.Name, "entrypoint-tester")
|
||||
pod.Spec.Containers[0].Command = []string{"/agnhost-2"}
|
||||
|
||||
f.TestContainerOutput("override command", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "override command", pod, 0, []string{
|
||||
"[/agnhost-2 entrypoint-tester]",
|
||||
})
|
||||
})
|
||||
@@ -87,7 +88,7 @@ var _ = SIGDescribe("Containers", func() {
|
||||
pod := entrypointTestPod(f.Namespace.Name, "entrypoint-tester", "override", "arguments")
|
||||
pod.Spec.Containers[0].Command = []string{"/agnhost-2"}
|
||||
|
||||
f.TestContainerOutput("override all", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "override all", pod, 0, []string{
|
||||
"[/agnhost-2 entrypoint-tester override arguments]",
|
||||
})
|
||||
})
|
||||
|
@@ -25,6 +25,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
|
||||
e2etodopod "k8s.io/kubernetes/test/e2e/framework/todo/pod"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
|
||||
@@ -418,5 +419,5 @@ func testDownwardAPI(f *framework.Framework, podName string, env []v1.EnvVar, ex
|
||||
}
|
||||
|
||||
func testDownwardAPIUsingPod(f *framework.Framework, pod *v1.Pod, env []v1.EnvVar, expectations []string) {
|
||||
f.TestContainerOutputRegexp("downward api env vars", pod, 0, expectations)
|
||||
e2etodopod.TestContainerOutputRegexp(f, "downward api env vars", pod, 0, expectations)
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||
e2etodopod "k8s.io/kubernetes/test/e2e/framework/todo/pod"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
|
||||
@@ -57,7 +58,7 @@ var _ = SIGDescribe("Variable Expansion", func() {
|
||||
}
|
||||
pod := newPod([]string{"sh", "-c", "env"}, envVars, nil, nil)
|
||||
|
||||
f.TestContainerOutput("env composition", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "env composition", pod, 0, []string{
|
||||
"FOO=foo-value",
|
||||
"BAR=bar-value",
|
||||
"FOOBAR=foo-value;;bar-value",
|
||||
@@ -78,7 +79,7 @@ var _ = SIGDescribe("Variable Expansion", func() {
|
||||
}
|
||||
pod := newPod([]string{"sh", "-c", "TEST_VAR=wrong echo \"$(TEST_VAR)\""}, envVars, nil, nil)
|
||||
|
||||
f.TestContainerOutput("substitution in container's command", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "substitution in container's command", pod, 0, []string{
|
||||
"test-value",
|
||||
})
|
||||
})
|
||||
@@ -98,7 +99,7 @@ var _ = SIGDescribe("Variable Expansion", func() {
|
||||
pod := newPod([]string{"sh", "-c"}, envVars, nil, nil)
|
||||
pod.Spec.Containers[0].Args = []string{"TEST_VAR=wrong echo \"$(TEST_VAR)\""}
|
||||
|
||||
f.TestContainerOutput("substitution in container's args", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "substitution in container's args", pod, 0, []string{
|
||||
"test-value",
|
||||
})
|
||||
})
|
||||
@@ -138,7 +139,7 @@ var _ = SIGDescribe("Variable Expansion", func() {
|
||||
envVars[0].Value = pod.ObjectMeta.Name
|
||||
pod.Spec.Containers[0].Command = []string{"sh", "-c", "test -d /testcontainer/" + pod.ObjectMeta.Name + ";echo $?"}
|
||||
|
||||
f.TestContainerOutput("substitution in volume subpath", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "substitution in volume subpath", pod, 0, []string{
|
||||
"0",
|
||||
})
|
||||
})
|
||||
|
@@ -51,6 +51,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/kubelet"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||
e2etodopod "k8s.io/kubernetes/test/e2e/framework/todo/pod"
|
||||
e2ewebsocket "k8s.io/kubernetes/test/e2e/framework/websocket"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
@@ -522,7 +523,7 @@ var _ = SIGDescribe("Pods", func() {
|
||||
"FOOSERVICE_PORT_8765_TCP_ADDR=",
|
||||
}
|
||||
expectNoErrorWithRetries(func() error {
|
||||
return f.MatchContainerOutput(pod, containerName, expectedVars, gomega.ContainSubstring)
|
||||
return e2etodopod.MatchContainerOutput(f, pod, containerName, expectedVars, gomega.ContainSubstring)
|
||||
}, maxRetries, "Container should have service environment variables set")
|
||||
})
|
||||
|
||||
|
@@ -29,6 +29,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2etodopod "k8s.io/kubernetes/test/e2e/framework/todo/pod"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
)
|
||||
@@ -81,7 +82,7 @@ var _ = SIGDescribe("Secrets", func() {
|
||||
},
|
||||
}
|
||||
|
||||
f.TestContainerOutput("consume secrets", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "consume secrets", pod, 0, []string{
|
||||
"SECRET_DATA=value-1",
|
||||
})
|
||||
})
|
||||
@@ -125,7 +126,7 @@ var _ = SIGDescribe("Secrets", func() {
|
||||
},
|
||||
}
|
||||
|
||||
f.TestContainerOutput("consume secrets", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "consume secrets", pod, 0, []string{
|
||||
"data-1=value-1", "data-2=value-2", "data-3=value-3",
|
||||
"p-data-1=value-1", "p-data-2=value-2", "p-data-3=value-3",
|
||||
})
|
||||
|
@@ -29,6 +29,7 @@ import (
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
||||
e2etodopod "k8s.io/kubernetes/test/e2e/framework/todo/pod"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
"k8s.io/utils/pointer"
|
||||
@@ -115,7 +116,7 @@ var _ = SIGDescribe("Security Context", func() {
|
||||
// When running in the host's user namespace, the /proc/self/uid_map file content looks like:
|
||||
// 0 0 4294967295
|
||||
// Verify the value 4294967295 is present in the output.
|
||||
f.TestContainerOutput("read namespace", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "read namespace", pod, 0, []string{
|
||||
"4294967295",
|
||||
})
|
||||
})
|
||||
@@ -239,7 +240,7 @@ var _ = SIGDescribe("Security Context", func() {
|
||||
// Each line should be "=0" that means root inside the container is the owner of the file.
|
||||
downwardAPIVolFiles := 1
|
||||
projectedFiles := len(secret.Data) + downwardAPIVolFiles
|
||||
f.TestContainerOutput("check file permissions", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "check file permissions", pod, 0, []string{
|
||||
strings.Repeat("=0\n", len(secret.Data)+len(configMap.Data)+downwardAPIVolFiles+projectedFiles),
|
||||
})
|
||||
})
|
||||
@@ -299,7 +300,7 @@ var _ = SIGDescribe("Security Context", func() {
|
||||
// Expect one line for each file on all the volumes.
|
||||
// Each line should be "=200" (fsGroup) that means it was mapped to the
|
||||
// right user inside the container.
|
||||
f.TestContainerOutput("check FSGroup is mapped correctly", pod, 0, []string{
|
||||
e2etodopod.TestContainerOutput(f, "check FSGroup is mapped correctly", pod, 0, []string{
|
||||
strings.Repeat(fmt.Sprintf("=%v\n", fsGroup), len(configMap.Data)),
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user