Skip to content

Commit 64c62ad

Browse files
feat(conformance): Add HTTPRouteMultipleGatewaysDifferentPools test (#838)
* copy of accepted inference pool test to start from. * add yaml file for the test * update time out * update the yaml file to add port 9002 * read timeout config from local repo * remove excess comments * copy from existing test to start with * update test and add gateway to main manifest * fix spelling error * correct spelling for scenarios * check route condition on RouteConditionResolvedRefs * check RouteConditionResolvedRefs instead of Reconciled * remove empty lines in yaml * set optional/defaulted fields as unspecified * add new line at the end of yaml files. * delete blank lines in yaml files. * change variable names to use primary / secondary * add to do for name change across the project. * fix comment * change all variable names to use primary/secondary consistantly * add to do for http route testing * HTTPRouteMustBeAcceptedAndResolved * add helper method. * using helper method for pool route accepted. * combline pool and route accpetnace * add http route validation * remove extra comments and yaml fields. * remove duplicate method * fix timeout * fix timeout * change varialbe names to use primary secondary consistently. * remove extra comments * factor out common code * Add actual http traffic validation using echo-basic * remove extra comments from manifest * remove modifiedTimeoutConfig.HTTPRouteMustHaveCondition per review comment. * remove modifiedTimeoutConfig.HTTPRouteMustHaveCondition per review comment * remove excessive logging from conformance.go * Update conformance/tests/basic/httproute_multiple_gateways_different_pools.yaml Co-authored-by: Lior Lieberman <[email protected]> * Update conformance/tests/basic/httproute_multiple_gateways_different_pools.yaml Co-authored-by: Lior Lieberman <[email protected]> * Update conformance/tests/basic/httproute_multiple_gateways_different_pools.yaml Co-authored-by: Lior Lieberman <[email protected]> * Update conformance/tests/basic/httproute_multiple_gateways_different_pools.yaml Co-authored-by: Lior Lieberman <[email protected]> * Update conformance/tests/basic/httproute_multiple_gateways_different_pools.yaml Co-authored-by: Lior Lieberman <[email protected]> * Remove unecessary logs for accpeted reason. * Remove all comments from yaml and go files and fix yaml * intermediate update * fix the test run * factor out common code * move epp def to shared manifest * remove extra comments * revert back to two epps * update to use epp filter * remove extra comments * add to do for epp image * switch to GeneralMustHaveConditionTimeout * undo gateway version changes * remove unused HTTPRouteMustHaveConditions * update doc string for GetPod * update docstring * fix defaults in timing.go * Remove resource type from names in manifests. * remove type from name * remove health check * add todo for combining getpod methods * remove duplicate methods * revert changes to conformance.go * revert chagnes to conformance.go * revert changes to helpers.go * use epp and pool from shared manifest * add todo to factor out common constants * remove port number for EPP call * remove port number for inf pool ref * use GetPodsWithLabel * removed unused method * fix routing issue * switch to using MakeRequestAndExpectEventuallyConsistentResponse * undo changes to GatewayFollowingEPPRouting * revert changes to traffic.go --------- Co-authored-by: Lior Lieberman <[email protected]>
1 parent 7df5d3d commit 64c62ad

File tree

2 files changed

+162
-0
lines changed

2 files changed

+162
-0
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package basic
18+
19+
import (
20+
"net/http"
21+
"testing"
22+
23+
"k8s.io/apimachinery/pkg/types"
24+
"sigs.k8s.io/gateway-api/conformance/utils/suite"
25+
26+
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
27+
k8sutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes"
28+
"sigs.k8s.io/gateway-api-inference-extension/conformance/utils/traffic"
29+
)
30+
31+
func init() {
32+
tests.ConformanceTests = append(tests.ConformanceTests, HTTPRouteMultipleGatewaysDifferentPools)
33+
}
34+
35+
var HTTPRouteMultipleGatewaysDifferentPools = suite.ConformanceTest{
36+
ShortName: "HTTPRouteMultipleGatewaysDifferentPools",
37+
Description: "Validates two HTTPRoutes on different Gateways successfully referencing different InferencePools and routes traffic accordingly.",
38+
Manifests: []string{"tests/basic/httproute_multiple_gateways_different_pools.yaml"},
39+
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
40+
const (
41+
appBackendNamespace = "gateway-conformance-app-backend"
42+
infraNamespace = "gateway-conformance-infra"
43+
44+
primaryGatewayName = "conformance-primary-gateway"
45+
routeForPrimaryGWName = "route-for-primary-gateway"
46+
primaryPoolName = "primary-inference-pool"
47+
primaryBackendPodName = "primary-inference-model-server"
48+
primaryRoutePath = "/test-primary-gateway"
49+
primaryRouteHostname = "primary.example.com"
50+
51+
secondaryGatewayName = "conformance-secondary-gateway"
52+
routeForSecondaryGWName = "route-for-secondary-gateway"
53+
secondaryPoolName = "secondary-inference-pool"
54+
secondaryBackendPodName = "secondary-inference-model-server"
55+
secondaryRoutePath = "/test-secondary-gateway"
56+
secondaryRouteHostname = "secondary.example.com"
57+
)
58+
59+
routeForPrimaryGWNN := types.NamespacedName{Name: routeForPrimaryGWName, Namespace: appBackendNamespace}
60+
routeForSecondaryGWNN := types.NamespacedName{Name: routeForSecondaryGWName, Namespace: appBackendNamespace}
61+
primaryPoolNN := types.NamespacedName{Name: primaryPoolName, Namespace: appBackendNamespace}
62+
secondaryPoolNN := types.NamespacedName{Name: secondaryPoolName, Namespace: appBackendNamespace}
63+
primaryGatewayNN := types.NamespacedName{Name: primaryGatewayName, Namespace: infraNamespace}
64+
secondaryGatewayNN := types.NamespacedName{Name: secondaryGatewayName, Namespace: infraNamespace}
65+
66+
t.Run("Primary HTTPRoute, InferencePool, and Gateway path: verify status and traffic", func(t *testing.T) {
67+
k8sutils.HTTPRouteAndInferencePoolMustBeAcceptedAndRouteAccepted(
68+
t,
69+
s.Client,
70+
routeForPrimaryGWNN,
71+
primaryGatewayNN,
72+
primaryPoolNN,
73+
)
74+
75+
primaryGwAddr := k8sutils.GetGatewayEndpoint(t, s.Client, s.TimeoutConfig, primaryGatewayNN)
76+
77+
traffic.MakeRequestAndExpectEventuallyConsistentResponse(
78+
t,
79+
s.RoundTripper,
80+
s.TimeoutConfig,
81+
primaryGwAddr,
82+
traffic.Request{
83+
Host: primaryRouteHostname,
84+
Path: primaryRoutePath,
85+
ExpectedStatusCode: http.StatusOK,
86+
Backend: primaryBackendPodName,
87+
Namespace: appBackendNamespace,
88+
},
89+
)
90+
})
91+
92+
t.Run("Secondary HTTPRoute, InferencePool, and Gateway path: verify status and traffic", func(t *testing.T) {
93+
k8sutils.HTTPRouteAndInferencePoolMustBeAcceptedAndRouteAccepted(
94+
t,
95+
s.Client,
96+
routeForSecondaryGWNN,
97+
secondaryGatewayNN,
98+
secondaryPoolNN,
99+
)
100+
101+
secondaryGwAddr := k8sutils.GetGatewayEndpoint(t, s.Client, s.TimeoutConfig, secondaryGatewayNN)
102+
103+
traffic.MakeRequestAndExpectEventuallyConsistentResponse(
104+
t,
105+
s.RoundTripper,
106+
s.TimeoutConfig,
107+
secondaryGwAddr,
108+
traffic.Request{
109+
Host: secondaryRouteHostname,
110+
Path: secondaryRoutePath,
111+
ExpectedStatusCode: http.StatusOK,
112+
Backend: secondaryBackendPodName,
113+
Namespace: appBackendNamespace,
114+
},
115+
)
116+
})
117+
},
118+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
apiVersion: gateway.networking.k8s.io/v1
3+
kind: HTTPRoute
4+
metadata:
5+
name: route-for-primary-gateway
6+
namespace: gateway-conformance-app-backend
7+
spec:
8+
parentRefs:
9+
- kind: Gateway
10+
name: conformance-primary-gateway
11+
namespace: gateway-conformance-infra
12+
hostnames:
13+
- "primary.example.com"
14+
rules:
15+
- backendRefs:
16+
- group: inference.networking.x-k8s.io
17+
kind: InferencePool
18+
name: primary-inference-pool
19+
matches:
20+
- path:
21+
type: PathPrefix
22+
value: /test-primary-gateway
23+
---
24+
apiVersion: gateway.networking.k8s.io/v1
25+
kind: HTTPRoute
26+
metadata:
27+
name: route-for-secondary-gateway
28+
namespace: gateway-conformance-app-backend
29+
spec:
30+
parentRefs:
31+
- kind: Gateway
32+
name: conformance-secondary-gateway
33+
namespace: gateway-conformance-infra
34+
hostnames:
35+
- "secondary.example.com"
36+
rules:
37+
- backendRefs:
38+
- group: inference.networking.x-k8s.io
39+
kind: InferencePool
40+
name: secondary-inference-pool
41+
matches:
42+
- path:
43+
type: PathPrefix
44+
value: /test-secondary-gateway

0 commit comments

Comments
 (0)