@@ -37,15 +37,17 @@ import (
37
37
"k8s.io/client-go/informers"
38
38
"k8s.io/client-go/kubernetes/fake"
39
39
"k8s.io/client-go/tools/cache"
40
+ "k8s.io/kubernetes/test/utils/ktesting"
40
41
)
41
42
42
43
func TestBeforeSynced (t * testing.T ) {
44
+ tCtx := ktesting .Init (t )
43
45
kc := fake .NewSimpleClientset ()
44
46
45
47
informerFactory := informers .NewSharedInformerFactoryWithOptions (kc , 0 )
46
48
47
49
ctbInformer := informerFactory .Certificates ().V1alpha1 ().ClusterTrustBundles ()
48
- ctbManager , _ := NewInformerManager (ctbInformer , 256 , 5 * time .Minute )
50
+ ctbManager , _ := NewInformerManager (tCtx , ctbInformer , 256 , 5 * time .Minute )
49
51
50
52
_ , err := ctbManager .GetTrustAnchorsByName ("foo" , false )
51
53
if err == nil {
@@ -55,6 +57,7 @@ func TestBeforeSynced(t *testing.T) {
55
57
56
58
func TestGetTrustAnchorsByName (t * testing.T ) {
57
59
ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
60
+ tCtx := ktesting .Init (t )
58
61
defer cancel ()
59
62
60
63
ctb1 := & certificatesv1alpha1.ClusterTrustBundle {
@@ -80,7 +83,7 @@ func TestGetTrustAnchorsByName(t *testing.T) {
80
83
informerFactory := informers .NewSharedInformerFactoryWithOptions (kc , 0 )
81
84
82
85
ctbInformer := informerFactory .Certificates ().V1alpha1 ().ClusterTrustBundles ()
83
- ctbManager , _ := NewInformerManager (ctbInformer , 256 , 5 * time .Minute )
86
+ ctbManager , _ := NewInformerManager (tCtx , ctbInformer , 256 , 5 * time .Minute )
84
87
85
88
informerFactory .Start (ctx .Done ())
86
89
if ! cache .WaitForCacheSync (ctx .Done (), ctbInformer .Informer ().HasSynced ) {
@@ -117,7 +120,8 @@ func TestGetTrustAnchorsByName(t *testing.T) {
117
120
}
118
121
119
122
func TestGetTrustAnchorsByNameCaching (t * testing.T ) {
120
- ctx , cancel := context .WithTimeout (context .Background (), 20 * time .Second )
123
+ tCtx := ktesting .Init (t )
124
+ ctx , cancel := context .WithTimeout (tCtx , 20 * time .Second )
121
125
defer cancel ()
122
126
123
127
ctb1 := & certificatesv1alpha1.ClusterTrustBundle {
@@ -143,7 +147,7 @@ func TestGetTrustAnchorsByNameCaching(t *testing.T) {
143
147
informerFactory := informers .NewSharedInformerFactoryWithOptions (kc , 0 )
144
148
145
149
ctbInformer := informerFactory .Certificates ().V1alpha1 ().ClusterTrustBundles ()
146
- ctbManager , _ := NewInformerManager (ctbInformer , 256 , 5 * time .Minute )
150
+ ctbManager , _ := NewInformerManager (tCtx , ctbInformer , 256 , 5 * time .Minute )
147
151
148
152
informerFactory .Start (ctx .Done ())
149
153
if ! cache .WaitForCacheSync (ctx .Done (), ctbInformer .Informer ().HasSynced ) {
@@ -204,6 +208,7 @@ func TestGetTrustAnchorsByNameCaching(t *testing.T) {
204
208
205
209
func TestGetTrustAnchorsBySignerName (t * testing.T ) {
206
210
ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
211
+ tCtx := ktesting .Init (t )
207
212
defer cancel ()
208
213
209
214
ctb1 := mustMakeCTB ("signer-a-label-a-1" , "foo.bar/a" , map [string ]string {"label" : "a" }, mustMakeRoot (t , "0" ))
@@ -217,7 +222,7 @@ func TestGetTrustAnchorsBySignerName(t *testing.T) {
217
222
informerFactory := informers .NewSharedInformerFactoryWithOptions (kc , 0 )
218
223
219
224
ctbInformer := informerFactory .Certificates ().V1alpha1 ().ClusterTrustBundles ()
220
- ctbManager , _ := NewInformerManager (ctbInformer , 256 , 5 * time .Minute )
225
+ ctbManager , _ := NewInformerManager (tCtx , ctbInformer , 256 , 5 * time .Minute )
221
226
222
227
informerFactory .Start (ctx .Done ())
223
228
if ! cache .WaitForCacheSync (ctx .Done (), ctbInformer .Informer ().HasSynced ) {
@@ -319,7 +324,8 @@ func TestGetTrustAnchorsBySignerName(t *testing.T) {
319
324
}
320
325
321
326
func TestGetTrustAnchorsBySignerNameCaching (t * testing.T ) {
322
- ctx , cancel := context .WithTimeout (context .Background (), 20 * time .Second )
327
+ tCtx := ktesting .Init (t )
328
+ ctx , cancel := context .WithTimeout (tCtx , 20 * time .Second )
323
329
defer cancel ()
324
330
325
331
ctb1 := mustMakeCTB ("signer-a-label-a-1" , "foo.bar/a" , map [string ]string {"label" : "a" }, mustMakeRoot (t , "0" ))
@@ -330,7 +336,7 @@ func TestGetTrustAnchorsBySignerNameCaching(t *testing.T) {
330
336
informerFactory := informers .NewSharedInformerFactoryWithOptions (kc , 0 )
331
337
332
338
ctbInformer := informerFactory .Certificates ().V1alpha1 ().ClusterTrustBundles ()
333
- ctbManager , _ := NewInformerManager (ctbInformer , 256 , 5 * time .Minute )
339
+ ctbManager , _ := NewInformerManager (tCtx , ctbInformer , 256 , 5 * time .Minute )
334
340
335
341
informerFactory .Start (ctx .Done ())
336
342
if ! cache .WaitForCacheSync (ctx .Done (), ctbInformer .Informer ().HasSynced ) {
0 commit comments