@@ -150,6 +150,7 @@ func TestIBMVPCClusterReconciler_reconcile(t *testing.T) {
150
150
}
151
151
clusterScope = & scope.ClusterScope {
152
152
IBMVPCClient : mockvpc ,
153
+ Cluster : & capiv1beta1.Cluster {},
153
154
Logger : klogr .New (),
154
155
IBMVPCCluster : & infrav1beta1.IBMVPCCluster {
155
156
ObjectMeta : metav1.ObjectMeta {
@@ -250,6 +251,36 @@ func TestIBMVPCClusterReconciler_reconcile(t *testing.T) {
250
251
g .Expect (clusterScope .IBMVPCCluster .Finalizers ).To (ContainElement (infrav1beta1 .ClusterFinalizer ))
251
252
g .Expect (clusterScope .IBMVPCCluster .Status .Ready ).To (Equal (true ))
252
253
})
254
+ t .Run ("Should use the user supplied port for the apiserver" , func (t * testing.T ) {
255
+ g := NewWithT (t )
256
+ setup (t )
257
+ t .Cleanup (teardown )
258
+ clusterScope .IBMVPCCluster .Finalizers = []string {infrav1beta1 .ClusterFinalizer }
259
+ port := int32 (412 )
260
+ clusterScope .Cluster .Spec .ClusterNetwork = & capiv1beta1.ClusterNetwork {APIServerPort : & port }
261
+ mockvpc .EXPECT ().ListVpcs (listVpcsOptions ).Return (vpclist , response , nil )
262
+ mockvpc .EXPECT ().ListFloatingIps (listFloatingIpsOptions ).Return (fips , response , nil )
263
+ mockvpc .EXPECT ().ListSubnets (options ).Return (subnets , response , nil )
264
+ _ , err := reconciler .reconcile (clusterScope )
265
+ g .Expect (err ).To (BeNil ())
266
+ g .Expect (clusterScope .IBMVPCCluster .Finalizers ).To (ContainElement (infrav1beta1 .ClusterFinalizer ))
267
+ g .Expect (clusterScope .IBMVPCCluster .Status .Ready ).To (Equal (true ))
268
+ g .Expect (clusterScope .IBMVPCCluster .Spec .ControlPlaneEndpoint .Port ).To (Equal (port ))
269
+ })
270
+ t .Run ("Should use the default port for the apiserver if not specified" , func (t * testing.T ) {
271
+ g := NewWithT (t )
272
+ setup (t )
273
+ t .Cleanup (teardown )
274
+ clusterScope .IBMVPCCluster .Finalizers = []string {infrav1beta1 .ClusterFinalizer }
275
+ mockvpc .EXPECT ().ListVpcs (listVpcsOptions ).Return (vpclist , response , nil )
276
+ mockvpc .EXPECT ().ListFloatingIps (listFloatingIpsOptions ).Return (fips , response , nil )
277
+ mockvpc .EXPECT ().ListSubnets (options ).Return (subnets , response , nil )
278
+ _ , err := reconciler .reconcile (clusterScope )
279
+ g .Expect (err ).To (BeNil ())
280
+ g .Expect (clusterScope .IBMVPCCluster .Finalizers ).To (ContainElement (infrav1beta1 .ClusterFinalizer ))
281
+ g .Expect (clusterScope .IBMVPCCluster .Status .Ready ).To (Equal (true ))
282
+ g .Expect (clusterScope .IBMVPCCluster .Spec .ControlPlaneEndpoint .Port ).To (Equal (int32 (6443 )))
283
+ })
253
284
})
254
285
}
255
286
0 commit comments