mirror of https://github.com/k3s-io/k3s
Merge pull request #7338 from jayunit100/containers-namespaces
Fixes in e2e tests: checking pods in the right namespace; proper use of namespaces in docker container test.pull/6/head
commit
4256164a2f
|
@ -27,15 +27,24 @@ import (
|
||||||
|
|
||||||
var _ = Describe("Docker Containers", func() {
|
var _ = Describe("Docker Containers", func() {
|
||||||
var c *client.Client
|
var c *client.Client
|
||||||
|
var ns string
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
var err error
|
var err error
|
||||||
c, err = loadClient()
|
c, err = loadClient()
|
||||||
|
ns_, err := createTestingNS("containers", c)
|
||||||
|
ns = ns_.Name
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
AfterEach(func() {
|
||||||
|
if err := c.Namespaces().Delete(ns); err != nil {
|
||||||
|
Failf("Couldn't delete ns %s", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
It("should use the image defaults if command and args are blank", func() {
|
It("should use the image defaults if command and args are blank", func() {
|
||||||
testContainerOutput("use defaults", c, entrypointTestPod(), []string{
|
testContainerOutputInNamespace(ns, "use defaults", c, entrypointTestPod(), []string{
|
||||||
"[/ep default arguments]",
|
"[/ep default arguments]",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -44,7 +53,7 @@ var _ = Describe("Docker Containers", func() {
|
||||||
pod := entrypointTestPod()
|
pod := entrypointTestPod()
|
||||||
pod.Spec.Containers[0].Args = []string{"override", "arguments"}
|
pod.Spec.Containers[0].Args = []string{"override", "arguments"}
|
||||||
|
|
||||||
testContainerOutput("override arguments", c, pod, []string{
|
testContainerOutputInNamespace(ns, "override arguments", c, pod, []string{
|
||||||
"[/ep override arguments]",
|
"[/ep override arguments]",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -55,7 +64,7 @@ var _ = Describe("Docker Containers", func() {
|
||||||
pod := entrypointTestPod()
|
pod := entrypointTestPod()
|
||||||
pod.Spec.Containers[0].Command = []string{"/ep-2"}
|
pod.Spec.Containers[0].Command = []string{"/ep-2"}
|
||||||
|
|
||||||
testContainerOutput("override command", c, pod, []string{
|
testContainerOutputInNamespace(ns, "override command", c, pod, []string{
|
||||||
"[/ep-2]",
|
"[/ep-2]",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -65,7 +74,7 @@ var _ = Describe("Docker Containers", func() {
|
||||||
pod.Spec.Containers[0].Command = []string{"/ep-2"}
|
pod.Spec.Containers[0].Command = []string{"/ep-2"}
|
||||||
pod.Spec.Containers[0].Args = []string{"override", "arguments"}
|
pod.Spec.Containers[0].Args = []string{"override", "arguments"}
|
||||||
|
|
||||||
testContainerOutput("override all", c, pod, []string{
|
testContainerOutputInNamespace(ns, "override all", c, pod, []string{
|
||||||
"[/ep-2 override arguments]",
|
"[/ep-2 override arguments]",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -86,7 +86,7 @@ func waitForPodCondition(c *client.Client, ns, podName, desc string, condition p
|
||||||
for start := time.Now(); time.Since(start) < podStartTimeout; time.Sleep(5 * time.Second) {
|
for start := time.Now(); time.Since(start) < podStartTimeout; time.Sleep(5 * time.Second) {
|
||||||
pod, err := c.Pods(ns).Get(podName)
|
pod, err := c.Pods(ns).Get(podName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Logf("Get pod failed, ignoring for 5s: %v", err)
|
Logf("Get pod %v in ns %v failed, ignoring for 5s: %v", podName, ns, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
done, err := condition(pod)
|
done, err := condition(pod)
|
||||||
|
@ -367,7 +367,7 @@ func testContainerOutputInNamespace(ns, scenarioName string, c *client.Client, p
|
||||||
containerName := pod.Spec.Containers[0].Name
|
containerName := pod.Spec.Containers[0].Name
|
||||||
|
|
||||||
// Wait for client pod to complete.
|
// Wait for client pod to complete.
|
||||||
expectNoError(waitForPodSuccess(c, pod.Name, containerName))
|
expectNoError(waitForPodSuccessInNamespace(c, pod.Name, containerName, ns))
|
||||||
|
|
||||||
// Grab its logs. Get host first.
|
// Grab its logs. Get host first.
|
||||||
podStatus, err := c.Pods(ns).Get(pod.Name)
|
podStatus, err := c.Pods(ns).Get(pod.Name)
|
||||||
|
|
Loading…
Reference in New Issue