@@ -24,12 +24,19 @@ import (
24
24
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25
25
"k8s.io/apimachinery/pkg/types"
26
26
"k8s.io/apimachinery/pkg/util/uuid"
27
+ "k8s.io/apimachinery/pkg/util/wait"
27
28
"k8s.io/kubernetes/test/e2e/framework"
28
29
imageutils "k8s.io/kubernetes/test/utils/image"
30
+ "time"
29
31
30
32
"github.com/onsi/ginkgo"
31
33
)
32
34
35
+ const (
36
+ podTemplateRetryPeriod = 1 * time .Second
37
+ podTemplateRetryTimeout = 1 * time .Minute
38
+ )
39
+
33
40
var _ = ginkgo .Describe ("[sig-node] PodTemplates" , func () {
34
41
f := framework .NewDefaultFramework ("podtemplate" )
35
42
/*
@@ -134,12 +141,10 @@ var _ = ginkgo.Describe("[sig-node] PodTemplates", func() {
134
141
framework .ExpectEqual (len (podTemplateList .Items ), len (podTemplateNames ), "looking for expected number of pod templates" )
135
142
136
143
ginkgo .By ("delete collection of pod templates" )
137
- // delete collection
144
+ // confirm that delete collection does remove all pod templates
138
145
139
- framework .Logf ("requesting DeleteCollection of pod templates" )
140
- err = f .ClientSet .CoreV1 ().PodTemplates (f .Namespace .Name ).DeleteCollection (context .TODO (), metav1.DeleteOptions {}, metav1.ListOptions {
141
- LabelSelector : "podtemplate-set=true" })
142
- framework .ExpectNoError (err , "failed to delete all pod templates" )
146
+ err = wait .PollImmediate (podTemplateRetryPeriod , podTemplateRetryTimeout , deletePodTemplateCollection (f , "podtemplate-set=true" ))
147
+ framework .ExpectNoError (err , "failed to delete collection" )
143
148
144
149
ginkgo .By ("get a list of pod templates with a label in the current namespace" )
145
150
// get list of pod templates
@@ -153,3 +158,21 @@ var _ = ginkgo.Describe("[sig-node] PodTemplates", func() {
153
158
})
154
159
155
160
})
161
+
162
+ func deletePodTemplateCollection (f * framework.Framework , label string ) func () (bool , error ) {
163
+ return func () (bool , error ) {
164
+ var err error
165
+
166
+ framework .Logf ("requesting DeleteCollection of pod templates" )
167
+
168
+ err = f .ClientSet .CoreV1 ().PodTemplates (f .Namespace .Name ).DeleteCollection (context .TODO (), metav1.DeleteOptions {}, metav1.ListOptions {
169
+ LabelSelector : label })
170
+
171
+ if err != nil {
172
+ return false , err
173
+ } else {
174
+ return true , nil
175
+ }
176
+
177
+ }
178
+ }
0 commit comments