test: Update summary test to check for process count

The process count is expected to always be >= 1 for pods in the test.

Let's check it's >= 1, so we can catch issues if the proecss count is
not reported.

Signed-off-by: David Porter <david@porter.me>
Signed-off-by: Paco Xu <paco.xu@daocloud.io>
This commit is contained in:
David Porter 2023-01-19 15:15:24 -08:00 committed by Peter Hunt
parent f58b46cb97
commit 6e6b2b76a3
3 changed files with 9 additions and 10 deletions

View File

@ -590,7 +590,6 @@ func (p *criStatsProvider) addProcessStats(
processStats := cadvisorInfoToProcessStats(container) processStats := cadvisorInfoToProcessStats(container)
// Sum up all of the process stats for each of the containers to obtain the cumulative pod level process count // Sum up all of the process stats for each of the containers to obtain the cumulative pod level process count
ps.ProcessStats = mergeProcessStats(ps.ProcessStats, processStats) ps.ProcessStats = mergeProcessStats(ps.ProcessStats, processStats)
return
} }
func (p *criStatsProvider) makeContainerStats( func (p *criStatsProvider) makeContainerStats(

View File

@ -27,7 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
statsapi "k8s.io/kubelet/pkg/apis/stats/v1alpha1" statsapi "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
"k8s.io/utils/pointer" "k8s.io/utils/ptr"
) )
func TestCustomMetrics(t *testing.T) { func TestCustomMetrics(t *testing.T) {
@ -115,21 +115,21 @@ func TestMergeProcessStats(t *testing.T) {
}, },
{ {
desc: "first non-nil, second not", desc: "first non-nil, second not",
first: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, first: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
second: nil, second: nil,
expected: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, expected: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
}, },
{ {
desc: "first nil, second non-nil", desc: "first nil, second non-nil",
first: nil, first: nil,
second: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, second: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
expected: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, expected: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
}, },
{ {
desc: "both non nill", desc: "both non nill",
first: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, first: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
second: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, second: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
expected: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(200)}, expected: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](200)},
}, },
} { } {
t.Run(tc.desc, func(t *testing.T) { t.Run(tc.desc, func(t *testing.T) {

View File

@ -259,7 +259,7 @@ var _ = SIGDescribe("Summary API", framework.WithNodeConformance(), func() {
"InodesUsed": bounded(0, 1e8), "InodesUsed": bounded(0, 1e8),
}), }),
"ProcessStats": ptrMatchAllFields(gstruct.Fields{ "ProcessStats": ptrMatchAllFields(gstruct.Fields{
"ProcessCount": bounded(0, 1e8), "ProcessCount": bounded(1, 1e8),
}), }),
}) })