@@ -29,7 +29,9 @@ import (
29
29
"sigs.k8s.io/gateway-api/pkg/features"
30
30
31
31
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
32
+ "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/config"
32
33
k8sutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes"
34
+ trafficutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/traffic"
33
35
)
34
36
35
37
func init () {
@@ -46,59 +48,115 @@ var InferencePoolParentStatus = suite.ConformanceTest{
46
48
},
47
49
Test : func (t * testing.T , s * suite.ConformanceTestSuite ) {
48
50
const (
49
- appBackendNamespace = "gateway-conformance-app-backend"
50
- infraNamespace = "gateway-conformance-infra"
51
- poolName = "multi-gateway-pool"
52
- sharedGateway1Name = "conformance-gateway"
53
- sharedGateway2Name = "conformance-secondary-gateway"
54
- httpRoute1Name = "httproute-for-gw1"
55
- httpRoute2Name = "httproute-for-gw2"
51
+ appBackendNamespace = "gateway-conformance-app-backend"
52
+ infraNamespace = "gateway-conformance-infra"
53
+ poolName = "multi-gateway-pool"
54
+ sharedPrimaryGatewayName = "conformance-gateway"
55
+ sharedSecondaryGatewayName = "conformance-secondary-gateway"
56
+ httpRoutePrimaryName = "httproute-for-primary-gw"
57
+ httpRouteSecondaryName = "httproute-for-secondary-gw"
58
+ hostnamePrimaryGw = "primary.example.com"
59
+ pathPrimaryGw = "/primary-gateway-test"
60
+ hostnameSecondaryGw = "secondary.example.com"
61
+ pathSecondaryGw = "/secondary-gateway-test"
62
+ backendServicePodName = "infra-backend-deployment"
56
63
)
57
64
58
65
poolNN := types.NamespacedName {Name : poolName , Namespace : appBackendNamespace }
59
- httpRoute1NN := types.NamespacedName {Name : httpRoute1Name , Namespace : appBackendNamespace }
60
- httpRoute2NN := types.NamespacedName {Name : httpRoute2Name , Namespace : appBackendNamespace }
61
- gateway1NN := types.NamespacedName {Name : sharedGateway1Name , Namespace : infraNamespace }
62
- gateway2NN := types.NamespacedName {Name : sharedGateway2Name , Namespace : infraNamespace }
66
+ httpRoutePrimaryNN := types.NamespacedName {Name : httpRoutePrimaryName , Namespace : appBackendNamespace }
67
+ httpRouteSecondaryNN := types.NamespacedName {Name : httpRouteSecondaryName , Namespace : appBackendNamespace }
68
+ gatewayPrimaryNN := types.NamespacedName {Name : sharedPrimaryGatewayName , Namespace : infraNamespace }
69
+ gatewaySecondaryNN := types.NamespacedName {Name : sharedSecondaryGatewayName , Namespace : infraNamespace }
63
70
64
- k8sutils .HTTPRouteMustBeAcceptedAndResolved (t , s .Client , s .TimeoutConfig , httpRoute1NN , gateway1NN )
65
- k8sutils .HTTPRouteMustBeAcceptedAndResolved (t , s .Client , s .TimeoutConfig , httpRoute2NN , gateway2NN )
71
+ inferenceTimeoutConfig := config .DefaultInferenceExtensionTimeoutConfig ()
66
72
67
- t .Run ("InferencePool should show Accepted:True by parents when referenced by multiple HTTPRoutes" , func (t * testing.T ) {
73
+ k8sutils .HTTPRouteMustBeAcceptedAndResolved (t , s .Client , s .TimeoutConfig , httpRoutePrimaryNN , gatewayPrimaryNN )
74
+ k8sutils .HTTPRouteMustBeAcceptedAndResolved (t , s .Client , s .TimeoutConfig , httpRouteSecondaryNN , gatewaySecondaryNN )
75
+
76
+ gwPrimaryAddr := k8sutils .GetGatewayEndpoint (t , s .Client , s .TimeoutConfig , gatewayPrimaryNN )
77
+ gwSecondaryAddr := k8sutils .GetGatewayEndpoint (t , s .Client , s .TimeoutConfig , gatewaySecondaryNN )
78
+
79
+ t .Run ("InferencePool should show Accepted:True by parents and be routable via multiple HTTPRoutes" , func (t * testing.T ) {
68
80
k8sutils .InferencePoolMustBeAcceptedByParent (t , s .Client , poolNN )
69
- // TODO(#865) ensure requests are correctly routed to this InferencePool.
70
81
t .Logf ("InferencePool %s has parent status Accepted:True as expected with two references." , poolNN .String ())
82
+
83
+ trafficutils .MakeRequestAndExpectSuccess (
84
+ t ,
85
+ s .RoundTripper ,
86
+ s .TimeoutConfig ,
87
+ gwPrimaryAddr ,
88
+ hostnamePrimaryGw ,
89
+ pathPrimaryGw ,
90
+ backendServicePodName ,
91
+ appBackendNamespace ,
92
+ )
93
+
94
+ trafficutils .MakeRequestAndExpectSuccess (
95
+ t ,
96
+ s .RoundTripper ,
97
+ s .TimeoutConfig ,
98
+ gwSecondaryAddr ,
99
+ hostnameSecondaryGw ,
100
+ pathSecondaryGw ,
101
+ backendServicePodName ,
102
+ appBackendNamespace ,
103
+ )
71
104
})
72
105
73
- t .Run ("Delete httproute-for-gw1 " , func (t * testing.T ) {
74
- httproute1 := & gatewayv1.HTTPRoute {
75
- ObjectMeta : metav1.ObjectMeta {Name : httpRoute1NN .Name , Namespace : httpRoute1NN .Namespace },
106
+ t .Run ("Delete httproute-for-primary-gw and verify InferencePool status and routing via secondary gw " , func (t * testing.T ) {
107
+ httpRoutePrimary := & gatewayv1.HTTPRoute {
108
+ ObjectMeta : metav1.ObjectMeta {Name : httpRoutePrimaryNN .Name , Namespace : httpRoutePrimaryNN .Namespace },
76
109
}
77
- t .Logf ("Deleting HTTPRoute %s" , httpRoute1NN .String ())
78
- require .NoError (t , s .Client .Delete (context .TODO (), httproute1 ), "failed to delete httproute-for-gw1" )
79
- time .Sleep (s .TimeoutConfig .GatewayMustHaveCondition )
80
- })
110
+ t .Logf ("Deleting HTTPRoute %s" , httpRoutePrimaryNN .String ())
111
+ require .NoError (t , s .Client .Delete (context .TODO (), httpRoutePrimary ), "failed to delete httproute-for-primary-gw" )
112
+
113
+ t .Logf ("Waiting for %v for Gateway conditions to update after deleting HTTPRoute %s" , inferenceTimeoutConfig .HTTPRouteDeletionReconciliationTimeout , httpRoutePrimaryNN .String ()) //
114
+ time .Sleep (inferenceTimeoutConfig .HTTPRouteDeletionReconciliationTimeout ) //
81
115
82
- t .Run ("InferencePool should still show Accepted:True by parent after one HTTPRoute is deleted" , func (t * testing.T ) {
83
116
k8sutils .InferencePoolMustBeAcceptedByParent (t , s .Client , poolNN )
84
- // TODO(#865) ensure requests are correctly routed to this InferencePool.
85
117
t .Logf ("InferencePool %s still has parent status Accepted:True as expected with one reference remaining." , poolNN .String ())
118
+
119
+ trafficutils .MakeRequestAndExpectSuccess (
120
+ t ,
121
+ s .RoundTripper ,
122
+ s .TimeoutConfig ,
123
+ gwSecondaryAddr ,
124
+ hostnameSecondaryGw ,
125
+ pathSecondaryGw ,
126
+ backendServicePodName ,
127
+ appBackendNamespace ,
128
+ )
129
+
130
+ trafficutils .MakeRequestAndExpectNotFound (
131
+ t ,
132
+ s .RoundTripper ,
133
+ s .TimeoutConfig ,
134
+ gwPrimaryAddr ,
135
+ hostnamePrimaryGw ,
136
+ pathPrimaryGw ,
137
+ )
86
138
})
87
139
88
- t .Run ("Delete httproute-for-gw2 " , func (t * testing.T ) {
89
- httproute2 := & gatewayv1.HTTPRoute {
90
- ObjectMeta : metav1.ObjectMeta {Name : httpRoute2NN .Name , Namespace : httpRoute2NN .Namespace },
140
+ t .Run ("Delete httproute-for-secondary-gw and verify InferencePool has no parent statuses and is not routable " , func (t * testing.T ) {
141
+ httpRouteSecondary := & gatewayv1.HTTPRoute {
142
+ ObjectMeta : metav1.ObjectMeta {Name : httpRouteSecondaryNN .Name , Namespace : httpRouteSecondaryNN .Namespace },
91
143
}
92
- t .Logf ("Deleting HTTPRoute %s" , httpRoute2NN .String ())
93
- require .NoError (t , s .Client .Delete (context .TODO (), httproute2 ), "failed to delete httproute-for-gw2" )
94
- })
144
+ t .Logf ("Deleting HTTPRoute %s" , httpRouteSecondaryNN .String ())
145
+ require .NoError (t , s .Client .Delete (context .TODO (), httpRouteSecondary ), "failed to delete httproute-for-secondary-gw" )
95
146
96
- t .Run ("InferencePool should have no parent statuses after all HTTPRoutes are deleted" , func (t * testing.T ) {
97
- t .Logf ("Waiting for InferencePool %s to have no parent statuses." , poolNN .String ())
98
147
k8sutils .InferencePoolMustHaveNoParents (t , s .Client , poolNN )
99
148
t .Logf ("InferencePool %s correctly shows no parent statuses, indicating it's no longer referenced." , poolNN .String ())
149
+
150
+ trafficutils .MakeRequestAndExpectNotFound (
151
+ t ,
152
+ s .RoundTripper ,
153
+ s .TimeoutConfig ,
154
+ gwSecondaryAddr ,
155
+ hostnameSecondaryGw ,
156
+ pathSecondaryGw ,
157
+ )
100
158
})
101
159
102
- t .Logf ("InferencePoolResolvedRefsCondition completed." )
160
+ t .Logf ("InferencePoolResolvedRefsCondition test completed." )
103
161
},
104
162
}
0 commit comments