fix: Fix e2e 'request header control' and add some testcases (#352)

This commit is contained in:
WeixinX
2023-05-25 15:51:39 +08:00
committed by GitHub
parent 3e68ae75d1
commit 44637c2449
3 changed files with 148 additions and 5 deletions

View File

@@ -32,6 +32,12 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
testcases := []http.Assertion{
{
Meta: http.AssertionMeta{
TestCaseName: "case 1: add one",
TargetBackend: "infra-backend-v1",
TargetNamespace: "higress-conformance-infra",
},
Request: http.AssertionRequest{
ActualRequest: http.Request{
Path: "/foo1",
@@ -39,6 +45,8 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{
},
ExpectedRequest: &http.ExpectedRequest{
Request: http.Request{
Path: "/foo1",
Host: "foo.com",
Headers: map[string]string{
"stage": "test",
},
@@ -53,6 +61,12 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{
},
},
{
Meta: http.AssertionMeta{
TestCaseName: "case 2: add more",
TargetBackend: "infra-backend-v1",
TargetNamespace: "higress-conformance-infra",
},
Request: http.AssertionRequest{
ActualRequest: http.Request{
Path: "/foo2",
@@ -60,6 +74,8 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{
},
ExpectedRequest: &http.ExpectedRequest{
Request: http.Request{
Path: "/foo2",
Host: "foo.com",
Headers: map[string]string{
"stage": "test",
"canary": "true",
@@ -75,6 +91,12 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{
},
},
{
Meta: http.AssertionMeta{
TestCaseName: "case 3: update one",
TargetBackend: "infra-backend-v1",
TargetNamespace: "higress-conformance-infra",
},
Request: http.AssertionRequest{
ActualRequest: http.Request{
Path: "/foo3",
@@ -85,9 +107,10 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{
},
ExpectedRequest: &http.ExpectedRequest{
Request: http.Request{
Path: "/foo3",
Host: "foo.com",
Headers: map[string]string{
"stage": "pro",
"canary": "true",
"stage": "pro",
},
},
},
@@ -100,19 +123,94 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{
},
},
{
Meta: http.AssertionMeta{
TestCaseName: "case 4: update more",
TargetBackend: "infra-backend-v1",
TargetNamespace: "higress-conformance-infra",
},
Request: http.AssertionRequest{
ActualRequest: http.Request{
Path: "/foo4",
Host: "foo.com",
Headers: map[string]string{
"stage": "test",
"canary": "true",
},
},
ExpectedRequest: &http.ExpectedRequest{
Request: http.Request{
Path: "/foo4",
Host: "foo.com",
Headers: map[string]string{
"stage": "pro",
"canary": "false",
},
},
},
},
Response: http.AssertionResponse{
ExpectedResponse: http.Response{
StatusCode: 200,
},
},
},
{
Meta: http.AssertionMeta{
TestCaseName: "case 5: remove one",
TargetBackend: "infra-backend-v1",
TargetNamespace: "higress-conformance-infra",
},
Request: http.AssertionRequest{
ActualRequest: http.Request{
Path: "/foo5",
Host: "foo.com",
Headers: map[string]string{
"stage": "test",
},
},
ExpectedRequest: &http.ExpectedRequest{
Request: http.Request{
Path: "/foo5",
Host: "foo.com",
},
AbsentHeaders: []string{"stage"},
},
},
Response: http.AssertionResponse{
ExpectedResponse: http.Response{
StatusCode: 200,
},
},
},
{
Meta: http.AssertionMeta{
TestCaseName: "case 6: remove more",
TargetBackend: "infra-backend-v1",
TargetNamespace: "higress-conformance-infra",
},
Request: http.AssertionRequest{
ActualRequest: http.Request{
Path: "/foo6",
Host: "foo.com",
Headers: map[string]string{
"stage": "test",
"canary": "true",
},
},
ExpectedRequest: &http.ExpectedRequest{
Request: http.Request{
Path: "/foo6",
Host: "foo.com",
},
AbsentHeaders: []string{"stage", "canary"},
},
},
Response: http.AssertionResponse{
ExpectedResponse: http.Response{
StatusCode: 200,

View File

@@ -61,7 +61,7 @@ kind: Ingress
metadata:
annotations:
higress.io/request-header-control-update: stage pro
name: httproute-request-header-control-update
name: httproute-request-header-control-update-one
namespace: higress-conformance-infra
spec:
ingressClassName: higress
@@ -81,8 +81,10 @@ apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
higress.io/request-header-control-remove: stage
name: httproute-request-header-control-remove
higress.io/request-header-control-update: |
stage pro
canary false
name: httproute-request-header-control-update-more
namespace: higress-conformance-infra
spec:
ingressClassName: higress
@@ -97,3 +99,45 @@ spec:
name: infra-backend-v1
port:
number: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
higress.io/request-header-control-remove: stage
name: httproute-request-header-control-remove-one
namespace: higress-conformance-infra
spec:
ingressClassName: higress
rules:
- host: "foo.com"
http:
paths:
- pathType: Exact
path: "/foo5"
backend:
service:
name: infra-backend-v1
port:
number: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
higress.io/request-header-control-remove: stage,canary
name: httproute-request-header-control-remove-more
namespace: higress-conformance-infra
spec:
ingressClassName: higress
rules:
- host: "foo.com"
http:
paths:
- pathType: Exact
path: "/foo6"
backend:
service:
name: infra-backend-v1
port:
number: 8080

View File

@@ -72,6 +72,7 @@ func TestHigressConformanceTests(t *testing.T) {
tests.HTTPRouteMatchPath,
tests.HttpForceRedirectHttps,
tests.HttpRedirectAsHttps,
tests.HTTPRouteRequestHeaderControl,
}
cSuite.Run(t, higressTests)