mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 04:27:54 +00:00
Adjust summary API e2e test
Signed-off-by: Itamar Holder <iholder@redhat.com>
This commit is contained in:
parent
e429793db1
commit
4cb5547f93
@ -112,6 +112,7 @@ var _ = SIGDescribe("Summary API [NodeConformance]", func() {
|
||||
"PageFaults": bounded(1000, 1e9),
|
||||
"MajorPageFaults": bounded(0, 100000),
|
||||
}),
|
||||
"Swap": swapExpectation(memoryLimit),
|
||||
"Accelerators": gomega.BeEmpty(),
|
||||
"Rootfs": gomega.BeNil(),
|
||||
"Logs": gomega.BeNil(),
|
||||
@ -183,6 +184,7 @@ var _ = SIGDescribe("Summary API [NodeConformance]", func() {
|
||||
"PageFaults": bounded(100, expectedPageFaultsUpperBound),
|
||||
"MajorPageFaults": bounded(0, expectedMajorPageFaultsUpperBound),
|
||||
}),
|
||||
"Swap": swapExpectation(memoryLimit),
|
||||
"Accelerators": gomega.BeEmpty(),
|
||||
"Rootfs": ptrMatchAllFields(gstruct.Fields{
|
||||
"Time": recent(maxStatsAge),
|
||||
@ -230,6 +232,7 @@ var _ = SIGDescribe("Summary API [NodeConformance]", func() {
|
||||
"PageFaults": bounded(0, expectedPageFaultsUpperBound),
|
||||
"MajorPageFaults": bounded(0, expectedMajorPageFaultsUpperBound),
|
||||
}),
|
||||
"Swap": swapExpectation(memoryLimit),
|
||||
"VolumeStats": gstruct.MatchAllElements(summaryObjectID, gstruct.Elements{
|
||||
"test-empty-dir": gstruct.MatchAllFields(gstruct.Fields{
|
||||
"Name": gomega.Equal("test-empty-dir"),
|
||||
@ -280,6 +283,7 @@ var _ = SIGDescribe("Summary API [NodeConformance]", func() {
|
||||
"PageFaults": bounded(1000, 1e9),
|
||||
"MajorPageFaults": bounded(0, 100000),
|
||||
}),
|
||||
"Swap": swapExpectation(memoryLimit),
|
||||
// TODO(#28407): Handle non-eth0 network interface names.
|
||||
"Network": ptrMatchAllFields(gstruct.Fields{
|
||||
"Time": recent(maxStatsAge),
|
||||
@ -410,6 +414,27 @@ func bounded(lower, upper interface{}) types.GomegaMatcher {
|
||||
gomega.BeNumerically("<=", upper)))
|
||||
}
|
||||
|
||||
func swapExpectation(upper interface{}) types.GomegaMatcher {
|
||||
// Size after which we consider memory to be "unlimited". This is not
|
||||
// MaxInt64 due to rounding by the kernel.
|
||||
const maxMemorySize = uint64(1 << 62)
|
||||
|
||||
swapBytesMatcher := gomega.Or(
|
||||
gomega.BeNil(),
|
||||
bounded(0, upper),
|
||||
gstruct.PointTo(gomega.BeNumerically(">=", maxMemorySize)),
|
||||
)
|
||||
|
||||
return gomega.Or(
|
||||
gomega.BeNil(),
|
||||
ptrMatchAllFields(gstruct.Fields{
|
||||
"Time": recent(maxStatsAge),
|
||||
"SwapUsageBytes": swapBytesMatcher,
|
||||
"SwapAvailableBytes": swapBytesMatcher,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
func recent(d time.Duration) types.GomegaMatcher {
|
||||
return gomega.WithTransform(func(t metav1.Time) time.Time {
|
||||
return t.Time
|
||||
|
Loading…
Reference in New Issue
Block a user