Initial Pod e2e test

This commit is contained in:
Phillip Wittrock
2015-11-20 15:59:31 -08:00
parent 0d4e0dc173
commit ec5ecb18fa
6 changed files with 100 additions and 33 deletions

View File

@@ -17,36 +17,65 @@ limitations under the License.
package e2e_node
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"time"
"github.com/golang/glog"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned"
)
var _ = Describe("Kubelet", func() {
var cl *client.Client
BeforeEach(func() {
// Setup the client to talk to the kubelet
// Setup the apiserver client
cl = client.NewOrDie(&client.Config{Host: *apiServerAddress})
})
Describe("checking kubelet status", func() {
Context("when retrieving the node status", func() {
It("should have the container version", func() {
Describe("pod scheduling", func() {
Context("when scheduling a busybox command in a pod", func() {
It("it should return succes", func() {
pod := &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "busybox",
Namespace: api.NamespaceDefault,
},
Spec: api.PodSpec{
NodeName: *nodeName,
Containers: []api.Container{
{
Image: "busybox",
Name: "busybox",
Command: []string{"echo", "'Hello World'"},
ImagePullPolicy: "IfNotPresent",
},
},
},
}
_, err := cl.Pods(api.NamespaceDefault).Create(pod)
Expect(err).To(BeNil(), fmt.Sprintf("Error creating Pod %v", err))
})
// TODO: This is just a place holder, write a real test here
resp, err := http.Get(fmt.Sprintf("http://%s:%d/api/v2.0/attributes", *kubeletHost, *kubeletPort))
if err != nil {
glog.Errorf("Error: %v", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
glog.Errorf("Error: %v", err)
return
}
glog.Infof("Resp: %s", body)
It("it should print the output to logs", func() {
errs := Retry(time.Minute*3, time.Second*2, cl, func(cl *client.Client) error {
rc, err := cl.Pods(api.NamespaceDefault).GetLogs("busybox", &api.PodLogOptions{}).Stream()
if err != nil {
return err
}
defer rc.Close()
buf := new(bytes.Buffer)
buf.ReadFrom(rc)
Expect(buf.String()).To(Equal("'Hello World'\n"))
return nil
})
Expect(errs).To(BeEmpty(), fmt.Sprintf("Failed to get Logs"))
})
It("it should be possible to delete", func() {
err := cl.Pods(api.NamespaceDefault).Delete("busybox", &api.DeleteOptions{})
Expect(err).To(BeNil(), fmt.Sprintf("Error creating Pod %v", err))
})
})
})