@@ -603,6 +603,70 @@ func TestService_createOrGetInternalAddress(t *testing.T) {
603
603
},
604
604
sharedVPC : true ,
605
605
},
606
+ {
607
+ name : "static address set for internal load balancer" ,
608
+ scope : func (s * scope.ClusterScope ) Scope {
609
+ s .GCPCluster .Spec .LoadBalancer = infrav1.LoadBalancerSpec {
610
+ LoadBalancerType : & lbTypeInternal ,
611
+ }
612
+
613
+ s .GCPCluster .Spec .LoadBalancer .InternalLoadBalancer .IPAddress = ptr .To ("1.2.3.4" )
614
+ return s
615
+ },
616
+
617
+ lbName : infrav1 .InternalRoleTagValue ,
618
+ mockAddress : & cloud.MockAddresses {
619
+ ProjectRouter : & cloud.SingleProjectRouter {ID : "proj-id" },
620
+ Objects : map [meta.Key ]* cloud.MockAddressesObj {},
621
+ },
622
+ mockSubnetworks : & cloud.MockSubnetworks {
623
+ ProjectRouter : & cloud.SingleProjectRouter {ID : "my-proj" },
624
+ Objects : map [meta.Key ]* cloud.MockSubnetworksObj {
625
+ * meta .RegionalKey ("control-plane" , "us-central1" ): {},
626
+ },
627
+ },
628
+ want : & compute.Address {
629
+ Address : "1.2.3.4" ,
630
+ IpVersion : "IPV4" ,
631
+ Name : "my-cluster-api-internal" ,
632
+ Region : "us-central1" ,
633
+ SelfLink : "https://www.googleapis.com/compute/v1/projects/proj-id/regions/us-central1/addresses/my-cluster-api-internal" ,
634
+ AddressType : "INTERNAL" ,
635
+ Purpose : "GCE_ENDPOINT" ,
636
+ },
637
+ },
638
+ {
639
+ name : "static address set for internal load balancer using SharedVPC subnet (should create address)" ,
640
+ scope : func (s * scope.ClusterScope ) Scope {
641
+ s .GCPCluster .Spec .LoadBalancer = infrav1.LoadBalancerSpec {
642
+ LoadBalancerType : & lbTypeInternal ,
643
+ }
644
+
645
+ s .GCPCluster .Spec .LoadBalancer .InternalLoadBalancer .IPAddress = ptr .To ("1.2.3.4" )
646
+ return s
647
+ },
648
+ lbName : infrav1 .InternalRoleTagValue ,
649
+ mockAddress : & cloud.MockAddresses {
650
+ ProjectRouter : & cloud.SingleProjectRouter {ID : "proj-id" },
651
+ Objects : map [meta.Key ]* cloud.MockAddressesObj {},
652
+ },
653
+ mockSubnetworks : & cloud.MockSubnetworks {
654
+ ProjectRouter : & cloud.SingleProjectRouter {ID : "proj-id" },
655
+ Objects : map [meta.Key ]* cloud.MockSubnetworksObj {
656
+ * meta .RegionalKey ("control-plane" , "us-central1" ): {},
657
+ },
658
+ },
659
+ want : & compute.Address {
660
+ Address : "1.2.3.4" ,
661
+ IpVersion : "IPV4" ,
662
+ Name : "my-cluster-api-internal" ,
663
+ Region : "us-central1" ,
664
+ SelfLink : "https://www.googleapis.com/compute/v1/projects/proj-id/regions/us-central1/addresses/my-cluster-api-internal" ,
665
+ AddressType : "INTERNAL" ,
666
+ Purpose : "GCE_ENDPOINT" ,
667
+ },
668
+ sharedVPC : true ,
669
+ },
606
670
}
607
671
for _ , tt := range tests {
608
672
t .Run (tt .name , func (t * testing.T ) {
0 commit comments