Skip to content

Commit 6e6b2b7

Browse files
bobbypagehaircommander
authored andcommitted
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 <[email protected]> Signed-off-by: Paco Xu <[email protected]>
1 parent f58b46c commit 6e6b2b7

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

pkg/kubelet/stats/cri_stats_provider.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ func (p *criStatsProvider) addProcessStats(
590590
processStats := cadvisorInfoToProcessStats(container)
591591
// Sum up all of the process stats for each of the containers to obtain the cumulative pod level process count
592592
ps.ProcessStats = mergeProcessStats(ps.ProcessStats, processStats)
593-
return
594593
}
595594

596595
func (p *criStatsProvider) makeContainerStats(

pkg/kubelet/stats/helper_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2929
statsapi "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
30-
"k8s.io/utils/pointer"
30+
"k8s.io/utils/ptr"
3131
)
3232

3333
func TestCustomMetrics(t *testing.T) {
@@ -115,21 +115,21 @@ func TestMergeProcessStats(t *testing.T) {
115115
},
116116
{
117117
desc: "first non-nil, second not",
118-
first: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)},
118+
first: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
119119
second: nil,
120-
expected: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)},
120+
expected: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
121121
},
122122
{
123123
desc: "first nil, second non-nil",
124124
first: nil,
125-
second: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)},
126-
expected: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)},
125+
second: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
126+
expected: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
127127
},
128128
{
129129
desc: "both non nill",
130-
first: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)},
131-
second: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)},
132-
expected: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(200)},
130+
first: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
131+
second: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)},
132+
expected: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](200)},
133133
},
134134
} {
135135
t.Run(tc.desc, func(t *testing.T) {

test/e2e_node/summary_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ var _ = SIGDescribe("Summary API", framework.WithNodeConformance(), func() {
259259
"InodesUsed": bounded(0, 1e8),
260260
}),
261261
"ProcessStats": ptrMatchAllFields(gstruct.Fields{
262-
"ProcessCount": bounded(0, 1e8),
262+
"ProcessCount": bounded(1, 1e8),
263263
}),
264264
})
265265

0 commit comments

Comments
 (0)