@@ -141,38 +141,37 @@ var _ = ginkgo.Describe("[sig-node] PodTemplates", func() {
141
141
framework .ExpectEqual (len (podTemplateList .Items ), len (podTemplateNames ), "looking for expected number of pod templates" )
142
142
143
143
ginkgo .By ("delete collection of pod templates" )
144
- // confirm that delete collection does remove all pod templates
144
+ // delete collection
145
145
146
- err = wait .PollImmediate (podTemplateRetryPeriod , podTemplateRetryTimeout , deletePodTemplateCollection (f , "podtemplate-set=true" ))
147
- framework .ExpectNoError (err , "failed to delete collection" )
148
-
149
- ginkgo .By ("get a list of pod templates with a label in the current namespace" )
150
- // get list of pod templates
151
- podTemplateList , err = f .ClientSet .CoreV1 ().PodTemplates (f .Namespace .Name ).List (context .TODO (), metav1.ListOptions {
152
- LabelSelector : "podtemplate-set=true" ,
153
- })
154
- framework .ExpectNoError (err , "failed to get a list of pod templates" )
146
+ framework .Logf ("requesting DeleteCollection of pod templates" )
147
+ err = f .ClientSet .CoreV1 ().PodTemplates (f .Namespace .Name ).DeleteCollection (context .TODO (), metav1.DeleteOptions {}, metav1.ListOptions {
148
+ LabelSelector : "podtemplate-set=true" })
149
+ framework .ExpectNoError (err , "failed to delete all pod templates" )
155
150
156
- framework . ExpectEqual ( len ( podTemplateList . Items ), 0 , " pod templates should all be deleted " )
151
+ ginkgo . By ( "check that the list of pod templates matches the requested quantity " )
157
152
153
+ err = wait .PollImmediate (podTemplateRetryPeriod , podTemplateRetryTimeout , checkPodTemplateListQuantity (f , "podtemplate-set=true" , 0 ))
154
+ framework .ExpectNoError (err , "failed to count required pod templates" )
158
155
})
159
156
160
157
})
161
158
162
- func deletePodTemplateCollection (f * framework.Framework , label string ) func () (bool , error ) {
159
+ func checkPodTemplateListQuantity (f * framework.Framework , label string , quantity int ) func () (bool , error ) {
163
160
return func () (bool , error ) {
164
161
var err error
165
162
166
- framework .Logf ("requesting DeleteCollection of pod templates" )
163
+ framework .Logf ("requesting list of pod templates to confirm quantity " )
167
164
168
- err = f .ClientSet .CoreV1 ().PodTemplates (f .Namespace .Name ).DeleteCollection (context .TODO (), metav1. DeleteOptions {} , metav1.ListOptions {
165
+ list , err : = f .ClientSet .CoreV1 ().PodTemplates (f .Namespace .Name ).List (context .TODO (), metav1.ListOptions {
169
166
LabelSelector : label })
170
167
171
168
if err != nil {
172
169
return false , err
173
- } else {
174
- return true , nil
175
170
}
176
171
172
+ if len (list .Items ) != quantity {
173
+ return false , err
174
+ }
175
+ return true , nil
177
176
}
178
177
}
0 commit comments