mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Node e2e: switch most of the tests to use the e2e framework
This commit switches the tests to use the e2e framework, so that namespace creation/deletion is handled between tests.
This commit is contained in:
parent
6e5faf59b2
commit
2b65b5a283
@ -21,23 +21,16 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
apierrs "k8s.io/kubernetes/pkg/api/errors"
|
|
||||||
"k8s.io/kubernetes/pkg/client/restclient"
|
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Kubelet Container Manager", func() {
|
var _ = framework.KubeDescribe("Kubelet Container Manager", func() {
|
||||||
var cl *client.Client
|
f := NewDefaultFramework("kubelet-container-manager")
|
||||||
BeforeEach(func() {
|
|
||||||
// Setup the apiserver client
|
|
||||||
cl = client.NewOrDie(&restclient.Config{Host: *apiServerAddress})
|
|
||||||
})
|
|
||||||
Describe("oom score adjusting", func() {
|
Describe("oom score adjusting", func() {
|
||||||
namespace := "oom-adj"
|
|
||||||
Context("when scheduling a busybox command that always fails in a pod", func() {
|
Context("when scheduling a busybox command that always fails in a pod", func() {
|
||||||
var podName string
|
var podName string
|
||||||
|
|
||||||
@ -46,7 +39,7 @@ var _ = Describe("Kubelet Container Manager", func() {
|
|||||||
pod := &api.Pod{
|
pod := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: podName,
|
Name: podName,
|
||||||
Namespace: namespace,
|
Namespace: f.Namespace.Name,
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
// Force the Pod to schedule to the node without a scheduler running
|
// Force the Pod to schedule to the node without a scheduler running
|
||||||
@ -63,13 +56,13 @@ var _ = Describe("Kubelet Container Manager", func() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := cl.Pods(namespace).Create(pod)
|
_, err := f.Client.Pods(f.Namespace.Name).Create(pod)
|
||||||
Expect(err).To(BeNil(), fmt.Sprintf("Error creating Pod %v", err))
|
Expect(err).To(BeNil(), fmt.Sprintf("Error creating Pod %v", err))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("it should have an error terminated reason", func() {
|
It("should have an error terminated reason", func() {
|
||||||
Eventually(func() error {
|
Eventually(func() error {
|
||||||
podData, err := cl.Pods(namespace).Get(podName)
|
podData, err := f.Client.Pods(f.Namespace.Name).Get(podName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -87,22 +80,10 @@ var _ = Describe("Kubelet Container Manager", func() {
|
|||||||
}, time.Minute, time.Second*4).Should(BeNil())
|
}, time.Minute, time.Second*4).Should(BeNil())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("it should be possible to delete", func() {
|
It("should be possible to delete", func() {
|
||||||
err := cl.Pods(namespace).Delete(podName, &api.DeleteOptions{})
|
err := f.Client.Pods(f.Namespace.Name).Delete(podName, &api.DeleteOptions{})
|
||||||
Expect(err).To(BeNil(), fmt.Sprintf("Error deleting Pod %v", err))
|
Expect(err).To(BeNil(), fmt.Sprintf("Error deleting Pod %v", err))
|
||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
|
||||||
cl.Pods(namespace).Delete(podName, &api.DeleteOptions{})
|
|
||||||
Eventually(func() bool {
|
|
||||||
_, err := cl.Pods(namespace).Get(podName)
|
|
||||||
if err != nil && apierrs.IsNotFound(err) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}, time.Minute, time.Second*4).Should(BeTrue())
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -19,9 +19,6 @@ package e2e_node
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/client/restclient"
|
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
@ -34,13 +31,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Image Container Conformance Test", func() {
|
var _ = Describe("Image Container Conformance Test", func() {
|
||||||
var cl *client.Client
|
|
||||||
|
|
||||||
BeforeEach(func() {
|
|
||||||
// Setup the apiserver client
|
|
||||||
cl = client.NewOrDie(&restclient.Config{Host: *apiServerAddress})
|
|
||||||
})
|
|
||||||
|
|
||||||
Describe("[FLAKY] image conformance blackbox test", func() {
|
Describe("[FLAKY] image conformance blackbox test", func() {
|
||||||
Context("when testing images that exist", func() {
|
Context("when testing images that exist", func() {
|
||||||
var conformImages []ConformanceImage
|
var conformImages []ConformanceImage
|
||||||
|
@ -38,9 +38,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var _ = framework.KubeDescribe("Kubelet", func() {
|
var _ = framework.KubeDescribe("Kubelet", func() {
|
||||||
|
f := NewDefaultFramework("kubelet-test")
|
||||||
Context("when scheduling a busybox command in a pod", func() {
|
Context("when scheduling a busybox command in a pod", func() {
|
||||||
// Setup the framework
|
|
||||||
f := NewDefaultFramework("pod-scheduling")
|
|
||||||
podName := "busybox-scheduling-" + string(util.NewUUID())
|
podName := "busybox-scheduling-" + string(util.NewUUID())
|
||||||
It("it should print the output to logs", func() {
|
It("it should print the output to logs", func() {
|
||||||
podClient := f.Client.Pods(f.Namespace.Name)
|
podClient := f.Client.Pods(f.Namespace.Name)
|
||||||
@ -81,7 +80,6 @@ var _ = framework.KubeDescribe("Kubelet", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Context("when scheduling a read only busybox container", func() {
|
Context("when scheduling a read only busybox container", func() {
|
||||||
f := NewDefaultFramework("pod-scheduling")
|
|
||||||
podName := "busybox-readonly-fs" + string(util.NewUUID())
|
podName := "busybox-readonly-fs" + string(util.NewUUID())
|
||||||
It("it should not write to root filesystem", func() {
|
It("it should not write to root filesystem", func() {
|
||||||
podClient := f.Client.Pods(f.Namespace.Name)
|
podClient := f.Client.Pods(f.Namespace.Name)
|
||||||
@ -123,8 +121,6 @@ var _ = framework.KubeDescribe("Kubelet", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
Describe("metrics api", func() {
|
Describe("metrics api", func() {
|
||||||
// Setup the framework
|
|
||||||
f := NewDefaultFramework("kubelet-metrics-api")
|
|
||||||
Context("when querying /stats/summary", func() {
|
Context("when querying /stats/summary", func() {
|
||||||
It("it should report resource usage through the stats api", func() {
|
It("it should report resource usage through the stats api", func() {
|
||||||
podNamePrefix := "stats-busybox-" + string(util.NewUUID())
|
podNamePrefix := "stats-busybox-" + string(util.NewUUID())
|
||||||
|
@ -24,25 +24,21 @@ import (
|
|||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/errors"
|
"k8s.io/kubernetes/pkg/api/errors"
|
||||||
"k8s.io/kubernetes/pkg/client/restclient"
|
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/types"
|
"k8s.io/kubernetes/pkg/types"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("MirrorPod", func() {
|
var _ = framework.KubeDescribe("MirrorPod", func() {
|
||||||
var cl *client.Client
|
f := NewDefaultFramework("mirror-pod")
|
||||||
BeforeEach(func() {
|
|
||||||
// Setup the apiserver client
|
|
||||||
cl = client.NewOrDie(&restclient.Config{Host: *apiServerAddress})
|
|
||||||
})
|
|
||||||
ns := "mirror-pod"
|
|
||||||
Context("when create a mirror pod ", func() {
|
Context("when create a mirror pod ", func() {
|
||||||
var staticPodName, mirrorPodName string
|
var staticPodName, mirrorPodName string
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
|
ns := f.Namespace.Name
|
||||||
staticPodName = "static-pod-" + string(util.NewUUID())
|
staticPodName = "static-pod-" + string(util.NewUUID())
|
||||||
mirrorPodName = staticPodName + "-" + e2es.nodeName
|
mirrorPodName = staticPodName + "-" + e2es.nodeName
|
||||||
|
|
||||||
@ -52,12 +48,13 @@ var _ = Describe("MirrorPod", func() {
|
|||||||
|
|
||||||
By("wait for the mirror pod to be running")
|
By("wait for the mirror pod to be running")
|
||||||
Eventually(func() error {
|
Eventually(func() error {
|
||||||
return checkMirrorPodRunning(cl, mirrorPodName, ns)
|
return checkMirrorPodRunning(f.Client, mirrorPodName, ns)
|
||||||
}, 2*time.Minute, time.Second*4).Should(BeNil())
|
}, 2*time.Minute, time.Second*4).Should(BeNil())
|
||||||
})
|
})
|
||||||
It("should be updated when static pod updated", func() {
|
It("should be updated when static pod updated", func() {
|
||||||
|
ns := f.Namespace.Name
|
||||||
By("get mirror pod uid")
|
By("get mirror pod uid")
|
||||||
pod, err := cl.Pods(ns).Get(mirrorPodName)
|
pod, err := f.Client.Pods(ns).Get(mirrorPodName)
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
uid := pod.UID
|
uid := pod.UID
|
||||||
|
|
||||||
@ -68,53 +65,56 @@ var _ = Describe("MirrorPod", func() {
|
|||||||
|
|
||||||
By("wait for the mirror pod to be updated")
|
By("wait for the mirror pod to be updated")
|
||||||
Eventually(func() error {
|
Eventually(func() error {
|
||||||
return checkMirrorPodRecreatedAndRunnig(cl, mirrorPodName, ns, uid)
|
return checkMirrorPodRecreatedAndRunnig(f.Client, mirrorPodName, ns, uid)
|
||||||
}, 2*time.Minute, time.Second*4).Should(BeNil())
|
}, 2*time.Minute, time.Second*4).Should(BeNil())
|
||||||
|
|
||||||
By("check the mirror pod container image is updated")
|
By("check the mirror pod container image is updated")
|
||||||
pod, err = cl.Pods(ns).Get(mirrorPodName)
|
pod, err = f.Client.Pods(ns).Get(mirrorPodName)
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
Expect(len(pod.Spec.Containers)).Should(Equal(1))
|
Expect(len(pod.Spec.Containers)).Should(Equal(1))
|
||||||
Expect(pod.Spec.Containers[0].Image).Should(Equal(image))
|
Expect(pod.Spec.Containers[0].Image).Should(Equal(image))
|
||||||
})
|
})
|
||||||
It("should be recreated when mirror pod gracefully deleted", func() {
|
It("should be recreated when mirror pod gracefully deleted", func() {
|
||||||
|
ns := f.Namespace.Name
|
||||||
By("get mirror pod uid")
|
By("get mirror pod uid")
|
||||||
pod, err := cl.Pods(ns).Get(mirrorPodName)
|
pod, err := f.Client.Pods(ns).Get(mirrorPodName)
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
uid := pod.UID
|
uid := pod.UID
|
||||||
|
|
||||||
By("delete the mirror pod with grace period 30s")
|
By("delete the mirror pod with grace period 30s")
|
||||||
err = cl.Pods(ns).Delete(mirrorPodName, api.NewDeleteOptions(30))
|
err = f.Client.Pods(ns).Delete(mirrorPodName, api.NewDeleteOptions(30))
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
|
|
||||||
By("wait for the mirror pod to be recreated")
|
By("wait for the mirror pod to be recreated")
|
||||||
Eventually(func() error {
|
Eventually(func() error {
|
||||||
return checkMirrorPodRecreatedAndRunnig(cl, mirrorPodName, ns, uid)
|
return checkMirrorPodRecreatedAndRunnig(f.Client, mirrorPodName, ns, uid)
|
||||||
}, 2*time.Minute, time.Second*4).Should(BeNil())
|
}, 2*time.Minute, time.Second*4).Should(BeNil())
|
||||||
})
|
})
|
||||||
It("should be recreated when mirror pod forcibly deleted", func() {
|
It("should be recreated when mirror pod forcibly deleted", func() {
|
||||||
|
ns := f.Namespace.Name
|
||||||
By("get mirror pod uid")
|
By("get mirror pod uid")
|
||||||
pod, err := cl.Pods(ns).Get(mirrorPodName)
|
pod, err := f.Client.Pods(ns).Get(mirrorPodName)
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
uid := pod.UID
|
uid := pod.UID
|
||||||
|
|
||||||
By("delete the mirror pod with grace period 0s")
|
By("delete the mirror pod with grace period 0s")
|
||||||
err = cl.Pods(ns).Delete(mirrorPodName, api.NewDeleteOptions(0))
|
err = f.Client.Pods(ns).Delete(mirrorPodName, api.NewDeleteOptions(0))
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
|
|
||||||
By("wait for the mirror pod to be recreated")
|
By("wait for the mirror pod to be recreated")
|
||||||
Eventually(func() error {
|
Eventually(func() error {
|
||||||
return checkMirrorPodRecreatedAndRunnig(cl, mirrorPodName, ns, uid)
|
return checkMirrorPodRecreatedAndRunnig(f.Client, mirrorPodName, ns, uid)
|
||||||
}, 2*time.Minute, time.Second*4).Should(BeNil())
|
}, 2*time.Minute, time.Second*4).Should(BeNil())
|
||||||
})
|
})
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
|
ns := f.Namespace.Name
|
||||||
By("delete the static pod")
|
By("delete the static pod")
|
||||||
err := deleteStaticPod(e2es.kubeletStaticPodDir, staticPodName, ns)
|
err := deleteStaticPod(e2es.kubeletStaticPodDir, staticPodName, ns)
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
|
|
||||||
By("wait for the mirror pod to disappear")
|
By("wait for the mirror pod to disappear")
|
||||||
Eventually(func() error {
|
Eventually(func() error {
|
||||||
return checkMirrorPodDisappear(cl, mirrorPodName, ns)
|
return checkMirrorPodDisappear(f.Client, mirrorPodName, ns)
|
||||||
}, 2*time.Minute, time.Second*4).Should(BeNil())
|
}, 2*time.Minute, time.Second*4).Should(BeNil())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -24,8 +24,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/client/restclient"
|
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@ -48,15 +46,9 @@ type testCase struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _ = Describe("Container Runtime Conformance Test", func() {
|
var _ = Describe("Container Runtime Conformance Test", func() {
|
||||||
var cl *client.Client
|
f := NewDefaultFramework("runtime-conformance")
|
||||||
|
|
||||||
BeforeEach(func() {
|
|
||||||
// Setup the apiserver client
|
|
||||||
cl = client.NewOrDie(&restclient.Config{Host: *apiServerAddress})
|
|
||||||
})
|
|
||||||
|
|
||||||
Describe("container runtime conformance blackbox test", func() {
|
Describe("container runtime conformance blackbox test", func() {
|
||||||
namespace := "runtime-conformance"
|
|
||||||
|
|
||||||
Context("when starting a container that exits", func() {
|
Context("when starting a container that exits", func() {
|
||||||
It("it should run with the expected status [Conformance]", func() {
|
It("it should run with the expected status [Conformance]", func() {
|
||||||
@ -108,11 +100,11 @@ while true; do sleep 1; done
|
|||||||
testContainer.Command = []string{"sh", "-c", tmpCmd}
|
testContainer.Command = []string{"sh", "-c", tmpCmd}
|
||||||
terminateContainer := ConformanceContainer{
|
terminateContainer := ConformanceContainer{
|
||||||
Container: testContainer,
|
Container: testContainer,
|
||||||
Client: cl,
|
Client: f.Client,
|
||||||
RestartPolicy: testCase.RestartPolicy,
|
RestartPolicy: testCase.RestartPolicy,
|
||||||
Volumes: testVolumes,
|
Volumes: testVolumes,
|
||||||
NodeName: *nodeName,
|
NodeName: *nodeName,
|
||||||
Namespace: namespace,
|
Namespace: f.Namespace.Name,
|
||||||
}
|
}
|
||||||
Expect(terminateContainer.Create()).To(Succeed())
|
Expect(terminateContainer.Create()).To(Succeed())
|
||||||
defer terminateContainer.Delete()
|
defer terminateContainer.Delete()
|
||||||
@ -152,10 +144,10 @@ while true; do sleep 1; done
|
|||||||
testContainer.Name = testCase.Name
|
testContainer.Name = testCase.Name
|
||||||
invalidImageContainer := ConformanceContainer{
|
invalidImageContainer := ConformanceContainer{
|
||||||
Container: testContainer,
|
Container: testContainer,
|
||||||
Client: cl,
|
Client: f.Client,
|
||||||
RestartPolicy: testCase.RestartPolicy,
|
RestartPolicy: testCase.RestartPolicy,
|
||||||
NodeName: *nodeName,
|
NodeName: *nodeName,
|
||||||
Namespace: namespace,
|
Namespace: f.Namespace.Name,
|
||||||
}
|
}
|
||||||
Expect(invalidImageContainer.Create()).To(Succeed())
|
Expect(invalidImageContainer.Create()).To(Succeed())
|
||||||
defer invalidImageContainer.Delete()
|
defer invalidImageContainer.Delete()
|
||||||
|
Loading…
Reference in New Issue
Block a user