Skip to content

Commit aaa0734

Browse files
committed
Confirm list quantity after pod template collection deleted
1 parent d373bef commit aaa0734

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

test/e2e/common/podtemplates.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,38 +141,37 @@ var _ = ginkgo.Describe("[sig-node] PodTemplates", func() {
141141
framework.ExpectEqual(len(podTemplateList.Items), len(podTemplateNames), "looking for expected number of pod templates")
142142

143143
ginkgo.By("delete collection of pod templates")
144-
// confirm that delete collection does remove all pod templates
144+
// delete collection
145145

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")
155150

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")
157152

153+
err = wait.PollImmediate(podTemplateRetryPeriod, podTemplateRetryTimeout, checkPodTemplateListQuantity(f, "podtemplate-set=true", 0))
154+
framework.ExpectNoError(err, "failed to count required pod templates")
158155
})
159156

160157
})
161158

162-
func deletePodTemplateCollection(f *framework.Framework, label string) func() (bool, error) {
159+
func checkPodTemplateListQuantity(f *framework.Framework, label string, quantity int) func() (bool, error) {
163160
return func() (bool, error) {
164161
var err error
165162

166-
framework.Logf("requesting DeleteCollection of pod templates")
163+
framework.Logf("requesting list of pod templates to confirm quantity")
167164

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{
169166
LabelSelector: label})
170167

171168
if err != nil {
172169
return false, err
173-
} else {
174-
return true, nil
175170
}
176171

172+
if len(list.Items) != quantity {
173+
return false, err
174+
}
175+
return true, nil
177176
}
178177
}

0 commit comments

Comments
 (0)