@@ -28,6 +28,7 @@ import (
28
28
apierrors "k8s.io/apimachinery/pkg/api/errors"
29
29
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30
30
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
31
+ "k8s.io/apimachinery/pkg/runtime"
31
32
"k8s.io/apimachinery/pkg/runtime/schema"
32
33
"k8s.io/apimachinery/pkg/util/intstr"
33
34
"k8s.io/client-go/tools/record"
@@ -2353,7 +2354,10 @@ func TestMachineSetReconciler_syncReplicas(t *testing.T) {
2353
2354
func TestMachineSetReconciler_syncReplicas_WithErrors (t * testing.T ) {
2354
2355
t .Run ("should hold off on sync replicas when create Infrastructure of machine failed " , func (t * testing.T ) {
2355
2356
g := NewWithT (t )
2356
- fakeClient := fake .NewClientBuilder ().WithObjects ().WithInterceptorFuncs (interceptor.Funcs {
2357
+ scheme := runtime .NewScheme ()
2358
+ g .Expect (clusterv1 .AddToScheme (scheme )).To (Succeed ())
2359
+
2360
+ fakeClient := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects ().WithInterceptorFuncs (interceptor.Funcs {
2357
2361
Create : func (ctx context.Context , client client.WithWatch , obj client.Object , opts ... client.CreateOption ) error {
2358
2362
// simulate scenarios where infra object creation fails
2359
2363
if obj .GetObjectKind ().GroupVersionKind ().Kind == "GenericInfrastructureMachine" {
@@ -2366,10 +2370,13 @@ func TestMachineSetReconciler_syncReplicas_WithErrors(t *testing.T) {
2366
2370
r := & Reconciler {
2367
2371
Client : fakeClient ,
2368
2372
}
2369
- testCluster := & clusterv1.Cluster {}
2370
- testCluster .Namespace = "default"
2371
- testCluster .Name = "test-cluster"
2372
- version := "v1.14.2"
2373
+ testCluster := & clusterv1.Cluster {
2374
+ ObjectMeta : metav1.ObjectMeta {
2375
+ Name : "test-cluster" ,
2376
+ Namespace : "default" ,
2377
+ },
2378
+ }
2379
+
2373
2380
duration10m := & metav1.Duration {Duration : 10 * time .Minute }
2374
2381
machineSet := & clusterv1.MachineSet {
2375
2382
ObjectMeta : metav1.ObjectMeta {
@@ -2383,7 +2390,7 @@ func TestMachineSetReconciler_syncReplicas_WithErrors(t *testing.T) {
2383
2390
Template : clusterv1.MachineTemplateSpec {
2384
2391
Spec : clusterv1.MachineSpec {
2385
2392
ClusterName : testCluster .Name ,
2386
- Version : & version ,
2393
+ Version : ptr . To ( "v1.14.2" ) ,
2387
2394
Bootstrap : clusterv1.Bootstrap {
2388
2395
ConfigRef : & corev1.ObjectReference {
2389
2396
APIVersion : "bootstrap.cluster.x-k8s.io/v1beta1" ,
@@ -2416,6 +2423,7 @@ func TestMachineSetReconciler_syncReplicas_WithErrors(t *testing.T) {
2416
2423
},
2417
2424
},
2418
2425
}
2426
+
2419
2427
bootstrapTmpl := & unstructured.Unstructured {
2420
2428
Object : map [string ]interface {}{
2421
2429
"spec" : map [string ]interface {}{
0 commit comments