From 6a9070a59d64fe54bca9ff0bdb8a6f7188b02fe0 Mon Sep 17 00:00:00 2001 From: chenguoyan01 Date: Tue, 17 Oct 2017 18:33:02 +0800 Subject: [PATCH] add TestStatus to instrumented_services_test Change-Id: Ib2fafd714ed0a48a4dbb3b9fb406e516d5587ae4 --- .../kuberuntime/instrumented_services_test.go | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/pkg/kubelet/kuberuntime/instrumented_services_test.go b/pkg/kubelet/kuberuntime/instrumented_services_test.go index edd1c9b0d3..933fc29959 100644 --- a/pkg/kubelet/kuberuntime/instrumented_services_test.go +++ b/pkg/kubelet/kuberuntime/instrumented_services_test.go @@ -17,13 +17,15 @@ limitations under the License. package kuberuntime import ( - "github.com/prometheus/client_golang/prometheus" - "github.com/stretchr/testify/assert" - "k8s.io/kubernetes/pkg/kubelet/metrics" "net" "net/http" "testing" "time" + + "github.com/prometheus/client_golang/prometheus" + "github.com/stretchr/testify/assert" + runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime" + "k8s.io/kubernetes/pkg/kubelet/metrics" ) func TestRecordOperation(t *testing.T) { @@ -67,3 +69,23 @@ func TestInstrumentedVersion(t *testing.T) { assert.NoError(t, err) assert.Equal(t, kubeRuntimeAPIVersion, vr.Version) } + +func TestStatus(t *testing.T) { + fakeRuntime, _, _, _ := createTestRuntimeManager() + fakeRuntime.FakeStatus = &runtimeapi.RuntimeStatus{ + Conditions: []*runtimeapi.RuntimeCondition{ + {Type: runtimeapi.RuntimeReady, Status: false}, + {Type: runtimeapi.NetworkReady, Status: true}, + }, + } + irs := newInstrumentedRuntimeService(fakeRuntime) + actural, err := irs.Status() + assert.NoError(t, err) + expected := &runtimeapi.RuntimeStatus{ + Conditions: []*runtimeapi.RuntimeCondition{ + {Type: runtimeapi.RuntimeReady, Status: false}, + {Type: runtimeapi.NetworkReady, Status: true}, + }, + } + assert.Equal(t, expected, actural) +}