From cb4b67a8866c109f34666c8b4cf949bc263c5586 Mon Sep 17 00:00:00 2001 From: Morgan Bauer Date: Tue, 9 Jun 2020 23:27:13 -0700 Subject: [PATCH] basic regression test of runDockershim - added basic regression test to ensure an error is raised in the case of an unconfigured runtime, and the case of asking for a docker runtime when compiled dockerless Signed-off-by: Morgan Bauer --- pkg/kubelet/kubelet_dockerless_test.go | 33 ++++++++++++++++++++++++++ pkg/kubelet/kubelet_test.go | 7 ++++++ 2 files changed, 40 insertions(+) create mode 100644 pkg/kubelet/kubelet_dockerless_test.go diff --git a/pkg/kubelet/kubelet_dockerless_test.go b/pkg/kubelet/kubelet_dockerless_test.go new file mode 100644 index 00000000000..d96bb2504a0 --- /dev/null +++ b/pkg/kubelet/kubelet_dockerless_test.go @@ -0,0 +1,33 @@ +// +build dockerless + +/* +Copyright 2020 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package kubelet_test + +import ( + "testing" + + "k8s.io/kubernetes/pkg/kubelet" + kubetypes "k8s.io/kubernetes/pkg/kubelet/types" +) + +func TestPreInitRuntimeService(t *testing.T) { + err := kubelet.PreInitRuntimeService(nil, nil, nil, kubetypes.DockerContainerRuntime, "", "", "", "") + if err == nil { + t.Fatal("PreInitRuntimeService should fail when configured to use docker and compiled dockerless") + } +} diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index b22a286c6a9..874763ea347 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -1953,6 +1953,13 @@ func TestSyncPodKillPod(t *testing.T) { checkPodStatus(t, kl, pod, v1.PodFailed) } +func TestPreInitRuntimeService(t *testing.T) { + err := PreInitRuntimeService(nil, nil, nil, "", "", "", "", "") + if err == nil { + t.Fatal("PreInitRuntimeService should fail when not configured with a container runtime") + } +} + func waitForVolumeUnmount( volumeManager kubeletvolume.VolumeManager, pod *v1.Pod) error {