Remove /podInfo endpoint on kubelet
Kubelet sends pod status updates to the API server now. This endpoint is no longer needed.
This commit is contained in:
@@ -25,20 +25,12 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/probe"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
)
|
||||
|
||||
func TestHTTPKubeletClient(t *testing.T) {
|
||||
expectObj := api.PodStatusResult{
|
||||
Status: api.PodStatus{
|
||||
ContainerStatuses: []api.ContainerStatus{
|
||||
{Name: "myID1"},
|
||||
{Name: "myID2"},
|
||||
},
|
||||
},
|
||||
}
|
||||
expectObj := probe.Success
|
||||
body, err := json.Marshal(expectObj)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@@ -63,76 +55,21 @@ func TestHTTPKubeletClient(t *testing.T) {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
podInfoGetter := &HTTPKubeletClient{
|
||||
c := &HTTPKubeletClient{
|
||||
Client: http.DefaultClient,
|
||||
Port: uint(port),
|
||||
}
|
||||
gotObj, err := podInfoGetter.GetPodStatus(parts[0], api.NamespaceDefault, "foo")
|
||||
gotObj, err := c.HealthCheck(parts[0])
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
// reflect.DeepEqual(expectObj, gotObj) doesn't handle blank times well
|
||||
if len(gotObj.Status.ContainerStatuses) != len(expectObj.Status.ContainerStatuses) {
|
||||
t.Errorf("Unexpected response. Expected: %#v, received %#v", expectObj, gotObj)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPKubeletClientNotFound(t *testing.T) {
|
||||
expectObj := api.PodContainerInfo{
|
||||
ContainerInfo: []api.ContainerStatus{
|
||||
{
|
||||
Name: "myID",
|
||||
},
|
||||
},
|
||||
}
|
||||
_, err := json.Marshal(expectObj)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 404,
|
||||
ResponseBody: "Pod not found",
|
||||
}
|
||||
testServer := httptest.NewServer(&fakeHandler)
|
||||
defer testServer.Close()
|
||||
|
||||
hostURL, err := url.Parse(testServer.URL)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
parts := strings.Split(hostURL.Host, ":")
|
||||
|
||||
port, err := strconv.Atoi(parts[1])
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
podInfoGetter := &HTTPKubeletClient{
|
||||
Client: http.DefaultClient,
|
||||
Port: uint(port),
|
||||
}
|
||||
_, err = podInfoGetter.GetPodStatus(parts[0], api.NamespaceDefault, "foo")
|
||||
if err != ErrPodInfoNotAvailable {
|
||||
t.Errorf("Expected %#v, Got %#v", ErrPodInfoNotAvailable, err)
|
||||
if gotObj != expectObj {
|
||||
t.Errorf("expected: %#v, got %#v", expectObj, gotObj)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPKubeletClientError(t *testing.T) {
|
||||
expectObj := api.PodContainerInfo{
|
||||
ContainerInfo: []api.ContainerStatus{
|
||||
{
|
||||
Name: "myID",
|
||||
},
|
||||
},
|
||||
}
|
||||
_, err := json.Marshal(expectObj)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
expectObj := probe.Failure
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 500,
|
||||
ResponseBody: "Internal server error",
|
||||
@@ -152,13 +89,13 @@ func TestHTTPKubeletClientError(t *testing.T) {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
podInfoGetter := &HTTPKubeletClient{
|
||||
c := &HTTPKubeletClient{
|
||||
Client: http.DefaultClient,
|
||||
Port: uint(port),
|
||||
}
|
||||
_, err = podInfoGetter.GetPodStatus(parts[0], api.NamespaceDefault, "foo")
|
||||
if err == nil || !strings.Contains(err.Error(), "HTTP error code 500") {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
gotObj, err := c.HealthCheck(parts[0])
|
||||
if gotObj != expectObj {
|
||||
t.Errorf("expected: %#v, got %#v", expectObj, gotObj)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user