Skip to content

Commit daacbf5

Browse files
committed
test: Add tests for zone-redundant load balancers
- Add unit tests for zone configuration on frontend IPs - Add E2E test for zone-redundant LB verification - Add apiserver-ilb-zones flavor for E2E testing
1 parent 4a09fe5 commit daacbf5

File tree

10 files changed

+872
-0
lines changed

10 files changed

+872
-0
lines changed

azure/services/loadbalancers/loadbalancers_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,30 @@ var (
111111
APIServerPort: 6443,
112112
}
113113

114+
fakeInternalAPILBSpecWithZones = LBSpec{
115+
Name: "my-private-lb",
116+
ResourceGroup: "my-rg",
117+
SubscriptionID: "123",
118+
ClusterName: "my-cluster",
119+
Location: "my-location",
120+
Role: infrav1.APIServerRole,
121+
Type: infrav1.Internal,
122+
SKU: infrav1.SKUStandard,
123+
SubnetName: "my-cp-subnet",
124+
BackendPoolName: "my-private-lb-backendPool",
125+
IdleTimeoutInMinutes: ptr.To[int32](4),
126+
AvailabilityZones: []string{"1", "2", "3"},
127+
FrontendIPConfigs: []infrav1.FrontendIP{
128+
{
129+
Name: "my-private-lb-frontEnd",
130+
FrontendIPClass: infrav1.FrontendIPClass{
131+
PrivateIPAddress: "10.0.0.10",
132+
},
133+
},
134+
},
135+
APIServerPort: 6443,
136+
}
137+
114138
fakeNodeOutboundLBSpec = LBSpec{
115139
Name: "my-cluster",
116140
ResourceGroup: "my-rg",

azure/services/loadbalancers/spec_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,22 @@ func TestParameters(t *testing.T) {
178178
},
179179
expectedError: "",
180180
},
181+
{
182+
name: "internal load balancer with availability zones",
183+
spec: &fakeInternalAPILBSpecWithZones,
184+
existing: nil,
185+
expect: func(g *WithT, result interface{}) {
186+
g.Expect(result).To(BeAssignableToTypeOf(armnetwork.LoadBalancer{}))
187+
lb := result.(armnetwork.LoadBalancer)
188+
// Verify zones are set on frontend IP configuration
189+
g.Expect(lb.Properties.FrontendIPConfigurations).To(HaveLen(1))
190+
g.Expect(lb.Properties.FrontendIPConfigurations[0].Zones).To(HaveLen(3))
191+
g.Expect(*lb.Properties.FrontendIPConfigurations[0].Zones[0]).To(Equal("1"))
192+
g.Expect(*lb.Properties.FrontendIPConfigurations[0].Zones[1]).To(Equal("2"))
193+
g.Expect(*lb.Properties.FrontendIPConfigurations[0].Zones[2]).To(Equal("3"))
194+
},
195+
expectedError: "",
196+
},
181197
}
182198
for _, tc := range testcases {
183199
t.Run(tc.name, func(t *testing.T) {

templates/cluster-template-apiserver-ilb-zones.yaml

Lines changed: 225 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: default
4+
resources:
5+
- ../apiserver-ilb
6+
7+
patches:
8+
- path: patches/lb-zones.yaml
9+
10+
sortOptions:
11+
order: fifo
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
2+
kind: AzureCluster
3+
metadata:
4+
name: ${CLUSTER_NAME}
5+
spec:
6+
networkSpec:
7+
apiServerLB:
8+
availabilityZones:
9+
- "1"
10+
- "2"
11+
- "3"

0 commit comments

Comments
 (0)