Merge pull request #62192 from patrikerdes/TestCRIListPodStats

Automatic merge from submit-queue (batch tested with PRs 62192, 61866, 62206, 62360). 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>.

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.)



**What this PR does / why we need it**:
To make all unit tests pass on macOS/Darwin

**Which issue(s) this PR fixes**:
Fixes #62177

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
pull/8/head
Kubernetes Submit Queue 2018-04-10 23:52:14 -07:00 committed by GitHub
commit 18e36c4f88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -18,6 +18,7 @@ package stats
import (
"math/rand"
"runtime"
"testing"
"time"
@ -464,6 +465,9 @@ func checkCRINetworkStats(assert *assert.Assertions, actual *statsapi.NetworkSta
}
func checkCRIPodCPUAndMemoryStats(assert *assert.Assertions, actual statsapi.PodStats, cs *cadvisorapiv2.ContainerStats) {
if runtime.GOOS != "linux" {
return
}
assert.Equal(cs.Timestamp.UnixNano(), actual.CPU.Time.UnixNano())
assert.Equal(cs.Cpu.Usage.Total, *actual.CPU.UsageCoreNanoSeconds)
assert.Equal(cs.CpuInst.Usage.Total, *actual.CPU.UsageNanoCores)