Switch the Kubelet to use kubelet/config
Also transfer the Kubelet from using ContainerManifest.ID to source specific identifiers with namespacing. Move goroutine behavior out of kubelet/ and into integration.go and cmd/kubelet/kubelet.go for better isolation.
This commit is contained in:
@@ -36,7 +36,7 @@ import (
|
||||
|
||||
type fakeKubelet struct {
|
||||
infoFunc func(name string) (api.PodInfo, error)
|
||||
containerInfoFunc func(podID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
||||
containerInfoFunc func(podFullName, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
||||
rootInfoFunc func(query *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
||||
machineInfoFunc func() (*info.MachineInfo, error)
|
||||
logFunc func(w http.ResponseWriter, req *http.Request)
|
||||
@@ -46,8 +46,8 @@ func (fk *fakeKubelet) GetPodInfo(name string) (api.PodInfo, error) {
|
||||
return fk.infoFunc(name)
|
||||
}
|
||||
|
||||
func (fk *fakeKubelet) GetContainerInfo(podID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
||||
return fk.containerInfoFunc(podID, containerName, req)
|
||||
func (fk *fakeKubelet) GetContainerInfo(podFullName, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
||||
return fk.containerInfoFunc(podFullName, containerName, req)
|
||||
}
|
||||
|
||||
func (fk *fakeKubelet) GetRootInfo(req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
||||
@@ -63,7 +63,7 @@ func (fk *fakeKubelet) ServeLogs(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
type serverTestFramework struct {
|
||||
updateChan chan manifestUpdate
|
||||
updateChan chan interface{}
|
||||
updateReader *channelReader
|
||||
serverUnderTest *Server
|
||||
fakeKubelet *fakeKubelet
|
||||
@@ -72,13 +72,13 @@ type serverTestFramework struct {
|
||||
|
||||
func makeServerTest() *serverTestFramework {
|
||||
fw := &serverTestFramework{
|
||||
updateChan: make(chan manifestUpdate),
|
||||
updateChan: make(chan interface{}),
|
||||
}
|
||||
fw.updateReader = startReading(fw.updateChan)
|
||||
fw.fakeKubelet = &fakeKubelet{}
|
||||
fw.serverUnderTest = &Server{
|
||||
Kubelet: fw.fakeKubelet,
|
||||
UpdateChannel: fw.updateChan,
|
||||
host: fw.fakeKubelet,
|
||||
updates: fw.updateChan,
|
||||
}
|
||||
fw.testHTTPServer = httptest.NewServer(fw.serverUnderTest)
|
||||
return fw
|
||||
@@ -106,8 +106,9 @@ func TestContainer(t *testing.T) {
|
||||
if len(received) != 1 {
|
||||
t.Errorf("Expected 1 manifest, but got %v", len(received))
|
||||
}
|
||||
if !reflect.DeepEqual(expected, received[0]) {
|
||||
t.Errorf("Expected %#v, but got %#v", expected, received[0])
|
||||
expectedPods := []Pod{Pod{Name: "1", Manifest: expected[0]}}
|
||||
if !reflect.DeepEqual(expectedPods, received[0]) {
|
||||
t.Errorf("Expected %#v, but got %#v", expectedPods, received[0])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,8 +129,9 @@ func TestContainers(t *testing.T) {
|
||||
if len(received) != 1 {
|
||||
t.Errorf("Expected 1 update, but got %v", len(received))
|
||||
}
|
||||
if !reflect.DeepEqual(expected, received[0]) {
|
||||
t.Errorf("Expected %#v, but got %#v", expected, received[0])
|
||||
expectedPods := []Pod{Pod{Name: "1", Manifest: expected[0]}, Pod{Name: "2", Manifest: expected[1]}}
|
||||
if !reflect.DeepEqual(expectedPods, received[0]) {
|
||||
t.Errorf("Expected %#v, but got %#v", expectedPods, received[0])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,10 +139,10 @@ func TestPodInfo(t *testing.T) {
|
||||
fw := makeServerTest()
|
||||
expected := api.PodInfo{"goodpod": docker.Container{ID: "myContainerID"}}
|
||||
fw.fakeKubelet.infoFunc = func(name string) (api.PodInfo, error) {
|
||||
if name == "goodpod" {
|
||||
if name == "goodpod.etcd" {
|
||||
return expected, nil
|
||||
}
|
||||
return nil, fmt.Errorf("bad pod")
|
||||
return nil, fmt.Errorf("bad pod %s", name)
|
||||
}
|
||||
resp, err := http.Get(fw.testHTTPServer.URL + "/podInfo?podID=goodpod")
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user