@@ -177,6 +177,12 @@ var _ = ginkgo.Describe("[sig-node] ConfigMap", func() {
177
177
_ , err := f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).Create (context .TODO (), & testConfigMap , metav1.CreateOptions {})
178
178
framework .ExpectNoError (err , "failed to create ConfigMap" )
179
179
180
+ ginkgo .By ("fetching the ConfigMap" )
181
+ configMap , err := f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).Get (context .TODO (), testConfigMapName , metav1.GetOptions {})
182
+ framework .ExpectNoError (err , "failed to get ConfigMap" )
183
+ framework .ExpectEqual (configMap .Data ["valueName" ], testConfigMap .Data ["valueName" ])
184
+ framework .ExpectEqual (configMap .Labels ["test-configmap-static" ], testConfigMap .Labels ["test-configmap-static" ])
185
+
180
186
configMapPatchPayload , err := json .Marshal (v1.ConfigMap {
181
187
ObjectMeta : metav1.ObjectMeta {
182
188
Labels : map [string ]string {
@@ -193,39 +199,35 @@ var _ = ginkgo.Describe("[sig-node] ConfigMap", func() {
193
199
_ , err = f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).Patch (context .TODO (), testConfigMapName , types .StrategicMergePatchType , []byte (configMapPatchPayload ), metav1.PatchOptions {})
194
200
framework .ExpectNoError (err , "failed to patch ConfigMap" )
195
201
196
- ginkgo .By ("fetching the ConfigMap" )
197
- configMap , err := f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).Get (context .TODO (), testConfigMapName , metav1.GetOptions {})
198
- framework .ExpectNoError (err , "failed to get ConfigMap" )
199
- framework .ExpectEqual (configMap .Data ["valueName" ], "value1" , "failed to patch ConfigMap" )
200
- framework .ExpectEqual (configMap .Labels ["test-configmap" ], "patched" , "failed to patch ConfigMap" )
201
-
202
- ginkgo .By ("listing all ConfigMaps in all namespaces" )
202
+ ginkgo .By ("listing all ConfigMaps in all namespaces with a label selector" )
203
203
configMapList , err := f .ClientSet .CoreV1 ().ConfigMaps ("" ).List (context .TODO (), metav1.ListOptions {
204
- LabelSelector : "test-configmap-static=true " ,
204
+ LabelSelector : "test-configmap=patched " ,
205
205
})
206
206
framework .ExpectNoError (err , "failed to list ConfigMaps with LabelSelector" )
207
- framework .ExpectNotEqual (len (configMapList .Items ), 0 , "no ConfigMaps found in ConfigMap list" )
208
207
testConfigMapFound := false
209
208
for _ , cm := range configMapList .Items {
210
- if cm .ObjectMeta .Name == testConfigMapName &&
209
+ if cm .ObjectMeta .Name == testConfigMap . ObjectMeta . Name &&
211
210
cm .ObjectMeta .Namespace == testNamespaceName &&
212
- cm .ObjectMeta .Labels ["test-configmap-static" ] == "true" &&
211
+ cm .ObjectMeta .Labels ["test-configmap-static" ] == testConfigMap .ObjectMeta .Labels ["test-configmap-static" ] &&
212
+ cm .ObjectMeta .Labels ["test-configmap" ] == "patched" &&
213
213
cm .Data ["valueName" ] == "value1" {
214
214
testConfigMapFound = true
215
215
break
216
216
}
217
217
}
218
- framework .ExpectEqual (testConfigMapFound , true , "failed to find ConfigMap in list " )
218
+ framework .ExpectEqual (testConfigMapFound , true , "failed to find ConfigMap by label selector " )
219
219
220
- ginkgo .By ("deleting the ConfigMap by a collection " )
220
+ ginkgo .By ("deleting the ConfigMap by collection with a label selector " )
221
221
err = f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).DeleteCollection (context .TODO (), metav1.DeleteOptions {}, metav1.ListOptions {
222
222
LabelSelector : "test-configmap-static=true" ,
223
223
})
224
224
framework .ExpectNoError (err , "failed to delete ConfigMap collection with LabelSelector" )
225
- ginkgo .By ("listing all ConfigMaps in all namespaces" )
226
- configMapList , err = f .ClientSet .CoreV1 ().ConfigMaps ("" ).List (context .TODO (), metav1.ListOptions {
225
+
226
+ ginkgo .By ("listing all ConfigMaps in test namespace" )
227
+ configMapList , err = f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).List (context .TODO (), metav1.ListOptions {
227
228
LabelSelector : "test-configmap-static=true" ,
228
229
})
230
+ framework .ExpectNoError (err , "failed to list ConfigMap by LabelSelector" )
229
231
framework .ExpectEqual (len (configMapList .Items ), 0 , "ConfigMap is still present after being deleted by collection" )
230
232
})
231
233
})
0 commit comments