mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 10:18:13 +00:00 
			
		
		
		
	cleanup all /tmp/kubelet_test files
Signed-off-by: Jess Frazelle <acidburn@google.com>
This commit is contained in:
		| @@ -36,6 +36,7 @@ func TestGetContainerInfo(t *testing.T) { | ||||
| 	} | ||||
|  | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	fakeRuntime := testKubelet.fakeRuntime | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	cadvisorReq := &cadvisorapi.ContainerInfoRequest{} | ||||
| @@ -72,6 +73,7 @@ func TestGetRawContainerInfoRoot(t *testing.T) { | ||||
| 		}, | ||||
| 	} | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	mockCadvisor := testKubelet.fakeCadvisor | ||||
| 	cadvisorReq := &cadvisorapi.ContainerInfoRequest{} | ||||
| @@ -99,6 +101,7 @@ func TestGetRawContainerInfoSubcontainers(t *testing.T) { | ||||
| 		}, | ||||
| 	} | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	mockCadvisor := testKubelet.fakeCadvisor | ||||
| 	cadvisorReq := &cadvisorapi.ContainerInfoRequest{} | ||||
| @@ -117,6 +120,7 @@ func TestGetRawContainerInfoSubcontainers(t *testing.T) { | ||||
| func TestGetContainerInfoWhenCadvisorFailed(t *testing.T) { | ||||
| 	containerID := "ab2cdf" | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	mockCadvisor := testKubelet.fakeCadvisor | ||||
| 	fakeRuntime := testKubelet.fakeRuntime | ||||
| @@ -152,6 +156,7 @@ func TestGetContainerInfoWhenCadvisorFailed(t *testing.T) { | ||||
|  | ||||
| func TestGetContainerInfoOnNonExistContainer(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	mockCadvisor := testKubelet.fakeCadvisor | ||||
| 	fakeRuntime := testKubelet.fakeRuntime | ||||
| @@ -166,6 +171,7 @@ func TestGetContainerInfoOnNonExistContainer(t *testing.T) { | ||||
|  | ||||
| func TestGetContainerInfoWhenContainerRuntimeFailed(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	mockCadvisor := testKubelet.fakeCadvisor | ||||
| 	fakeRuntime := testKubelet.fakeRuntime | ||||
| @@ -187,6 +193,7 @@ func TestGetContainerInfoWhenContainerRuntimeFailed(t *testing.T) { | ||||
|  | ||||
| func TestGetContainerInfoWithNoContainers(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	mockCadvisor := testKubelet.fakeCadvisor | ||||
|  | ||||
| @@ -205,6 +212,7 @@ func TestGetContainerInfoWithNoContainers(t *testing.T) { | ||||
|  | ||||
| func TestGetContainerInfoWithNoMatchingContainers(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	fakeRuntime := testKubelet.fakeRuntime | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	mockCadvisor := testKubelet.fakeCadvisor | ||||
| @@ -253,6 +261,7 @@ func TestHasDedicatedImageFs(t *testing.T) { | ||||
| 	} | ||||
| 	for testName, testCase := range testCases { | ||||
| 		testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 		defer testKubelet.Cleanup() | ||||
| 		kubelet := testKubelet.kubelet | ||||
| 		mockCadvisor := testKubelet.fakeCadvisor | ||||
| 		mockCadvisor.On("Start").Return(nil) | ||||
|   | ||||
| @@ -25,6 +25,7 @@ import ( | ||||
|  | ||||
| func TestKubeletDirs(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	root := kubelet.rootDirectory | ||||
|  | ||||
| @@ -87,6 +88,7 @@ func TestKubeletDirs(t *testing.T) { | ||||
|  | ||||
| func TestKubeletDirsCompat(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	root := kubelet.rootDirectory | ||||
| 	if err := os.MkdirAll(root, 0750); err != nil { | ||||
|   | ||||
| @@ -28,6 +28,7 @@ import ( | ||||
|  | ||||
| func TestNodeIPParam(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	tests := []struct { | ||||
| 		nodeIP   string | ||||
| @@ -96,6 +97,7 @@ func TestParseResolvConf(t *testing.T) { | ||||
| 		{"#comment\nnameserver 1.2.3.4\n#comment\nsearch foo\ncomment", []string{"1.2.3.4"}, []string{"foo"}}, | ||||
| 	} | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	for i, tc := range testCases { | ||||
| 		ns, srch, err := kubelet.parseResolvConf(strings.NewReader(tc.data)) | ||||
| @@ -178,6 +180,7 @@ func TestCleanupBandwidthLimits(t *testing.T) { | ||||
| 		} | ||||
|  | ||||
| 		testKube := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 		defer testKube.Cleanup() | ||||
| 		testKube.kubelet.shaper = shaper | ||||
|  | ||||
| 		for _, pod := range test.pods { | ||||
|   | ||||
| @@ -114,6 +114,7 @@ func TestUpdateNewNodeStatus(t *testing.T) { | ||||
| 	inputImageList, expectedImageList := generateTestingImageList(maxImagesInNodeStatus + 1) | ||||
| 	testKubelet := newTestKubeletWithImageList( | ||||
| 		t, inputImageList, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	kubeClient := testKubelet.fakeKubeClient | ||||
| 	existingNode := v1.Node{ObjectMeta: v1.ObjectMeta{Name: testKubeletHostname}} | ||||
| @@ -253,6 +254,7 @@ func TestUpdateNewNodeStatus(t *testing.T) { | ||||
|  | ||||
| func TestUpdateNewNodeOutOfDiskStatusWithTransitionFrequency(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	kubeClient := testKubelet.fakeKubeClient | ||||
| 	existingNode := v1.Node{ObjectMeta: v1.ObjectMeta{Name: testKubeletHostname}} | ||||
| @@ -328,6 +330,7 @@ func TestUpdateNewNodeOutOfDiskStatusWithTransitionFrequency(t *testing.T) { | ||||
|  | ||||
| func TestUpdateExistingNodeStatus(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	kubeClient := testKubelet.fakeKubeClient | ||||
| 	existingNode := v1.Node{ | ||||
| @@ -523,6 +526,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) { | ||||
|  | ||||
| func TestUpdateExistingNodeOutOfDiskStatusWithTransitionFrequency(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	clock := testKubelet.fakeClock | ||||
| 	// Do not set nano second, because apiserver function doesn't support nano second. (Only support | ||||
| @@ -681,6 +685,7 @@ func TestUpdateExistingNodeOutOfDiskStatusWithTransitionFrequency(t *testing.T) | ||||
|  | ||||
| func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	clock := testKubelet.fakeClock | ||||
| 	kubeClient := testKubelet.fakeKubeClient | ||||
| @@ -900,6 +905,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) { | ||||
|  | ||||
| func TestUpdateNodeStatusError(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	// No matching node for the kubelet | ||||
| 	testKubelet.fakeKubeClient.ReactionChain = fake.NewSimpleClientset(&v1.NodeList{Items: []v1.Node{}}).ReactionChain | ||||
| @@ -914,6 +920,7 @@ func TestUpdateNodeStatusError(t *testing.T) { | ||||
|  | ||||
| func TestRegisterWithApiServer(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	kubeClient := testKubelet.fakeKubeClient | ||||
| 	kubeClient.AddReactor("create", "nodes", func(action core.Action) (bool, runtime.Object, error) { | ||||
| @@ -1094,6 +1101,7 @@ func TestTryRegisterWithApiServer(t *testing.T) { | ||||
|  | ||||
| 	for _, tc := range cases { | ||||
| 		testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled is a don't-care for this test */) | ||||
| 		defer testKubelet.Cleanup() | ||||
| 		kubelet := testKubelet.kubelet | ||||
| 		kubeClient := testKubelet.fakeKubeClient | ||||
|  | ||||
|   | ||||
| @@ -113,6 +113,7 @@ func TestMakeMounts(t *testing.T) { | ||||
|  | ||||
| func TestRunInContainerNoSuchPod(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	fakeRuntime := testKubelet.fakeRuntime | ||||
| 	fakeRuntime.PodList = []*containertest.FakePod{} | ||||
| @@ -132,6 +133,7 @@ func TestRunInContainerNoSuchPod(t *testing.T) { | ||||
| func TestRunInContainer(t *testing.T) { | ||||
| 	for _, testError := range []error{nil, errors.New("bar")} { | ||||
| 		testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 		defer testKubelet.Cleanup() | ||||
| 		kubelet := testKubelet.kubelet | ||||
| 		fakeRuntime := testKubelet.fakeRuntime | ||||
| 		fakeCommandRunner := containertest.FakeContainerCommandRunner{ | ||||
| @@ -165,6 +167,7 @@ func TestRunInContainer(t *testing.T) { | ||||
|  | ||||
| func TestGenerateRunContainerOptions_DNSConfigurationParams(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
|  | ||||
| 	clusterNS := "203.0.113.1" | ||||
| @@ -737,6 +740,7 @@ func TestMakeEnvironmentVariables(t *testing.T) { | ||||
|  | ||||
| 	for _, tc := range testCases { | ||||
| 		testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 		defer testKubelet.Cleanup() | ||||
| 		kl := testKubelet.kubelet | ||||
| 		kl.masterServiceNamespace = tc.masterServiceNs | ||||
| 		if tc.nilLister { | ||||
| @@ -1202,6 +1206,7 @@ func TestExec(t *testing.T) { | ||||
|  | ||||
| 	for _, tc := range testcases { | ||||
| 		testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 		defer testKubelet.Cleanup() | ||||
| 		kubelet := testKubelet.kubelet | ||||
| 		testKubelet.fakeRuntime.PodList = []*containertest.FakePod{ | ||||
| 			{Pod: &kubecontainer.Pod{ | ||||
| @@ -1292,6 +1297,7 @@ func TestPortForward(t *testing.T) { | ||||
|  | ||||
| 	for _, tc := range testcases { | ||||
| 		testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 		defer testKubelet.Cleanup() | ||||
| 		kubelet := testKubelet.kubelet | ||||
| 		testKubelet.fakeRuntime.PodList = []*containertest.FakePod{ | ||||
| 			{Pod: &kubecontainer.Pod{ | ||||
| @@ -1439,6 +1445,7 @@ func TestHasHostMountPVC(t *testing.T) { | ||||
|  | ||||
| 	for k, v := range tests { | ||||
| 		testKubelet := newTestKubelet(t, false) | ||||
| 		defer testKubelet.Cleanup() | ||||
| 		pod := &v1.Pod{ | ||||
| 			Spec: v1.PodSpec{}, | ||||
| 		} | ||||
|   | ||||
| @@ -33,6 +33,7 @@ func TestPodResourceLimitsDefaulting(t *testing.T) { | ||||
| 	cpuCores := resource.MustParse("10") | ||||
| 	memoryCapacity := resource.MustParse("10Gi") | ||||
| 	tk := newTestKubelet(t, true) | ||||
| 	defer tk.Cleanup() | ||||
| 	tk.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	tk.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{ | ||||
| 		NumCores:       int(cpuCores.Value()), | ||||
|   | ||||
| @@ -106,6 +106,12 @@ type TestKubelet struct { | ||||
| 	volumePlugin     *volumetest.FakeVolumePlugin | ||||
| } | ||||
|  | ||||
| func (tk *TestKubelet) Cleanup() { | ||||
| 	if tk.kubelet != nil { | ||||
| 		os.RemoveAll(tk.kubelet.rootDirectory) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // newTestKubelet returns test kubelet with two images. | ||||
| func newTestKubelet(t *testing.T, controllerAttachDetachEnabled bool) *TestKubelet { | ||||
| 	imageList := []kubecontainer.Image{ | ||||
| @@ -289,6 +295,7 @@ var emptyPodUIDs map[types.UID]kubetypes.SyncPodType | ||||
|  | ||||
| func TestSyncLoopTimeUpdate(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	kubelet := testKubelet.kubelet | ||||
|  | ||||
| @@ -314,6 +321,7 @@ func TestSyncLoopTimeUpdate(t *testing.T) { | ||||
|  | ||||
| func TestSyncLoopAbort(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	kubelet.runtimeState.setRuntimeSync(time.Now()) | ||||
| @@ -334,6 +342,7 @@ func TestSyncLoopAbort(t *testing.T) { | ||||
|  | ||||
| func TestSyncPodsStartPod(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("ImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| @@ -356,6 +365,7 @@ func TestSyncPodsDeletesWhenSourcesAreReady(t *testing.T) { | ||||
| 	ready := false | ||||
|  | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	fakeRuntime := testKubelet.fakeRuntime | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("ImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| @@ -410,6 +420,7 @@ func (ls testNodeLister) List() (v1.NodeList, error) { | ||||
| // Tests that we handle port conflicts correctly by setting the failed status in status map. | ||||
| func TestHandlePortConflicts(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kl := testKubelet.kubelet | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("ImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| @@ -526,6 +537,7 @@ func TestCriticalPrioritySorting(t *testing.T) { | ||||
| // Tests that we handle host name conflicts correctly by setting the failed status in status map. | ||||
| func TestHandleHostNameConflicts(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kl := testKubelet.kubelet | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("ImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| @@ -577,6 +589,7 @@ func TestHandleHostNameConflicts(t *testing.T) { | ||||
| // Tests that we handle not matching labels selector correctly by setting the failed status in status map. | ||||
| func TestHandleNodeSelector(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kl := testKubelet.kubelet | ||||
| 	nodes := []v1.Node{ | ||||
| 		{ | ||||
| @@ -617,6 +630,7 @@ func TestHandleNodeSelector(t *testing.T) { | ||||
| // Tests that we handle exceeded resources correctly by setting the failed status in status map. | ||||
| func TestHandleMemExceeded(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kl := testKubelet.kubelet | ||||
| 	nodes := []v1.Node{ | ||||
| 		{ObjectMeta: v1.ObjectMeta{Name: testKubeletHostname}, | ||||
| @@ -665,6 +679,7 @@ func TestHandleMemExceeded(t *testing.T) { | ||||
| // TODO(filipg): This test should be removed once StatusSyncer can do garbage collection without external signal. | ||||
| func TestPurgingObsoleteStatusMapEntries(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("ImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| @@ -696,6 +711,7 @@ func TestPurgingObsoleteStatusMapEntries(t *testing.T) { | ||||
|  | ||||
| func TestValidateContainerLogStatus(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	containerName := "x" | ||||
| 	testCases := []struct { | ||||
| @@ -822,6 +838,7 @@ func updateDiskSpacePolicy(kubelet *Kubelet, mockCadvisor *cadvisortest.Mock, ro | ||||
| func TestCreateMirrorPod(t *testing.T) { | ||||
| 	for _, updateType := range []kubetypes.SyncPodType{kubetypes.SyncPodCreate, kubetypes.SyncPodUpdate} { | ||||
| 		testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 		defer testKubelet.Cleanup() | ||||
| 		testKubelet.fakeCadvisor.On("Start").Return(nil) | ||||
| 		testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 		testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| @@ -848,6 +865,7 @@ func TestCreateMirrorPod(t *testing.T) { | ||||
|  | ||||
| func TestDeleteOutdatedMirrorPod(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("Start").Return(nil) | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| @@ -890,6 +908,7 @@ func TestDeleteOutdatedMirrorPod(t *testing.T) { | ||||
|  | ||||
| func TestDeleteOrphanedMirrorPods(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("Start").Return(nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("ImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| @@ -981,6 +1000,7 @@ func TestGetContainerInfoForMirrorPods(t *testing.T) { | ||||
| 	} | ||||
|  | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	fakeRuntime := testKubelet.fakeRuntime | ||||
| 	mockCadvisor := testKubelet.fakeCadvisor | ||||
| 	cadvisorReq := &cadvisorapi.ContainerInfoRequest{} | ||||
| @@ -1011,6 +1031,7 @@ func TestGetContainerInfoForMirrorPods(t *testing.T) { | ||||
|  | ||||
| func TestHostNetworkAllowed(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("Start").Return(nil) | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| @@ -1043,6 +1064,7 @@ func TestHostNetworkAllowed(t *testing.T) { | ||||
|  | ||||
| func TestHostNetworkDisallowed(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("Start").Return(nil) | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| @@ -1074,6 +1096,7 @@ func TestHostNetworkDisallowed(t *testing.T) { | ||||
|  | ||||
| func TestPrivilegeContainerAllowed(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("Start").Return(nil) | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| @@ -1103,6 +1126,7 @@ func TestPrivilegeContainerAllowed(t *testing.T) { | ||||
|  | ||||
| func TestPrivilegedContainerDisallowed(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("ImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| @@ -1129,6 +1153,7 @@ func TestPrivilegedContainerDisallowed(t *testing.T) { | ||||
|  | ||||
| func TestNetworkErrorsWithoutHostNetwork(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("ImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| @@ -1170,6 +1195,7 @@ func TestNetworkErrorsWithoutHostNetwork(t *testing.T) { | ||||
|  | ||||
| func TestFilterOutTerminatedPods(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	pods := newTestPods(5) | ||||
| 	pods[0].Status.Phase = v1.PodFailed | ||||
| @@ -1236,6 +1262,7 @@ func TestMakePortMappings(t *testing.T) { | ||||
|  | ||||
| func TestSyncPodsSetStatusToFailedForPodsThatRunTooLong(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	fakeRuntime := testKubelet.fakeRuntime | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	kubelet := testKubelet.kubelet | ||||
| @@ -1283,6 +1310,7 @@ func TestSyncPodsSetStatusToFailedForPodsThatRunTooLong(t *testing.T) { | ||||
|  | ||||
| func TestSyncPodsDoesNotSetPodsThatDidNotRunTooLongToFailed(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	fakeRuntime := testKubelet.fakeRuntime | ||||
| 	testKubelet.fakeCadvisor.On("Start").Return(nil) | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| @@ -1352,6 +1380,7 @@ func podWithUidNameNsSpec(uid types.UID, name, namespace string, spec v1.PodSpec | ||||
|  | ||||
| func TestDeletePodDirsForDeletedPods(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("Start").Return(nil) | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| @@ -1391,6 +1420,7 @@ func syncAndVerifyPodDir(t *testing.T, testKubelet *TestKubelet, pods []*v1.Pod, | ||||
|  | ||||
| func TestDoesNotDeletePodDirsForTerminatedPods(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("Start").Return(nil) | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| @@ -1413,6 +1443,7 @@ func TestDoesNotDeletePodDirsForTerminatedPods(t *testing.T) { | ||||
|  | ||||
| func TestDoesNotDeletePodDirsIfContainerIsRunning(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("Start").Return(nil) | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| @@ -1445,6 +1476,7 @@ func TestDoesNotDeletePodDirsIfContainerIsRunning(t *testing.T) { | ||||
|  | ||||
| func TestGetPodsToSync(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	clock := testKubelet.fakeClock | ||||
| 	pods := newTestPods(5) | ||||
| @@ -1475,6 +1507,7 @@ func TestGetPodsToSync(t *testing.T) { | ||||
|  | ||||
| func TestGenerateAPIPodStatusWithSortedContainers(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("ImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| @@ -1537,6 +1570,7 @@ func TestGenerateAPIPodStatusWithReasonCache(t *testing.T) { | ||||
| 	testErrorReason := fmt.Errorf("test-error") | ||||
| 	emptyContainerID := (&kubecontainer.ContainerID{}).String() | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("ImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| @@ -1726,6 +1760,7 @@ func TestGenerateAPIPodStatusWithDifferentRestartPolicies(t *testing.T) { | ||||
| 	testErrorReason := fmt.Errorf("test-error") | ||||
| 	emptyContainerID := (&kubecontainer.ContainerID{}).String() | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	testKubelet.fakeCadvisor.On("VersionInfo").Return(&cadvisorapi.VersionInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil) | ||||
| 	testKubelet.fakeCadvisor.On("ImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil) | ||||
| @@ -1892,6 +1927,7 @@ func (a *testPodAdmitHandler) Admit(attrs *lifecycle.PodAdmitAttributes) lifecyc | ||||
| // Test verifies that the kubelet invokes an admission handler during HandlePodAdditions. | ||||
| func TestHandlePodAdditionsInvokesPodAdmitHandlers(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kl := testKubelet.kubelet | ||||
| 	kl.nodeLister = testNodeLister{nodes: []v1.Node{ | ||||
| 		{ | ||||
| @@ -1971,6 +2007,7 @@ func (a *testPodSyncLoopHandler) ShouldSync(pod *v1.Pod) bool { | ||||
| // TestGetPodsToSyncInvokesPodSyncLoopHandlers ensures that the get pods to sync routine invokes the handler. | ||||
| func TestGetPodsToSyncInvokesPodSyncLoopHandlers(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	pods := newTestPods(5) | ||||
| 	expected := []*v1.Pod{pods[0]} | ||||
| @@ -2006,6 +2043,7 @@ func (a *testPodSyncHandler) ShouldEvict(pod *v1.Pod) lifecycle.ShouldEvictRespo | ||||
| // TestGenerateAPIPodStatusInvokesPodSyncHandlers invokes the handlers and reports the proper status | ||||
| func TestGenerateAPIPodStatusInvokesPodSyncHandlers(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	pod := newTestPods(1)[0] | ||||
| 	podsToEvict := []*v1.Pod{pod} | ||||
| @@ -2023,6 +2061,7 @@ func TestGenerateAPIPodStatusInvokesPodSyncHandlers(t *testing.T) { | ||||
|  | ||||
| func TestSyncPodKillPod(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kl := testKubelet.kubelet | ||||
| 	pod := &v1.Pod{ | ||||
| 		ObjectMeta: v1.ObjectMeta{ | ||||
|   | ||||
| @@ -85,6 +85,7 @@ func TestListVolumesForPod(t *testing.T) { | ||||
|  | ||||
| func TestPodVolumesExist(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
|  | ||||
| 	pods := []*v1.Pod{ | ||||
| @@ -169,6 +170,7 @@ func TestPodVolumesExist(t *testing.T) { | ||||
|  | ||||
| func TestVolumeAttachAndMountControllerDisabled(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
|  | ||||
| 	pod := podWithUidNameNsSpec("12345678", "foo", "test", v1.PodSpec{ | ||||
| @@ -214,6 +216,7 @@ func TestVolumeAttachAndMountControllerDisabled(t *testing.T) { | ||||
|  | ||||
| func TestVolumeUnmountAndDetachControllerDisabled(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
|  | ||||
| 	pod := podWithUidNameNsSpec("12345678", "foo", "test", v1.PodSpec{ | ||||
| @@ -284,6 +287,7 @@ func TestVolumeUnmountAndDetachControllerDisabled(t *testing.T) { | ||||
|  | ||||
| func TestVolumeAttachAndMountControllerEnabled(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, true /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	kubeClient := testKubelet.fakeKubeClient | ||||
| 	kubeClient.AddReactor("get", "nodes", | ||||
| @@ -352,6 +356,7 @@ func TestVolumeAttachAndMountControllerEnabled(t *testing.T) { | ||||
|  | ||||
| func TestVolumeUnmountAndDetachControllerEnabled(t *testing.T) { | ||||
| 	testKubelet := newTestKubelet(t, true /* controllerAttachDetachEnabled */) | ||||
| 	defer testKubelet.Cleanup() | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	kubeClient := testKubelet.fakeKubeClient | ||||
| 	kubeClient.AddReactor("get", "nodes", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jess Frazelle
					Jess Frazelle