@@ -20,16 +20,11 @@ import (
20
20
"context"
21
21
"encoding/json"
22
22
"fmt"
23
- "time"
24
23
25
24
v1 "k8s.io/api/core/v1"
26
25
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
26
"k8s.io/apimachinery/pkg/types"
28
27
"k8s.io/apimachinery/pkg/util/uuid"
29
- watch "k8s.io/apimachinery/pkg/watch"
30
- "k8s.io/client-go/dynamic"
31
- "k8s.io/client-go/tools/cache"
32
- watchtools "k8s.io/client-go/tools/watch"
33
28
"k8s.io/kubernetes/test/e2e/framework"
34
29
imageutils "k8s.io/kubernetes/test/utils/image"
35
30
@@ -39,12 +34,6 @@ import (
39
34
var _ = ginkgo .Describe ("[sig-node] ConfigMap" , func () {
40
35
f := framework .NewDefaultFramework ("configmap" )
41
36
42
- var dc dynamic.Interface
43
-
44
- ginkgo .BeforeEach (func () {
45
- dc = f .DynamicClient
46
- })
47
-
48
37
/*
49
38
Release : v1.9
50
39
Testname: ConfigMap, from environment field
@@ -184,37 +173,10 @@ var _ = ginkgo.Describe("[sig-node] ConfigMap", func() {
184
173
},
185
174
}
186
175
187
- w := & cache.ListWatch {
188
- WatchFunc : func (options metav1.ListOptions ) (watch.Interface , error ) {
189
- options .LabelSelector = "test-configmap-static=true"
190
- return f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).Watch (context .TODO (), options )
191
- },
192
- }
193
- cml , err := f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).List (context .TODO (), metav1.ListOptions {LabelSelector : "test-configmap-static=true" })
194
- framework .ExpectNoError (err )
195
-
196
176
ginkgo .By ("creating a ConfigMap" )
197
- cm , err := f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).Create (context .TODO (), & testConfigMap , metav1.CreateOptions {})
177
+ _ , err := f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).Create (context .TODO (), & testConfigMap , metav1.CreateOptions {})
198
178
framework .ExpectNoError (err , "failed to create ConfigMap" )
199
179
200
- ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
201
- defer cancel ()
202
- _ , err = watchtools .Until (ctx , cml .ResourceVersion , w , func (event watch.Event ) (bool , error ) {
203
- switch event .Type {
204
- case watch .Added :
205
- if cm , ok := event .Object .(* v1.ConfigMap ); ok {
206
- found := cm .ObjectMeta .Name == testConfigMap .Name &&
207
- cm .Labels ["test-configmap-static" ] == "true" &&
208
- cm .Data ["valueName" ] == "value"
209
- return found , nil
210
- }
211
- default :
212
- framework .Logf ("observed event type %v" , event .Type )
213
- }
214
- return false , nil
215
- })
216
- framework .ExpectNoError (err , "failed to see a watch.Added event for the configmap we created" )
217
-
218
180
configMapPatchPayload , err := json .Marshal (v1.ConfigMap {
219
181
ObjectMeta : metav1.ObjectMeta {
220
182
Labels : map [string ]string {
@@ -228,27 +190,8 @@ var _ = ginkgo.Describe("[sig-node] ConfigMap", func() {
228
190
framework .ExpectNoError (err , "failed to marshal patch data" )
229
191
230
192
ginkgo .By ("patching the ConfigMap" )
231
- cm2 , err : = f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).Patch (context .TODO (), testConfigMapName , types .StrategicMergePatchType , []byte (configMapPatchPayload ), metav1.PatchOptions {})
193
+ _ , err = f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).Patch (context .TODO (), testConfigMapName , types .StrategicMergePatchType , []byte (configMapPatchPayload ), metav1.PatchOptions {})
232
194
framework .ExpectNoError (err , "failed to patch ConfigMap" )
233
- ginkgo .By ("waiting for the ConfigMap to be modified" )
234
- ctx , cancel = context .WithTimeout (context .Background (), 30 * time .Second )
235
- defer cancel ()
236
- _ , err = watchtools .Until (ctx , cm .ResourceVersion , w , func (event watch.Event ) (bool , error ) {
237
- switch event .Type {
238
- case watch .Modified :
239
- if cm , ok := event .Object .(* v1.ConfigMap ); ok {
240
- found := cm .ObjectMeta .Name == testConfigMap .Name &&
241
- cm .Labels ["test-configmap-static" ] == "true" &&
242
- cm .Labels ["test-configmap" ] == "patched" &&
243
- cm .Data ["valueName" ] == "value1"
244
- return found , nil
245
- }
246
- default :
247
- framework .Logf ("observed event type %v" , event .Type )
248
- }
249
- return false , nil
250
- })
251
- framework .ExpectNoError (err , "failed to see a watch.Modified event for the configmap we patched" )
252
195
253
196
ginkgo .By ("fetching the ConfigMap" )
254
197
configMap , err := f .ClientSet .CoreV1 ().ConfigMaps (testNamespaceName ).Get (context .TODO (), testConfigMapName , metav1.GetOptions {})
@@ -279,25 +222,11 @@ var _ = ginkgo.Describe("[sig-node] ConfigMap", func() {
279
222
LabelSelector : "test-configmap-static=true" ,
280
223
})
281
224
framework .ExpectNoError (err , "failed to delete ConfigMap collection with LabelSelector" )
282
- ginkgo .By ("waiting for the ConfigMap to be deleted" )
283
- ctx , cancel = context .WithTimeout (context .Background (), 30 * time .Second )
284
- defer cancel ()
285
- _ , err = watchtools .Until (ctx , cm2 .ResourceVersion , w , func (event watch.Event ) (bool , error ) {
286
- switch event .Type {
287
- case watch .Deleted :
288
- if cm , ok := event .Object .(* v1.ConfigMap ); ok {
289
- found := cm .ObjectMeta .Name == testConfigMap .Name &&
290
- cm .Labels ["test-configmap-static" ] == "true" &&
291
- cm .Labels ["test-configmap" ] == "patched" &&
292
- cm .Data ["valueName" ] == "value1"
293
- return found , nil
294
- }
295
- default :
296
- framework .Logf ("observed event type %v" , event .Type )
297
- }
298
- return false , nil
225
+ ginkgo .By ("listing all ConfigMaps in all namespaces" )
226
+ configMapList , err = f .ClientSet .CoreV1 ().ConfigMaps ("" ).List (context .TODO (), metav1.ListOptions {
227
+ LabelSelector : "test-configmap-static=true" ,
299
228
})
300
- framework .ExpectNoError ( err , "fasiled to observe a watch.Deleted event for the ConfigMap we deleted " )
229
+ framework .ExpectEqual ( len ( configMapList . Items ), 0 , "ConfigMap is still present after being deleted by collection " )
301
230
})
302
231
})
303
232
0 commit comments