@@ -117,30 +117,71 @@ func TestExecuteBaseHttp_NginxReadinessProbePort(t *testing.T) {
117117 },
118118 }
119119
120- customConfig := dataplane.Configuration {
120+ customPortConfig := dataplane.Configuration {
121121 BaseHTTPConfig : dataplane.BaseHTTPConfig {
122122 NginxReadinessProbePort : 9090 ,
123123 },
124124 }
125125
126+ customIPv4Config := dataplane.Configuration {
127+ BaseHTTPConfig : dataplane.BaseHTTPConfig {
128+ NginxReadinessProbePort : dataplane .DefaultNginxReadinessProbePort ,
129+ IPFamily : dataplane .IPv4 ,
130+ },
131+ }
132+
133+ customIPv6Config := dataplane.Configuration {
134+ BaseHTTPConfig : dataplane.BaseHTTPConfig {
135+ NginxReadinessProbePort : dataplane .DefaultNginxReadinessProbePort ,
136+ IPFamily : dataplane .IPv6 ,
137+ },
138+ }
139+
126140 tests := []struct {
127- name string
128- expectedPort string
129- expectedListen string
130- conf dataplane.Configuration
141+ name string
142+ expectedPort string
143+ expectedListen string
144+ expectedNoListen string
145+ conf dataplane.Configuration
131146 }{
132147 {
133148 name : "default nginx readiness probe port" ,
134149 conf : defaultConfig ,
135150 expectedPort : "8081" ,
136151 expectedListen : "listen 8081;" ,
137152 },
153+ {
154+ name : "default nginx readiness probe port on ipv6" ,
155+ conf : defaultConfig ,
156+ expectedPort : "8081" ,
157+ expectedListen : "listen [::]:8081;" ,
158+ },
138159 {
139160 name : "custom nginx readiness probe 9090" ,
140- conf : customConfig ,
161+ conf : customPortConfig ,
141162 expectedPort : "9090" ,
142163 expectedListen : "listen 9090;" ,
143164 },
165+ {
166+ name : "custom nginx readiness probe 9090 on ipv6" ,
167+ conf : customPortConfig ,
168+ expectedPort : "9090" ,
169+ expectedListen : "listen [::]:9090;" ,
170+ },
171+ {
172+ name : "custom ipv4 nginx readiness probe does not have ipv6 listen" ,
173+ conf : customIPv4Config ,
174+ expectedPort : "8081" ,
175+ expectedListen : "listen 8081;" ,
176+ expectedNoListen : "listen [::]:8081;" ,
177+ },
178+ {
179+ name : "custom ipv6 nginx readiness probe does not have ipv4 listen" ,
180+ conf : customIPv6Config ,
181+ expectedPort : "8081" ,
182+ expectedListen : "listen [::]:8081;" ,
183+ expectedNoListen : "listen 8081;" ,
184+ },
144185 }
145186
146187 for _ , test := range tests {
@@ -156,6 +197,11 @@ func TestExecuteBaseHttp_NginxReadinessProbePort(t *testing.T) {
156197 // check that the listen directive contains the expected port
157198 g .Expect (httpConfig ).To (ContainSubstring (test .expectedListen ))
158199
200+ // check that an additional listen directive is NOT set
201+ if test .expectedNoListen != "" {
202+ g .Expect (httpConfig ).ToNot (ContainSubstring (test .expectedNoListen ))
203+ }
204+
159205 // check that the health check server block is present
160206 g .Expect (httpConfig ).To (ContainSubstring ("server {" ))
161207 g .Expect (httpConfig ).To (ContainSubstring ("access_log off;" ))
0 commit comments