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:
		| @@ -590,7 +590,6 @@ func (p *criStatsProvider) addProcessStats( | ||||
| 	processStats := cadvisorInfoToProcessStats(container) | ||||
| 	// 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) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (p *criStatsProvider) makeContainerStats( | ||||
|   | ||||
| @@ -27,7 +27,7 @@ import ( | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	statsapi "k8s.io/kubelet/pkg/apis/stats/v1alpha1" | ||||
| 	"k8s.io/utils/pointer" | ||||
| 	"k8s.io/utils/ptr" | ||||
| ) | ||||
|  | ||||
| func TestCustomMetrics(t *testing.T) { | ||||
| @@ -115,21 +115,21 @@ func TestMergeProcessStats(t *testing.T) { | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:     "first non-nil, second not", | ||||
| 			first:    &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, | ||||
| 			first:    &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)}, | ||||
| 			second:   nil, | ||||
| 			expected: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, | ||||
| 			expected: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:     "first nil, second non-nil", | ||||
| 			first:    nil, | ||||
| 			second:   &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, | ||||
| 			expected: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, | ||||
| 			second:   &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)}, | ||||
| 			expected: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:     "both non nill", | ||||
| 			first:    &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, | ||||
| 			second:   &statsapi.ProcessStats{ProcessCount: pointer.Uint64(100)}, | ||||
| 			expected: &statsapi.ProcessStats{ProcessCount: pointer.Uint64(200)}, | ||||
| 			first:    &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)}, | ||||
| 			second:   &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](100)}, | ||||
| 			expected: &statsapi.ProcessStats{ProcessCount: ptr.To[uint64](200)}, | ||||
| 		}, | ||||
| 	} { | ||||
| 		t.Run(tc.desc, func(t *testing.T) { | ||||
|   | ||||
| @@ -259,7 +259,7 @@ var _ = SIGDescribe("Summary API", framework.WithNodeConformance(), func() { | ||||
| 					"InodesUsed":     bounded(0, 1e8), | ||||
| 				}), | ||||
| 				"ProcessStats": ptrMatchAllFields(gstruct.Fields{ | ||||
| 					"ProcessCount": bounded(0, 1e8), | ||||
| 					"ProcessCount": bounded(1, 1e8), | ||||
| 				}), | ||||
| 			}) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 David Porter
					David Porter