@@ -91,6 +91,7 @@ var _ = SIGDescribe("CPU Manager Metrics", framework.WithSerial(), feature.CPUMa
91
91
ginkgo .AfterEach (func (ctx context.Context ) {
92
92
if testPod != nil {
93
93
deletePodSyncByName (ctx , f , testPod .Name )
94
+ waitForContainerRemoval (ctx , testPod .Spec .Containers [0 ].Name , testPod .Name , testPod .Namespace )
94
95
}
95
96
updateKubeletConfig (ctx , f , oldCfg , true )
96
97
})
@@ -160,11 +161,32 @@ var _ = SIGDescribe("CPU Manager Metrics", framework.WithSerial(), feature.CPUMa
160
161
ginkgo .By ("Ensuring the metrics match the expectations a few more times" )
161
162
gomega .Consistently (ctx , getKubeletMetrics , 1 * time .Minute , 15 * time .Second ).Should (matchResourceMetrics )
162
163
})
164
+
165
+ ginkgo .It ("should return updated alignment counters when pod successfully run" , func (ctx context.Context ) {
166
+ ginkgo .By ("Creating the test pod" )
167
+ testPod = e2epod .NewPodClient (f ).Create (ctx , makeGuaranteedCPUExclusiveSleeperPod ("count-align-smt-ok" , smtLevel ))
168
+
169
+ // we updated the kubelet config in BeforeEach, so we can assume we start fresh.
170
+ // being [Serial], we can also assume noone else but us is running pods.
171
+ ginkgo .By ("Checking the cpumanager metrics right after the kubelet restart, with pod should be admitted" )
172
+
173
+ idFn := makeCustomPairID ("scope" , "boundary" )
174
+ matchAlignmentMetrics := gstruct .MatchKeys (gstruct .IgnoreExtras , gstruct.Keys {
175
+ "kubelet_container_aligned_compute_resources_count" : gstruct .MatchElements (idFn , gstruct .IgnoreExtras , gstruct.Elements {
176
+ "container::physical_cpu" : timelessSample (1 ),
177
+ }),
178
+ })
179
+
180
+ ginkgo .By ("Giving the Kubelet time to update the alignment metrics" )
181
+ gomega .Eventually (ctx , getKubeletMetrics , 1 * time .Minute , 15 * time .Second ).Should (matchAlignmentMetrics )
182
+ ginkgo .By ("Ensuring the metrics match the expectations about alignment metrics a few more times" )
183
+ gomega .Consistently (ctx , getKubeletMetrics , 1 * time .Minute , 15 * time .Second ).Should (matchAlignmentMetrics )
184
+ })
163
185
})
164
186
})
165
187
166
188
func getKubeletMetrics (ctx context.Context ) (e2emetrics.KubeletMetrics , error ) {
167
- ginkgo .By ("getting Kubelet metrics from the metrics API" )
189
+ ginkgo .By ("Getting Kubelet metrics from the metrics API" )
168
190
return e2emetrics .GrabKubeletMetricsWithoutProxy (ctx , nodeNameOrIP ()+ ":10255" , "/metrics" )
169
191
}
170
192
@@ -189,7 +211,7 @@ func makeGuaranteedCPUExclusiveSleeperPod(name string, cpus int) *v1.Pod {
189
211
v1 .ResourceMemory : resource .MustParse ("64Mi" ),
190
212
},
191
213
},
192
- Command : []string {"sh" , "-c" , "sleep" , " 1d" },
214
+ Command : []string {"sh" , "-c" , "sleep 1d" },
193
215
},
194
216
},
195
217
},
0 commit comments