use different pod names and namespaces

pull/6/head
Phillip Wittrock 2016-03-03 14:40:26 -08:00
parent a511961cc8
commit ce2d2c84c1
1 changed files with 22 additions and 18 deletions

View File

@ -44,12 +44,14 @@ var _ = Describe("Kubelet", func() {
}) })
Describe("pod scheduling", func() { Describe("pod scheduling", func() {
namespace := "pod-scheduling"
Context("when scheduling a busybox command in a pod", func() { Context("when scheduling a busybox command in a pod", func() {
podName := "busybox-scheduling"
It("it should return succes", func() { It("it should return succes", func() {
pod := &api.Pod{ pod := &api.Pod{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: "busybox", Name: podName,
Namespace: api.NamespaceDefault, Namespace: namespace,
}, },
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
@ -59,20 +61,20 @@ var _ = Describe("Kubelet", func() {
Containers: []api.Container{ Containers: []api.Container{
{ {
Image: "gcr.io/google_containers/busybox", Image: "gcr.io/google_containers/busybox",
Name: "busybox", Name: podName,
Command: []string{"echo", "'Hello World'"}, Command: []string{"echo", "'Hello World'"},
}, },
}, },
}, },
} }
_, err := cl.Pods(api.NamespaceDefault).Create(pod) _, err := cl.Pods(namespace).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 print the output to logs", func() { It("it should print the output to logs", func() {
Eventually(func() string { Eventually(func() string {
sinceTime := unversioned.NewTime(time.Now().Add(time.Duration(-1 * time.Hour))) sinceTime := unversioned.NewTime(time.Now().Add(time.Duration(-1 * time.Hour)))
rc, err := cl.Pods(api.NamespaceDefault).GetLogs("busybox", &api.PodLogOptions{SinceTime: &sinceTime}).Stream() rc, err := cl.Pods(namespace).GetLogs(podName, &api.PodLogOptions{SinceTime: &sinceTime}).Stream()
if err != nil { if err != nil {
return "" return ""
} }
@ -84,18 +86,19 @@ var _ = Describe("Kubelet", func() {
}) })
It("it should be possible to delete", func() { It("it should be possible to delete", func() {
err := cl.Pods(api.NamespaceDefault).Delete("busybox", &api.DeleteOptions{}) err := cl.Pods(namespace).Delete(podName, &api.DeleteOptions{})
Expect(err).To(BeNil(), fmt.Sprintf("Error creating Pod %v", err)) Expect(err).To(BeNil(), fmt.Sprintf("Error deleting Pod %v", err))
}) })
}) })
Context("when scheduling a read only busybox container", func() { Context("when scheduling a read only busybox container", func() {
podName := "busybox-readonly-fs"
It("it should return success", func() { It("it should return success", func() {
isReadOnly := true isReadOnly := true
pod := &api.Pod{ pod := &api.Pod{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: "busybox", Name: podName,
Namespace: api.NamespaceDefault, Namespace: namespace,
}, },
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
@ -105,7 +108,7 @@ var _ = Describe("Kubelet", func() {
Containers: []api.Container{ Containers: []api.Container{
{ {
Image: "gcr.io/google_containers/busybox", Image: "gcr.io/google_containers/busybox",
Name: "busybox", Name: podName,
Command: []string{"sh", "-c", "echo test > /file"}, Command: []string{"sh", "-c", "echo test > /file"},
SecurityContext: &api.SecurityContext{ SecurityContext: &api.SecurityContext{
ReadOnlyRootFilesystem: &isReadOnly, ReadOnlyRootFilesystem: &isReadOnly,
@ -114,13 +117,13 @@ var _ = Describe("Kubelet", func() {
}, },
}, },
} }
_, err := cl.Pods(api.NamespaceDefault).Create(pod) _, err := cl.Pods(namespace).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 not write to the root filesystem", func() { It("it should not write to the root filesystem", func() {
Eventually(func() string { Eventually(func() string {
rc, err := cl.Pods(api.NamespaceDefault).GetLogs("busybox", &api.PodLogOptions{}).Stream() rc, err := cl.Pods(namespace).GetLogs(podName, &api.PodLogOptions{}).Stream()
if err != nil { if err != nil {
return "" return ""
} }
@ -132,13 +135,14 @@ var _ = Describe("Kubelet", func() {
}) })
It("it should be possible to delete", func() { It("it should be possible to delete", func() {
err := cl.Pods(api.NamespaceDefault).Delete("busybox", &api.DeleteOptions{}) err := cl.Pods(namespace).Delete(podName, &api.DeleteOptions{})
Expect(err).To(BeNil(), fmt.Sprintf("Error creating Pod %v", err)) Expect(err).To(BeNil(), fmt.Sprintf("Error creating Pod %v", err))
}) })
}) })
}) })
Describe("metrics api", func() { Describe("metrics api", func() {
namespace := "kubelet-metrics-api"
statsPrefix := "stats-busybox-" statsPrefix := "stats-busybox-"
podNames := []string{} podNames := []string{}
podCount := 2 podCount := 2
@ -147,7 +151,7 @@ var _ = Describe("Kubelet", func() {
} }
BeforeEach(func() { BeforeEach(func() {
for _, podName := range podNames { for _, podName := range podNames {
createPod(cl, podName, []api.Container{ createPod(cl, podName, namespace, []api.Container{
{ {
Image: "gcr.io/google_containers/busybox", Image: "gcr.io/google_containers/busybox",
Command: []string{"sh", "-c", "echo 'Hello World' | tee ~/file | tee /test-empty-dir-mnt | sleep 60"}, Command: []string{"sh", "-c", "echo 'Hello World' | tee ~/file | tee /test-empty-dir-mnt | sleep 60"},
@ -259,7 +263,7 @@ var _ = Describe("Kubelet", func() {
AfterEach(func() { AfterEach(func() {
for _, podName := range podNames { for _, podName := range podNames {
err := cl.Pods(api.NamespaceDefault).Delete(podName, &api.DeleteOptions{}) err := cl.Pods(namespace).Delete(podName, &api.DeleteOptions{})
Expect(err).To(BeNil(), fmt.Sprintf("Error deleting Pod %v", podName)) Expect(err).To(BeNil(), fmt.Sprintf("Error deleting Pod %v", podName))
} }
}) })
@ -284,11 +288,11 @@ const (
containerSuffix = "-c" containerSuffix = "-c"
) )
func createPod(cl *client.Client, podName string, containers []api.Container, volumes []api.Volume) { func createPod(cl *client.Client, podName string, namespace string, containers []api.Container, volumes []api.Volume) {
pod := &api.Pod{ pod := &api.Pod{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: podName, Name: podName,
Namespace: api.NamespaceDefault, Namespace: namespace,
}, },
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
@ -299,6 +303,6 @@ func createPod(cl *client.Client, podName string, containers []api.Container, vo
Volumes: volumes, Volumes: volumes,
}, },
} }
_, err := cl.Pods(api.NamespaceDefault).Create(pod) _, err := cl.Pods(namespace).Create(pod)
Expect(err).To(BeNil(), fmt.Sprintf("Error creating Pod %v", err)) Expect(err).To(BeNil(), fmt.Sprintf("Error creating Pod %v", err))
} }