@@ -27,7 +27,7 @@ func TestUpdateGatewayStatusProgrammedCondition(t *testing.T) {
2727 gw * gwapiv1.Gateway
2828 svc * corev1.Service
2929 deployment * appsv1.Deployment
30- nodeAddresses [] string
30+ nodeAddresses NodeAddresses
3131 }
3232 tests := []struct {
3333 name string
@@ -52,6 +52,9 @@ func TestUpdateGatewayStatusProgrammedCondition(t *testing.T) {
5252 Spec : corev1.ServiceSpec {
5353 ClusterIPs : []string {"127.0.0.1" },
5454 Type : corev1 .ServiceTypeLoadBalancer ,
55+ IPFamilies : []corev1.IPFamily {
56+ corev1 .IPv4Protocol ,
57+ },
5558 },
5659 Status : corev1.ServiceStatus {
5760 LoadBalancer : corev1.LoadBalancerStatus {
@@ -81,6 +84,9 @@ func TestUpdateGatewayStatusProgrammedCondition(t *testing.T) {
8184 Spec : corev1.ServiceSpec {
8285 ClusterIPs : []string {"127.0.0.1" },
8386 Type : corev1 .ServiceTypeLoadBalancer ,
87+ IPFamilies : []corev1.IPFamily {
88+ corev1 .IPv4Protocol ,
89+ },
8490 },
8591 Status : corev1.ServiceStatus {
8692 LoadBalancer : corev1.LoadBalancerStatus {
@@ -114,6 +120,9 @@ func TestUpdateGatewayStatusProgrammedCondition(t *testing.T) {
114120 Spec : corev1.ServiceSpec {
115121 ClusterIPs : []string {"127.0.0.1" },
116122 Type : corev1 .ServiceTypeClusterIP ,
123+ IPFamilies : []corev1.IPFamily {
124+ corev1 .IPv4Protocol ,
125+ },
117126 },
118127 },
119128 },
@@ -127,13 +136,18 @@ func TestUpdateGatewayStatusProgrammedCondition(t *testing.T) {
127136 {
128137 name : "Nodeport svc" ,
129138 args : args {
130- gw : & gwapiv1.Gateway {},
131- nodeAddresses : []string {"1" , "2" },
139+ gw : & gwapiv1.Gateway {},
140+ nodeAddresses : NodeAddresses {
141+ IPv4 : []string {"1" , "2" },
142+ },
132143 svc : & corev1.Service {
133144 TypeMeta : metav1.TypeMeta {},
134145 ObjectMeta : metav1.ObjectMeta {},
135146 Spec : corev1.ServiceSpec {
136147 Type : corev1 .ServiceTypeNodePort ,
148+ IPFamilies : []corev1.IPFamily {
149+ corev1 .IPv4Protocol ,
150+ },
137151 },
138152 },
139153 },
@@ -153,9 +167,9 @@ func TestUpdateGatewayStatusProgrammedCondition(t *testing.T) {
153167 args : args {
154168 gw : & gwapiv1.Gateway {},
155169 // 20 node addresses
156- nodeAddresses : func () (addr [] string ) {
170+ nodeAddresses : func () (addr NodeAddresses ) {
157171 for i := 0 ; i < 20 ; i ++ {
158- addr = append (addr , strconv .Itoa (i ))
172+ addr . IPv4 = append (addr . IPv4 , strconv .Itoa (i ))
159173 }
160174 return
161175 }(),
@@ -164,6 +178,9 @@ func TestUpdateGatewayStatusProgrammedCondition(t *testing.T) {
164178 ObjectMeta : metav1.ObjectMeta {},
165179 Spec : corev1.ServiceSpec {
166180 Type : corev1 .ServiceTypeNodePort ,
181+ IPFamilies : []corev1.IPFamily {
182+ corev1 .IPv4Protocol ,
183+ },
167184 },
168185 },
169186 },
@@ -185,6 +202,9 @@ func TestUpdateGatewayStatusProgrammedCondition(t *testing.T) {
185202 svc : & corev1.Service {
186203 Spec : corev1.ServiceSpec {
187204 Type : corev1 .ServiceTypeLoadBalancer ,
205+ IPFamilies : []corev1.IPFamily {
206+ corev1 .IPv6Protocol ,
207+ },
188208 },
189209 Status : corev1.ServiceStatus {
190210 LoadBalancer : corev1.LoadBalancerStatus {
@@ -210,6 +230,9 @@ func TestUpdateGatewayStatusProgrammedCondition(t *testing.T) {
210230 Spec : corev1.ServiceSpec {
211231 ClusterIPs : []string {"2001:db8::2" },
212232 Type : corev1 .ServiceTypeClusterIP ,
233+ IPFamilies : []corev1.IPFamily {
234+ corev1 .IPv6Protocol ,
235+ },
213236 },
214237 },
215238 },
@@ -223,11 +246,16 @@ func TestUpdateGatewayStatusProgrammedCondition(t *testing.T) {
223246 {
224247 name : "Nodeport svc with IPv6 node addresses" ,
225248 args : args {
226- gw : & gwapiv1.Gateway {},
227- nodeAddresses : []string {"2001:db8::3" , "2001:db8::4" },
249+ gw : & gwapiv1.Gateway {},
250+ nodeAddresses : NodeAddresses {
251+ IPv6 : []string {"2001:db8::3" , "2001:db8::4" },
252+ },
228253 svc : & corev1.Service {
229254 Spec : corev1.ServiceSpec {
230255 Type : corev1 .ServiceTypeNodePort ,
256+ IPFamilies : []corev1.IPFamily {
257+ corev1 .IPv6Protocol ,
258+ },
231259 },
232260 },
233261 },
@@ -281,10 +309,34 @@ func TestUpdateGatewayStatusProgrammedCondition(t *testing.T) {
281309 },
282310 wantAddresses : []gwapiv1.GatewayStatusAddress {},
283311 },
312+ {
313+ name : "Nodeport svc Ipv6 with dual stack node addresses" ,
314+ args : args {
315+ gw : & gwapiv1.Gateway {},
316+ nodeAddresses : NodeAddresses {
317+ IPv4 : []string {"10.0.0.1" },
318+ IPv6 : []string {"2001:db8::4" },
319+ },
320+ svc : & corev1.Service {
321+ Spec : corev1.ServiceSpec {
322+ Type : corev1 .ServiceTypeNodePort ,
323+ IPFamilies : []corev1.IPFamily {
324+ corev1 .IPv6Protocol ,
325+ },
326+ },
327+ },
328+ },
329+ wantAddresses : []gwapiv1.GatewayStatusAddress {
330+ {
331+ Type : ptr .To (gwapiv1 .IPAddressType ),
332+ Value : "2001:db8::4" ,
333+ },
334+ },
335+ },
284336 }
285337 for _ , tt := range tests {
286338 t .Run (tt .name , func (t * testing.T ) {
287- UpdateGatewayStatusProgrammedCondition (tt .args .gw , tt .args .svc , tt .args .deployment , tt .args .nodeAddresses ... )
339+ UpdateGatewayStatusProgrammedCondition (tt .args .gw , tt .args .svc , tt .args .deployment , tt .args .nodeAddresses )
288340 assert .True (t , reflect .DeepEqual (tt .wantAddresses , tt .args .gw .Status .Addresses ))
289341 })
290342 }
0 commit comments