@@ -14,6 +14,7 @@ import (
1414 "time"
1515
1616 "github.com/stretchr/testify/require"
17+ corev1 "k8s.io/api/core/v1"
1718 "k8s.io/apimachinery/pkg/types"
1819 gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
1920 "sigs.k8s.io/gateway-api/conformance/utils/http"
@@ -151,32 +152,36 @@ var BackendHealthCheckWithOverrideTest = suite.ConformanceTest{
151152 Description : "Test backend health check with override configuration" ,
152153 Manifests : []string {"testdata/backend-health-check-with-override.yaml" },
153154 Test : func (t * testing.T , suite * suite.ConformanceTestSuite ) {
154- t .Run ("health check with override" , func (t * testing.T ) {
155+ ns := "gateway-conformance-infra"
156+ withOverrideRouteNN := types.NamespacedName {Name : "httproute-with-health-check-override" , Namespace : ns }
157+ withoutOverrideRouteNN := types.NamespacedName {Name : "httproute-without-health-check-override" , Namespace : ns }
158+ gtwName := "same-namespace"
159+ gwNN := types.NamespacedName {Name : gtwName , Namespace : ns }
160+ gwAddr := kubernetes .GatewayAndHTTPRoutesMustBeAccepted (t , suite .Client , suite .TimeoutConfig , suite .ControllerName ,
161+ kubernetes .NewGatewayRef (gwNN ), withOverrideRouteNN , withoutOverrideRouteNN )
162+
163+ ancestorRef := gwapiv1.ParentReference {
164+ Group : gatewayapi .GroupPtr (gwapiv1 .GroupName ),
165+ Kind : gatewayapi .KindPtr (resource .KindGateway ),
166+ Namespace : gatewayapi .NamespacePtr (gwNN .Namespace ),
167+ Name : gwapiv1 .ObjectName (gwNN .Name ),
168+ }
169+ BackendTrafficPolicyMustBeAccepted (t , suite .Client , types.NamespacedName {Name : "btp-with-health-check-override" , Namespace : ns }, suite .ControllerName , ancestorRef )
170+ BackendTrafficPolicyMustBeAccepted (t , suite .Client , types.NamespacedName {Name : "btp-without-health-check-override" , Namespace : ns }, suite .ControllerName , ancestorRef )
171+
172+ // Wait for the service pods to be ready
173+ WaitForPods (t , suite .Client , ns , map [string ]string {"app" : "multi-ports-backend" }, corev1 .PodRunning , & PodReady )
174+ WaitForPods (t , suite .Client , ns , map [string ]string {"app" : "single-port-backend" }, corev1 .PodRunning , & PodReady )
175+
176+ t .Run ("health checks work with and without health check overrides" , func (t * testing.T ) {
155177 ctx := context .Background ()
156- ns := "gateway-conformance-infra"
157- withOverrideRouteNN := types.NamespacedName {Name : "httproute-with-health-check-override" , Namespace : ns }
158- withoutOverrideRouteNN := types.NamespacedName {Name : "httproute-without-health-check-override" , Namespace : ns }
159- gwNN := types.NamespacedName {Name : "same-namespace" , Namespace : ns }
160- gwAddr := kubernetes .GatewayAndHTTPRoutesMustBeAccepted (t , suite .Client , suite .TimeoutConfig , suite .ControllerName ,
161- kubernetes .NewGatewayRef (gwNN ), withOverrideRouteNN , withoutOverrideRouteNN )
162-
163- ancestorRef := gwapiv1.ParentReference {
164- Group : gatewayapi .GroupPtr (gwapiv1 .GroupName ),
165- Kind : gatewayapi .KindPtr (resource .KindGateway ),
166- Namespace : gatewayapi .NamespacePtr (gwNN .Namespace ),
167- Name : gwapiv1 .ObjectName (gwNN .Name ),
168- }
169- BackendTrafficPolicyMustBeAccepted (t , suite .Client , types.NamespacedName {Name : "btp-with-health-check-override" , Namespace : ns }, suite .ControllerName , ancestorRef )
170- BackendTrafficPolicyMustBeAccepted (t , suite .Client , types.NamespacedName {Name : "btp-without-health-check-override" , Namespace : ns }, suite .ControllerName , ancestorRef )
171-
172178 promClient , err := prometheus .NewClient (suite .Client ,
173179 types.NamespacedName {Name : "prometheus" , Namespace : "monitoring" },
174180 )
175181 require .NoError (t , err )
176182
177183 withOverrideClusterName := fmt .Sprintf ("httproute/%s/%s/rule/0" , ns , withOverrideRouteNN .Name )
178184 withoutOverrideClusterName := fmt .Sprintf ("httproute/%s/%s/rule/0" , ns , withoutOverrideRouteNN .Name )
179- gtwName := "same-namespace"
180185
181186 // both routes should have successful health checks
182187 withOverridePromQL := fmt .Sprintf (`envoy_cluster_health_check_success{envoy_cluster_name="%s",gateway_envoyproxy_io_owning_gateway_name="%s"}` , withOverrideClusterName , gtwName )
0 commit comments