mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 05:21:58 +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),
|
"PageFaults": bounded(1000, 1e9),
|
||||||
"MajorPageFaults": bounded(0, 100000),
|
"MajorPageFaults": bounded(0, 100000),
|
||||||
}),
|
}),
|
||||||
|
"Swap": swapExpectation(memoryLimit),
|
||||||
"Accelerators": gomega.BeEmpty(),
|
"Accelerators": gomega.BeEmpty(),
|
||||||
"Rootfs": gomega.BeNil(),
|
"Rootfs": gomega.BeNil(),
|
||||||
"Logs": gomega.BeNil(),
|
"Logs": gomega.BeNil(),
|
||||||
@ -183,6 +184,7 @@ var _ = SIGDescribe("Summary API [NodeConformance]", func() {
|
|||||||
"PageFaults": bounded(100, expectedPageFaultsUpperBound),
|
"PageFaults": bounded(100, expectedPageFaultsUpperBound),
|
||||||
"MajorPageFaults": bounded(0, expectedMajorPageFaultsUpperBound),
|
"MajorPageFaults": bounded(0, expectedMajorPageFaultsUpperBound),
|
||||||
}),
|
}),
|
||||||
|
"Swap": swapExpectation(memoryLimit),
|
||||||
"Accelerators": gomega.BeEmpty(),
|
"Accelerators": gomega.BeEmpty(),
|
||||||
"Rootfs": ptrMatchAllFields(gstruct.Fields{
|
"Rootfs": ptrMatchAllFields(gstruct.Fields{
|
||||||
"Time": recent(maxStatsAge),
|
"Time": recent(maxStatsAge),
|
||||||
@ -230,6 +232,7 @@ var _ = SIGDescribe("Summary API [NodeConformance]", func() {
|
|||||||
"PageFaults": bounded(0, expectedPageFaultsUpperBound),
|
"PageFaults": bounded(0, expectedPageFaultsUpperBound),
|
||||||
"MajorPageFaults": bounded(0, expectedMajorPageFaultsUpperBound),
|
"MajorPageFaults": bounded(0, expectedMajorPageFaultsUpperBound),
|
||||||
}),
|
}),
|
||||||
|
"Swap": swapExpectation(memoryLimit),
|
||||||
"VolumeStats": gstruct.MatchAllElements(summaryObjectID, gstruct.Elements{
|
"VolumeStats": gstruct.MatchAllElements(summaryObjectID, gstruct.Elements{
|
||||||
"test-empty-dir": gstruct.MatchAllFields(gstruct.Fields{
|
"test-empty-dir": gstruct.MatchAllFields(gstruct.Fields{
|
||||||
"Name": gomega.Equal("test-empty-dir"),
|
"Name": gomega.Equal("test-empty-dir"),
|
||||||
@ -280,6 +283,7 @@ var _ = SIGDescribe("Summary API [NodeConformance]", func() {
|
|||||||
"PageFaults": bounded(1000, 1e9),
|
"PageFaults": bounded(1000, 1e9),
|
||||||
"MajorPageFaults": bounded(0, 100000),
|
"MajorPageFaults": bounded(0, 100000),
|
||||||
}),
|
}),
|
||||||
|
"Swap": swapExpectation(memoryLimit),
|
||||||
// TODO(#28407): Handle non-eth0 network interface names.
|
// TODO(#28407): Handle non-eth0 network interface names.
|
||||||
"Network": ptrMatchAllFields(gstruct.Fields{
|
"Network": ptrMatchAllFields(gstruct.Fields{
|
||||||
"Time": recent(maxStatsAge),
|
"Time": recent(maxStatsAge),
|
||||||
@ -410,6 +414,27 @@ func bounded(lower, upper interface{}) types.GomegaMatcher {
|
|||||||
gomega.BeNumerically("<=", upper)))
|
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 {
|
func recent(d time.Duration) types.GomegaMatcher {
|
||||||
return gomega.WithTransform(func(t metav1.Time) time.Time {
|
return gomega.WithTransform(func(t metav1.Time) time.Time {
|
||||||
return t.Time
|
return t.Time
|
||||||
|
Loading…
Reference in New Issue
Block a user