@@ -28,7 +28,7 @@ import (
28
28
"k8s.io/client-go/kubernetes"
29
29
"sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient"
30
30
"sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/provider"
31
- clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1 "
31
+ clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha2 "
32
32
)
33
33
34
34
type testClusterProvisioner struct {
@@ -91,7 +91,7 @@ type stringCheckFunc func(string) error
91
91
type testClusterClient struct {
92
92
ApplyErr error
93
93
DeleteErr error
94
- WaitForClusterV1alpha1ReadyErr error
94
+ WaitForClusterV1alpha2ReadyErr error
95
95
GetClustersErr error
96
96
GetClusterErr error
97
97
GetMachineClassesErr error
@@ -117,7 +117,6 @@ type testClusterClient struct {
117
117
ApplyFunc stringCheckFunc
118
118
119
119
clusters map [string ][]* clusterv1.Cluster
120
- machineClasses map [string ][]* clusterv1.MachineClass
121
120
machineDeployments map [string ][]* clusterv1.MachineDeployment
122
121
machineSets map [string ][]* clusterv1.MachineSet
123
122
machines map [string ][]* clusterv1.Machine
@@ -143,8 +142,8 @@ func (c *testClusterClient) GetContextNamespace() string {
143
142
return c .contextNamespace
144
143
}
145
144
146
- func (c * testClusterClient ) WaitForClusterV1alpha1Ready () error {
147
- return c .WaitForClusterV1alpha1ReadyErr
145
+ func (c * testClusterClient ) WaitForClusterV1alpha2Ready () error {
146
+ return c .WaitForClusterV1alpha2ReadyErr
148
147
}
149
148
150
149
func (c * testClusterClient ) GetCluster (clusterName , namespace string ) (* clusterv1.Cluster , error ) {
@@ -273,18 +272,6 @@ func (c *testClusterClient) DeleteClusters(ns string) error {
273
272
return nil
274
273
}
275
274
276
- func (c * testClusterClient ) DeleteMachineClasses (ns string ) error {
277
- if c .DeleteMachineClassesErr != nil {
278
- return c .DeleteMachineClassesErr
279
- }
280
- if ns == "" {
281
- c .machineClasses = make (map [string ][]* clusterv1.MachineClass )
282
- } else {
283
- delete (c .machineClasses , ns )
284
- }
285
- return nil
286
- }
287
-
288
275
func (c * testClusterClient ) DeleteMachineDeployments (ns string ) error {
289
276
if c .DeleteMachineDeploymentsErr != nil {
290
277
return c .DeleteMachineDeploymentsErr
@@ -490,21 +477,6 @@ func (c *testClusterClient) WaitForResourceStatuses() error {
490
477
return nil
491
478
}
492
479
493
- // TODO: implement GetMachineClasses for testClusterClient and add tests
494
- func (c * testClusterClient ) GetMachineClasses (namespace string ) ([]* clusterv1.MachineClass , error ) {
495
- return c .machineClasses [namespace ], c .GetMachineClassesErr
496
- }
497
-
498
- // TODO: implement CreateMachineClass for testClusterClient and add tests
499
- func (c * testClusterClient ) CreateMachineClass (* clusterv1.MachineClass ) error {
500
- return errors .Errorf ("CreateMachineClass Not yet implemented." )
501
- }
502
-
503
- // TODO: implement DeleteMachineClass for testClusterClient and add tests
504
- func (c * testClusterClient ) DeleteMachineClass (namespace , name string ) error {
505
- return errors .Errorf ("DeleteMachineClass Not yet implemented." )
506
- }
507
-
508
480
func contains (s []string , e string ) bool {
509
481
exists := false
510
482
for _ , existingNs := range s {
@@ -702,7 +674,7 @@ func TestClusterCreate(t *testing.T) {
702
674
{
703
675
name : "fail waiting for api ready on bootstrap cluster" ,
704
676
targetClient : & testClusterClient {ApplyFunc : func (yaml string ) error { return nil }},
705
- bootstrapClient : & testClusterClient {WaitForClusterV1alpha1ReadyErr : errors .New ("Test failure" )},
677
+ bootstrapClient : & testClusterClient {WaitForClusterV1alpha2ReadyErr : errors .New ("Test failure" )},
706
678
namespaceToExpectedInternalMachines : make (map [string ]int ),
707
679
namespaceToInputCluster : map [string ][]* clusterv1.Cluster {metav1 .NamespaceDefault : getClustersForNamespace (metav1 .NamespaceDefault , 1 )},
708
680
cleanupExternal : true ,
@@ -771,7 +743,7 @@ func TestClusterCreate(t *testing.T) {
771
743
},
772
744
{
773
745
name : "fail wait for api ready on target cluster" ,
774
- targetClient : & testClusterClient {WaitForClusterV1alpha1ReadyErr : errors .New ("Test failure" )},
746
+ targetClient : & testClusterClient {WaitForClusterV1alpha2ReadyErr : errors .New ("Test failure" )},
775
747
bootstrapClient : & testClusterClient {},
776
748
namespaceToExpectedInternalMachines : make (map [string ]int ),
777
749
namespaceToInputCluster : map [string ][]* clusterv1.Cluster {metav1 .NamespaceDefault : getClustersForNamespace (metav1 .NamespaceDefault , 1 )},
@@ -1376,9 +1348,6 @@ func TestClusterDelete(t *testing.T) {
1376
1348
for _ , machineSets := range testCase .bootstrapClient .machineSets {
1377
1349
bootstrapMachineSets = bootstrapMachineSets + len (machineSets )
1378
1350
}
1379
- for _ , machineClasses := range testCase .bootstrapClient .machineClasses {
1380
- bootstrapMachineClasses = bootstrapMachineClasses + len (machineClasses )
1381
- }
1382
1351
for _ , clusters := range testCase .targetClient .clusters {
1383
1352
targetClusters = targetClusters + len (clusters )
1384
1353
}
@@ -1391,9 +1360,6 @@ func TestClusterDelete(t *testing.T) {
1391
1360
for _ , machineSets := range testCase .targetClient .machineSets {
1392
1361
targetMachineSets = targetMachineSets + len (machineSets )
1393
1362
}
1394
- for _ , machineClasses := range testCase .targetClient .machineClasses {
1395
- targetMachineClasses = targetMachineClasses + len (machineClasses )
1396
- }
1397
1363
1398
1364
if bootstrapClusters != 0 {
1399
1365
t .Fatalf ("Unexpected Cluster count in bootstrap cluster. Got: %d, Want: 0" , bootstrapClusters )
@@ -1434,10 +1400,8 @@ func generateTestControlPlaneMachines(cluster *clusterv1.Cluster, ns string, nam
1434
1400
machines := make ([]* clusterv1.Machine , 0 , len (names ))
1435
1401
for _ , name := range names {
1436
1402
machine := generateTestNodeMachine (cluster , ns , name )
1437
- machine .Spec = clusterv1.MachineSpec {
1438
- Versions : clusterv1.MachineVersionInfo {
1439
- ControlPlane : "1.10.1" ,
1440
- },
1403
+ machine .ObjectMeta .Labels = map [string ]string {
1404
+ clusterv1 .MachineControlPlaneLabelName : "true" ,
1441
1405
}
1442
1406
machines = append (machines , machine )
1443
1407
}
0 commit comments