@@ -21,7 +21,6 @@ import (
21
21
"testing"
22
22
"time"
23
23
24
- "github.com/go-logr/logr"
25
24
. "github.com/onsi/gomega"
26
25
corev1 "k8s.io/api/core/v1"
27
26
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -33,11 +32,10 @@ import (
33
32
ctrl "sigs.k8s.io/controller-runtime"
34
33
"sigs.k8s.io/controller-runtime/pkg/client"
35
34
"sigs.k8s.io/controller-runtime/pkg/client/fake"
36
- "sigs.k8s.io/controller-runtime/pkg/log"
37
35
38
36
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
37
+ "sigs.k8s.io/cluster-api/controllers/clustercache"
39
38
"sigs.k8s.io/cluster-api/controllers/external"
40
- "sigs.k8s.io/cluster-api/controllers/remote"
41
39
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
42
40
"sigs.k8s.io/cluster-api/internal/test/builder"
43
41
"sigs.k8s.io/cluster-api/internal/util/ssa"
@@ -129,7 +127,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
129
127
fakeClient := fake .NewClientBuilder ().WithObjects (defaultCluster , defaultKubeconfigSecret , machinepool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
130
128
r := & MachinePoolReconciler {
131
129
Client : fakeClient ,
132
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
130
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
133
131
}
134
132
135
133
scope := & scope {
@@ -166,7 +164,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
166
164
167
165
r := & MachinePoolReconciler {
168
166
Client : fakeClient ,
169
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
167
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
170
168
}
171
169
172
170
scope := & scope {
@@ -200,7 +198,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
200
198
fakeClient := fake .NewClientBuilder ().WithObjects (defaultCluster , defaultKubeconfigSecret , machinepool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
201
199
r := & MachinePoolReconciler {
202
200
Client : fakeClient ,
203
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
201
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
204
202
}
205
203
206
204
scope := & scope {
@@ -250,7 +248,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
250
248
fakeClient := fake .NewClientBuilder ().WithObjects (defaultCluster , defaultKubeconfigSecret , machinepool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
251
249
r := & MachinePoolReconciler {
252
250
Client : fakeClient ,
253
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
251
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
254
252
}
255
253
256
254
scope := & scope {
@@ -312,7 +310,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
312
310
fakeClient := fake .NewClientBuilder ().WithObjects (defaultCluster , defaultKubeconfigSecret , machinepool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
313
311
r := & MachinePoolReconciler {
314
312
Client : fakeClient ,
315
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
313
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
316
314
}
317
315
318
316
scope := & scope {
@@ -352,7 +350,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
352
350
fakeClient := fake .NewClientBuilder ().WithObjects (defaultCluster , defaultKubeconfigSecret , machinepool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
353
351
r := & MachinePoolReconciler {
354
352
Client : fakeClient ,
355
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
353
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
356
354
}
357
355
358
356
scope := & scope {
@@ -399,7 +397,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
399
397
fakeClient := fake .NewClientBuilder ().WithObjects (defaultCluster , defaultKubeconfigSecret , machinepool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
400
398
r := & MachinePoolReconciler {
401
399
Client : fakeClient ,
402
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
400
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
403
401
}
404
402
405
403
scope := & scope {
@@ -459,7 +457,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
459
457
fakeClient := fake .NewClientBuilder ().WithObjects (defaultCluster , defaultKubeconfigSecret , machinepool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
460
458
r := & MachinePoolReconciler {
461
459
Client : fakeClient ,
462
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
460
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
463
461
}
464
462
465
463
scope := & scope {
@@ -525,7 +523,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
525
523
fakeClient := fake .NewClientBuilder ().WithObjects (defaultCluster , defaultKubeconfigSecret , machinepool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
526
524
r := & MachinePoolReconciler {
527
525
Client : fakeClient ,
528
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
526
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
529
527
}
530
528
531
529
scope := & scope {
@@ -589,7 +587,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
589
587
fakeClient := fake .NewClientBuilder ().WithObjects (defaultCluster , defaultKubeconfigSecret , machinePool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
590
588
r := & MachinePoolReconciler {
591
589
Client : fakeClient ,
592
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
590
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
593
591
}
594
592
595
593
scope := & scope {
@@ -675,7 +673,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
675
673
fakeClient := fake .NewClientBuilder ().WithObjects (defaultCluster , defaultKubeconfigSecret , machinePool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
676
674
r := & MachinePoolReconciler {
677
675
Client : fakeClient ,
678
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
676
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
679
677
}
680
678
681
679
scope := & scope {
@@ -1286,7 +1284,7 @@ func TestReconcileMachinePoolInfrastructure(t *testing.T) {
1286
1284
fakeClient := fake .NewClientBuilder ().WithObjects (tc .machinepool , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
1287
1285
r := & MachinePoolReconciler {
1288
1286
Client : fakeClient ,
1289
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
1287
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : defaultCluster .Name , Namespace : defaultCluster .Namespace }),
1290
1288
}
1291
1289
1292
1290
scope := & scope {
@@ -1789,7 +1787,7 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) {
1789
1787
fakeClient := fake .NewClientBuilder ().WithObjects (testCluster , kubeconfigSecret , machinepool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
1790
1788
r := & MachinePoolReconciler {
1791
1789
Client : fakeClient ,
1792
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), env .GetClient (), env . GetClient (), env . GetClient (). Scheme (), client.ObjectKey {Name : testCluster .Name , Namespace : testCluster .Namespace }),
1790
+ ClusterCache : clustercache . NewFakeClusterCache ( env .GetClient (), client.ObjectKey {Name : testCluster .Name , Namespace : testCluster .Namespace }),
1793
1791
recorder : record .NewFakeRecorder (32 ),
1794
1792
}
1795
1793
@@ -1851,7 +1849,7 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) {
1851
1849
fakeClient := fake .NewClientBuilder ().WithObjects (testCluster , kubeconfigSecret , machinepool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
1852
1850
r := & MachinePoolReconciler {
1853
1851
Client : fakeClient ,
1854
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), env .GetClient (), env . GetClient (), env . GetClient (). Scheme (), client.ObjectKey {Name : testCluster .Name , Namespace : testCluster .Namespace }),
1852
+ ClusterCache : clustercache . NewFakeClusterCache ( env .GetClient (), client.ObjectKey {Name : testCluster .Name , Namespace : testCluster .Namespace }),
1855
1853
recorder : record .NewFakeRecorder (32 ),
1856
1854
}
1857
1855
@@ -1897,7 +1895,7 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) {
1897
1895
r := & MachinePoolReconciler {
1898
1896
Client : fakeClient ,
1899
1897
recorder : record .NewFakeRecorder (32 ),
1900
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : testCluster .Name , Namespace : testCluster .Namespace }),
1898
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : testCluster .Name , Namespace : testCluster .Namespace }),
1901
1899
}
1902
1900
1903
1901
scope := & scope {
@@ -1938,7 +1936,7 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) {
1938
1936
r := & MachinePoolReconciler {
1939
1937
Client : fakeClient ,
1940
1938
recorder : record .NewFakeRecorder (32 ),
1941
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), fakeClient , fakeClient , fakeClient . Scheme () , client.ObjectKey {Name : testCluster .Name , Namespace : testCluster .Namespace }),
1939
+ ClusterCache : clustercache . NewFakeClusterCache ( fakeClient , client.ObjectKey {Name : testCluster .Name , Namespace : testCluster .Namespace }),
1942
1940
}
1943
1941
1944
1942
scope := & scope {
@@ -2000,7 +1998,7 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) {
2000
1998
fakeClient := fake .NewClientBuilder ().WithObjects (testCluster , kubeconfigSecret , machinepool , bootstrapConfig , infraConfig , builder .TestBootstrapConfigCRD , builder .TestInfrastructureMachineTemplateCRD ).Build ()
2001
1999
r := & MachinePoolReconciler {
2002
2000
Client : fakeClient ,
2003
- ClusterCache : remote . NewTestClusterCacheTracker ( logr . New (log. NullLogSink {}), env .GetClient (), env . GetClient (), env . GetClient (). Scheme (), client.ObjectKey {Name : testCluster .Name , Namespace : testCluster .Namespace }),
2001
+ ClusterCache : clustercache . NewFakeClusterCache ( env .GetClient (), client.ObjectKey {Name : testCluster .Name , Namespace : testCluster .Namespace }),
2004
2002
recorder : record .NewFakeRecorder (32 ),
2005
2003
}
2006
2004
0 commit comments