mirror of https://github.com/k3s-io/k3s
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 @feiskyerpull/6/head
commit
a3a659b8ca
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue