Fix kubelet tests for systems without functional dns to look up localhost.

pull/6/head
Robert Bailey 2015-05-20 11:52:12 -07:00
parent 295d0564a2
commit 3302628db3
1 changed files with 11 additions and 12 deletions

View File

@ -69,7 +69,7 @@ type TestKubelet struct {
fakeMirrorClient *fakeMirrorClient fakeMirrorClient *fakeMirrorClient
} }
const testKubeletHostname = "testnode" const testKubeletHostname = "127.0.0.1"
func newTestKubelet(t *testing.T) *TestKubelet { func newTestKubelet(t *testing.T) *TestKubelet {
fakeDocker := &dockertools.FakeDockerClient{Errors: make(map[string]error), RemovedImages: util.StringSet{}} fakeDocker := &dockertools.FakeDockerClient{Errors: make(map[string]error), RemovedImages: util.StringSet{}}
@ -81,7 +81,7 @@ func newTestKubelet(t *testing.T) *TestKubelet {
kubelet.kubeClient = fakeKubeClient kubelet.kubeClient = fakeKubeClient
kubelet.os = kubecontainer.FakeOS{} kubelet.os = kubecontainer.FakeOS{}
kubelet.hostname = "testnode" kubelet.hostname = testKubeletHostname
kubelet.runtimeUpThreshold = maxWaitForContainerRuntime kubelet.runtimeUpThreshold = maxWaitForContainerRuntime
kubelet.networkPlugin, _ = network.InitNetworkPlugin([]network.NetworkPlugin{}, "", network.NewFakeHost(nil)) kubelet.networkPlugin, _ = network.InitNetworkPlugin([]network.NetworkPlugin{}, "", network.NewFakeHost(nil))
if tempDir, err := ioutil.TempDir("/tmp", "kubelet_test."); err != nil { if tempDir, err := ioutil.TempDir("/tmp", "kubelet_test."); err != nil {
@ -3026,7 +3026,7 @@ func TestHandleNodeSelector(t *testing.T) {
testKubelet := newTestKubelet(t) testKubelet := newTestKubelet(t)
kl := testKubelet.kubelet kl := testKubelet.kubelet
kl.nodeLister = testNodeLister{nodes: []api.Node{ kl.nodeLister = testNodeLister{nodes: []api.Node{
{ObjectMeta: api.ObjectMeta{Name: "testnode", Labels: map[string]string{"key": "B"}}}, {ObjectMeta: api.ObjectMeta{Name: testKubeletHostname, Labels: map[string]string{"key": "B"}}},
}} }}
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil) testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil) testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
@ -3241,7 +3241,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
kubelet := testKubelet.kubelet kubelet := testKubelet.kubelet
kubeClient := testKubelet.fakeKubeClient kubeClient := testKubelet.fakeKubeClient
kubeClient.ReactFn = testclient.NewSimpleFake(&api.NodeList{Items: []api.Node{ kubeClient.ReactFn = testclient.NewSimpleFake(&api.NodeList{Items: []api.Node{
{ObjectMeta: api.ObjectMeta{Name: "127.0.0.1"}}, {ObjectMeta: api.ObjectMeta{Name: testKubeletHostname}},
}}).ReactFn }}).ReactFn
machineInfo := &cadvisorApi.MachineInfo{ machineInfo := &cadvisorApi.MachineInfo{
MachineID: "123", MachineID: "123",
@ -3259,7 +3259,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
} }
mockCadvisor.On("VersionInfo").Return(versionInfo, nil) mockCadvisor.On("VersionInfo").Return(versionInfo, nil)
expectedNode := &api.Node{ expectedNode := &api.Node{
ObjectMeta: api.ObjectMeta{Name: "127.0.0.1"}, ObjectMeta: api.ObjectMeta{Name: testKubeletHostname},
Spec: api.NodeSpec{}, Spec: api.NodeSpec{},
Status: api.NodeStatus{ Status: api.NodeStatus{
Conditions: []api.NodeCondition{ Conditions: []api.NodeCondition{
@ -3320,7 +3320,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
kubeClient := testKubelet.fakeKubeClient kubeClient := testKubelet.fakeKubeClient
kubeClient.ReactFn = testclient.NewSimpleFake(&api.NodeList{Items: []api.Node{ kubeClient.ReactFn = testclient.NewSimpleFake(&api.NodeList{Items: []api.Node{
{ {
ObjectMeta: api.ObjectMeta{Name: "127.0.0.1"}, ObjectMeta: api.ObjectMeta{Name: testKubeletHostname},
Spec: api.NodeSpec{}, Spec: api.NodeSpec{},
Status: api.NodeStatus{ Status: api.NodeStatus{
Conditions: []api.NodeCondition{ Conditions: []api.NodeCondition{
@ -3356,7 +3356,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
} }
mockCadvisor.On("VersionInfo").Return(versionInfo, nil) mockCadvisor.On("VersionInfo").Return(versionInfo, nil)
expectedNode := &api.Node{ expectedNode := &api.Node{
ObjectMeta: api.ObjectMeta{Name: "127.0.0.1"}, ObjectMeta: api.ObjectMeta{Name: testKubeletHostname},
Spec: api.NodeSpec{}, Spec: api.NodeSpec{},
Status: api.NodeStatus{ Status: api.NodeStatus{
Conditions: []api.NodeCondition{ Conditions: []api.NodeCondition{
@ -3423,7 +3423,7 @@ func TestUpdateNodeStatusWithoutContainerRuntime(t *testing.T) {
fakeDocker.VersionInfo = []string{} fakeDocker.VersionInfo = []string{}
kubeClient.ReactFn = testclient.NewSimpleFake(&api.NodeList{Items: []api.Node{ kubeClient.ReactFn = testclient.NewSimpleFake(&api.NodeList{Items: []api.Node{
{ObjectMeta: api.ObjectMeta{Name: "127.0.0.1"}}, {ObjectMeta: api.ObjectMeta{Name: testKubeletHostname}},
}}).ReactFn }}).ReactFn
mockCadvisor := testKubelet.fakeCadvisor mockCadvisor := testKubelet.fakeCadvisor
machineInfo := &cadvisorApi.MachineInfo{ machineInfo := &cadvisorApi.MachineInfo{
@ -3442,7 +3442,7 @@ func TestUpdateNodeStatusWithoutContainerRuntime(t *testing.T) {
mockCadvisor.On("VersionInfo").Return(versionInfo, nil) mockCadvisor.On("VersionInfo").Return(versionInfo, nil)
expectedNode := &api.Node{ expectedNode := &api.Node{
ObjectMeta: api.ObjectMeta{Name: "127.0.0.1"}, ObjectMeta: api.ObjectMeta{Name: testKubeletHostname},
Spec: api.NodeSpec{}, Spec: api.NodeSpec{},
Status: api.NodeStatus{ Status: api.NodeStatus{
Conditions: []api.NodeCondition{ Conditions: []api.NodeCondition{
@ -4410,7 +4410,6 @@ func TestFilterOutTerminatedPods(t *testing.T) {
func TestRegisterExistingNodeWithApiserver(t *testing.T) { func TestRegisterExistingNodeWithApiserver(t *testing.T) {
testKubelet := newTestKubelet(t) testKubelet := newTestKubelet(t)
kubelet := testKubelet.kubelet kubelet := testKubelet.kubelet
kubelet.hostname = "127.0.0.1"
kubeClient := testKubelet.fakeKubeClient kubeClient := testKubelet.fakeKubeClient
kubeClient.ReactFn = func(action testclient.FakeAction) (runtime.Object, error) { kubeClient.ReactFn = func(action testclient.FakeAction) (runtime.Object, error) {
segments := strings.Split(action.Action, "-") segments := strings.Split(action.Action, "-")
@ -4427,8 +4426,8 @@ func TestRegisterExistingNodeWithApiserver(t *testing.T) {
case "get": case "get":
// Return an existing (matching) node on get. // Return an existing (matching) node on get.
return &api.Node{ return &api.Node{
ObjectMeta: api.ObjectMeta{Name: "127.0.0.1"}, ObjectMeta: api.ObjectMeta{Name: testKubeletHostname},
Spec: api.NodeSpec{ExternalID: "127.0.0.1"}, Spec: api.NodeSpec{ExternalID: testKubeletHostname},
}, nil }, nil
default: default:
return nil, fmt.Errorf("no reaction implemented for %s", action.Action) return nil, fmt.Errorf("no reaction implemented for %s", action.Action)