119119 kubectl delete --ignore-not-found -f " $BATS_TEST_DIRNAME " /../examples/gateway_httproute_simple.yaml
120120}
121121
122+ @test " Gateway: Multiple HTTP Listeners on Same Port with enable-lb-port-mapping" {
123+ # Apply a Gateway with two HTTP listeners on the same port (443) with different
124+ # hostnames. This reproduces the bug where duplicate --publish=443/tcp args
125+ # caused Docker to fail with exit status 125.
126+ kubectl apply -f " $BATS_TEST_DIRNAME " /../examples/gateway_https_multi_listener.yaml
127+
128+ # Wait for the backend application pod to be ready
129+ kubectl wait --for=condition=ready pods -l app=MultiListenerApp --timeout=60s
130+
131+ # Retry loop to get the Gateway's external IP address
132+ for i in {1..10}
133+ do
134+ IP=$( kubectl get gateway multi-listener-gateway --output jsonpath=' {.status.addresses[0].value}' 2> /dev/null)
135+ [[ ! -z " $IP " ]] && break || sleep 1
136+ done
137+ if [[ -z " $IP " ]]; then
138+ echo " Failed to get Gateway IP address"
139+ return 1
140+ fi
141+ echo " Gateway IP: $IP "
142+
143+ # Verify the gateway container is reachable (if duplicates existed, container creation would have failed)
144+ for i in {1..10}
145+ do
146+ HOSTNAME=$( curl -s --connect-timeout 5 http://${IP} /hostname -H " Host: route.multi-listener.test" || true)
147+ [[ ! -z " $HOSTNAME " ]] && break || sleep 1
148+ done
149+ if [[ -z " $HOSTNAME " ]]; then
150+ echo " Failed to get hostname via Gateway"
151+ return 1
152+ fi
153+ echo " Hostname via Gateway: $HOSTNAME "
154+
155+ # Cleanup
156+ kubectl delete --ignore-not-found -f " $BATS_TEST_DIRNAME " /../examples/gateway_https_multi_listener.yaml
157+ }
158+
159+
122160
123161@test " Ingress to Gateway Migration and X-Forwarded-For Header" {
124162 # Apply the Gateway and HTTPRoute manifests
258296 kubectl delete deployment ws-echo
259297 kubectl delete service ws-service
260298 kubectl delete ingress ws-ingress
261- }
299+ }
0 commit comments