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:
Yu-Ju Hong
2016-06-13 15:10:36 -07:00
committed by Random-Liu
parent 6e5faf59b2
commit 2b65b5a283
5 changed files with 34 additions and 75 deletions

View File

@@ -21,23 +21,16 @@ import (
"time"
"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/test/e2e/framework"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Kubelet Container Manager", func() {
var cl *client.Client
BeforeEach(func() {
// Setup the apiserver client
cl = client.NewOrDie(&restclient.Config{Host: *apiServerAddress})
})
var _ = framework.KubeDescribe("Kubelet Container Manager", func() {
f := NewDefaultFramework("kubelet-container-manager")
Describe("oom score adjusting", func() {
namespace := "oom-adj"
Context("when scheduling a busybox command that always fails in a pod", func() {
var podName string
@@ -46,7 +39,7 @@ var _ = Describe("Kubelet Container Manager", func() {
pod := &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: podName,
Namespace: namespace,
Namespace: f.Namespace.Name,
},
Spec: api.PodSpec{
// 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))
})
It("it should have an error terminated reason", func() {
It("should have an error terminated reason", func() {
Eventually(func() error {
podData, err := cl.Pods(namespace).Get(podName)
podData, err := f.Client.Pods(f.Namespace.Name).Get(podName)
if err != nil {
return err
}
@@ -87,22 +80,10 @@ var _ = Describe("Kubelet Container Manager", func() {
}, time.Minute, time.Second*4).Should(BeNil())
})
It("it should be possible to delete", func() {
err := cl.Pods(namespace).Delete(podName, &api.DeleteOptions{})
It("should be possible to delete", func() {
err := f.Client.Pods(f.Namespace.Name).Delete(podName, &api.DeleteOptions{})
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())
})
})
})