mirror of https://github.com/k3s-io/k3s
Make the test TestCRIListPodStats pass for Darwin and Windows
GetPodCgroupNameSuffix is only implemented for Linux, which mean that CPU and Memory stats are only available on Linux. My fix to make the test pass on other OS:es than Linux is to just check CPU and Memory stats on Linux. (This is similar to #57637 which fixed the same problem for the test TestCadvisorListPodStats.)pull/8/head
parent
80bd7510df
commit
c47583099c
|
@ -38,6 +38,7 @@ import (
|
|||
kubepodtest "k8s.io/kubernetes/pkg/kubelet/pod/testing"
|
||||
serverstats "k8s.io/kubernetes/pkg/kubelet/server/stats"
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -206,7 +207,9 @@ func TestCRIListPodStats(t *testing.T) {
|
|||
checkCRIRootfsStats(assert, c1, containerStats1, nil)
|
||||
checkCRILogsStats(assert, c1, &rootFsInfo, containerLogStats1)
|
||||
checkCRINetworkStats(assert, p0.Network, infos[sandbox0.PodSandboxStatus.Id].Stats[0].Network)
|
||||
checkCRIPodCPUAndMemoryStats(assert, p0, infos[sandbox0Cgroup].Stats[0])
|
||||
if runtime.GOOS == "linux" {
|
||||
checkCRIPodCPUAndMemoryStats(assert, p0, infos[sandbox0Cgroup].Stats[0])
|
||||
}
|
||||
|
||||
p1 := podStatsMap[statsapi.PodReference{Name: "sandbox1-name", UID: "sandbox1-uid", Namespace: "sandbox1-ns"}]
|
||||
assert.Equal(sandbox1.CreatedAt, p1.StartTime.UnixNano())
|
||||
|
@ -220,7 +223,9 @@ func TestCRIListPodStats(t *testing.T) {
|
|||
checkCRIRootfsStats(assert, c2, containerStats2, &imageFsInfo)
|
||||
checkCRILogsStats(assert, c2, &rootFsInfo, containerLogStats2)
|
||||
checkCRINetworkStats(assert, p1.Network, infos[sandbox1.PodSandboxStatus.Id].Stats[0].Network)
|
||||
checkCRIPodCPUAndMemoryStats(assert, p1, infos[sandbox1Cgroup].Stats[0])
|
||||
if runtime.GOOS == "linux" {
|
||||
checkCRIPodCPUAndMemoryStats(assert, p1, infos[sandbox1Cgroup].Stats[0])
|
||||
}
|
||||
|
||||
p2 := podStatsMap[statsapi.PodReference{Name: "sandbox2-name", UID: "sandbox2-uid", Namespace: "sandbox2-ns"}]
|
||||
assert.Equal(sandbox2.CreatedAt, p2.StartTime.UnixNano())
|
||||
|
@ -236,7 +241,9 @@ func TestCRIListPodStats(t *testing.T) {
|
|||
|
||||
checkCRILogsStats(assert, c3, &rootFsInfo, containerLogStats4)
|
||||
checkCRINetworkStats(assert, p2.Network, infos[sandbox2.PodSandboxStatus.Id].Stats[0].Network)
|
||||
checkCRIPodCPUAndMemoryStats(assert, p2, infos[sandbox2Cgroup].Stats[0])
|
||||
if runtime.GOOS == "linux" {
|
||||
checkCRIPodCPUAndMemoryStats(assert, p2, infos[sandbox2Cgroup].Stats[0])
|
||||
}
|
||||
|
||||
mockCadvisor.AssertExpectations(t)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue