Skip to content

Commit 26a93b3

Browse files
fix integration EE tests with Kong 3.11 (#7620)
* fix integration EE tests with Kong 3.11 Signed-off-by: Jintao Zhang <[email protected]> * chore(deps): update kong/kong-gateway docker tag to v3.11.0.0 --------- Signed-off-by: Jintao Zhang <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent 616c0fa commit 26a93b3

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

.github/test_dependencies.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ integration:
4646
# renovate: datasource=docker depName=kong versioning=docker
4747
kong-oss: '3.9.1'
4848
# renovate: datasource=docker depName=kong/kong-gateway versioning=docker
49-
kong-ee: '3.9.1.2'
49+
kong-ee: '3.11.0.0'
5050

5151
kongintegration:
5252
# renovate: datasource=docker depName=kong versioning=docker
5353
kong-oss: '3.9.1'
5454
# renovate: datasource=docker depName=kong/kong-gateway versioning=docker
55-
kong-ee: '3.9.1.2'
55+
kong-ee: '3.11.0.0'
5656

5757
envtests:
5858
# renovate: datasource=docker depName=kong/kong-gateway versioning=docker
59-
kong-ee: '3.9.1.2'
59+
kong-ee: '3.11.0.0'
6060
# This is a version of Kong Gateway that does not support sticky sessions,
6161
# all versions >= 3.11.0 support sticky sessions.
6262
kong-without-sticky-sessions: '3.9.1'

test/kongintegration/inmemory_update_strategy_test.go

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ func TestUpdateStrategyInMemory_PropagatesResourcesErrors(t *testing.T) {
9191
},
9292
}
9393
expectedMessage := "invalid path: value must be null"
94-
expectedRawErrBody := []byte(`{"code":14,"name":"invalid declarative configuration","fields":{},"message":"declarative config is invalid: {}","flattened_errors":[{"entity_type":"service","entity_name":"test-service","entity_tags":["k8s-name:test-service","k8s-namespace:default","k8s-kind:Service","k8s-uid:a3b8afcc-9f19-42e4-aa8f-5866168c2ad3","k8s-group:","k8s-version:v1"],"errors":[{"type":"field","message":"value must be null","field":"path"},{"type":"entity","message":"failed conditional validation given value of field 'protocol'"}],"entity":{"path":"/test","name":"test-service","protocol":"grpc","tags":["k8s-name:test-service","k8s-namespace:default","k8s-kind:Service","k8s-uid:a3b8afcc-9f19-42e4-aa8f-5866168c2ad3","k8s-group:","k8s-version:v1"],"host":"konghq.com","port":80}}]}`)
95-
expectedBody := map[string]any{}
96-
require.NoError(t, json.Unmarshal(expectedRawErrBody, &expectedBody))
94+
// We don't hardcode the expected response body as it can vary between Kong versions
95+
// Instead, we verify the essential structure and fields are present
9796

9897
require.EventuallyWithT(t, func(t *assert.CollectT) {
9998
configSize, err := sut.Update(ctx, faultyConfig)
@@ -131,12 +130,44 @@ func TestUpdateStrategyInMemory_PropagatesResourcesErrors(t *testing.T) {
131130
if diff := cmp.Diff(expectedCausingObjects, resourceErr.CausingObjects()); !assert.Empty(t, diff) {
132131
return
133132
}
133+
// Verify essential structure of the response body
134134
actualBody := map[string]any{}
135135
err = json.Unmarshal(updateError.RawResponseBody(), &actualBody)
136136
if !assert.NoError(t, err) {
137137
return
138138
}
139-
if diff := cmp.Diff(expectedBody, actualBody); !assert.Empty(t, diff) {
139+
140+
// Check for required fields in the error response
141+
if !assert.Contains(t, actualBody, "code") {
142+
return
143+
}
144+
if !assert.Contains(t, actualBody, "name") {
145+
return
146+
}
147+
if !assert.Contains(t, actualBody, "flattened_errors") {
148+
return
149+
}
150+
151+
// Verify the flattened_errors contains our test service
152+
flattenedErrors, ok := actualBody["flattened_errors"].([]any)
153+
if !assert.True(t, ok) {
154+
return
155+
}
156+
if !assert.NotEmpty(t, flattenedErrors) {
157+
return
158+
}
159+
160+
// Check that at least one error relates to our test service
161+
foundServiceError := false
162+
for _, errorItem := range flattenedErrors {
163+
if errorMap, ok := errorItem.(map[string]any); ok {
164+
if entityName, ok := errorMap["entity_name"].(string); ok && entityName == "test-service" {
165+
foundServiceError = true
166+
break
167+
}
168+
}
169+
}
170+
if !assert.True(t, foundServiceError, "Expected to find flattened error for test-service") {
140171
return
141172
}
142173
}, timeout, period)

test/kongintegration/kongupstreampolicy_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ func dropKongDefaults(upstream *kong.Upstream) *kong.Upstream {
327327
if upstream.HashOnCookiePath != nil && *upstream.HashOnCookiePath == "/" {
328328
upstream.HashOnCookiePath = nil
329329
}
330+
if upstream.StickySessionsCookiePath != nil && *upstream.StickySessionsCookiePath == "/" {
331+
upstream.StickySessionsCookiePath = nil
332+
}
330333
if upstream.UseSrvName != nil && *upstream.UseSrvName == false {
331334
upstream.UseSrvName = nil
332335
}

0 commit comments

Comments
 (0)