Merge pull request #53696 from drinktee/kuberuntimeunitest

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Increases test coverage for kubelet/kuberuntime

What this PR does / why we need it:
Increases test coverage for kubelet/kuberuntime
#46123

Which issue this PR fixes:
#46123

/assign @feiskyer
pull/6/head
Kubernetes Submit Queue 2017-10-18 00:43:08 -07:00 committed by GitHub
commit a3a659b8ca
1 changed files with 33 additions and 3 deletions

View File

@ -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) {
@ -59,3 +61,31 @@ func TestRecordOperation(t *testing.T) {
mux.ServeHTTP(w, r)
}), "GET", prometheusUrl, nil, runtimeOperationsLatencyExpected)
}
func TestInstrumentedVersion(t *testing.T) {
fakeRuntime, _, _, _ := createTestRuntimeManager()
irs := newInstrumentedRuntimeService(fakeRuntime)
vr, err := irs.Version("1")
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)
}