@@ -86,7 +86,7 @@ func TestConcurrentEvictionRequests(t *testing.T) {
86
86
}
87
87
}
88
88
89
- waitToObservePods (t , informers .Core ().V1 ().Pods ().Informer (), numOfEvictions )
89
+ waitToObservePods (t , informers .Core ().V1 ().Pods ().Informer (), numOfEvictions , v1 . PodRunning )
90
90
91
91
pdb := newPDB ()
92
92
if _ , err := clientSet .Policy ().PodDisruptionBudgets (ns .Name ).Create (pdb ); err != nil {
@@ -193,18 +193,21 @@ func TestTerminalPodEviction(t *testing.T) {
193
193
if _ , err := clientSet .CoreV1 ().Pods (ns .Name ).Create (pod ); err != nil {
194
194
t .Errorf ("Failed to create pod: %v" , err )
195
195
}
196
+
196
197
addPodConditionSucceeded (pod )
197
198
if _ , err := clientSet .CoreV1 ().Pods (ns .Name ).UpdateStatus (pod ); err != nil {
198
199
t .Fatal (err )
199
200
}
200
201
201
- waitToObservePods (t , informers .Core ().V1 ().Pods ().Informer (), 1 )
202
+ waitToObservePods (t , informers .Core ().V1 ().Pods ().Informer (), 1 , v1 . PodSucceeded )
202
203
203
204
pdb := newPDB ()
204
205
if _ , err := clientSet .Policy ().PodDisruptionBudgets (ns .Name ).Create (pdb ); err != nil {
205
206
t .Errorf ("Failed to create PodDisruptionBudget: %v" , err )
206
207
}
207
208
209
+ waitPDBStable (t , clientSet , 1 , ns .Name , pdb .Name )
210
+
208
211
pdbList , err := clientSet .Policy ().PodDisruptionBudgets (ns .Name ).List (metav1.ListOptions {})
209
212
if err != nil {
210
213
t .Fatalf ("Error while listing pod disruption budget" )
@@ -341,13 +344,19 @@ func rmSetup(t *testing.T) (*httptest.Server, framework.CloseFunc, *disruption.D
341
344
// wait for the podInformer to observe the pods. Call this function before
342
345
// running the RS controller to prevent the rc manager from creating new pods
343
346
// rather than adopting the existing ones.
344
- func waitToObservePods (t * testing.T , podInformer cache.SharedIndexInformer , podNum int ) {
347
+ func waitToObservePods (t * testing.T , podInformer cache.SharedIndexInformer , podNum int , phase v1. PodPhase ) {
345
348
if err := wait .PollImmediate (2 * time .Second , 60 * time .Second , func () (bool , error ) {
346
349
objects := podInformer .GetIndexer ().List ()
347
- if len (objects ) = = podNum {
348
- return true , nil
350
+ if len (objects ) ! = podNum {
351
+ return false , nil
349
352
}
350
- return false , nil
353
+ for _ , obj := range objects {
354
+ pod := obj .(* v1.Pod )
355
+ if pod .Status .Phase != phase {
356
+ return false , nil
357
+ }
358
+ }
359
+ return true , nil
351
360
}); err != nil {
352
361
t .Fatal (err )
353
362
}
0 commit comments