e2e: add http rewrite path testcase (#177)

Signed-off-by: bitliu <bitliu@tencent.com>
This commit is contained in:
Xunzhuo
2023-02-07 14:40:18 +08:00
committed by GitHub
parent d84c9e67c3
commit 40f4d7845d
3 changed files with 84 additions and 3 deletions

View File

@@ -0,0 +1,46 @@
// Copyright (c) 2022 Alibaba Group Holding Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package tests
import (
"testing"
"github.com/alibaba/higress/test/ingress/conformance/utils/http"
"github.com/alibaba/higress/test/ingress/conformance/utils/suite"
)
func init() {
HigressConformanceTests = append(HigressConformanceTests, HTTPRouteRewritePath)
}
var HTTPRouteRewritePath = suite.ConformanceTest{
ShortName: "HTTPRouteRewritePath",
Description: "A single Ingress in the higress-conformance-infra namespace uses the rewrite path",
Manifests: []string{"tests/httproute-rewrite-path.yaml"},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
t.Run("Rewrite HTTPRoute Path", func(t *testing.T) {
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, suite.GatewayAddress, http.ExpectedResponse{
Request: http.Request{Path: "/svc/foo"},
ExpectedRequest: &http.ExpectedRequest{
Request: http.Request{Path: "/foo"},
},
Response: http.Response{StatusCode: 200},
Backend: "infra-backend-v1",
Namespace: "higress-conformance-infra",
})
})
},
}

View File

@@ -0,0 +1,33 @@
# Copyright (c) 2022 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: "/$1"
name: httproute-rewrite-path
namespace: higress-conformance-infra
spec:
ingressClassName: higress
rules:
- http:
paths:
- pathType: ImplementationSpecific
path: "/svc/(.*)"
backend:
service:
name: infra-backend-v1
port:
number: 8080

View File

@@ -18,13 +18,14 @@ import (
"flag"
"testing"
"github.com/alibaba/higress/test/ingress/conformance/tests"
"github.com/alibaba/higress/test/ingress/conformance/utils/flags"
"github.com/alibaba/higress/test/ingress/conformance/utils/suite"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/networking/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"github.com/alibaba/higress/test/ingress/conformance/tests"
"github.com/alibaba/higress/test/ingress/conformance/utils/flags"
"github.com/alibaba/higress/test/ingress/conformance/utils/suite"
)
func TestHigressConformanceTests(t *testing.T) {
@@ -51,6 +52,7 @@ func TestHigressConformanceTests(t *testing.T) {
higressTests := []suite.ConformanceTest{
tests.HTTPRouteSimpleSameNamespace,
tests.HTTPRouteHostNameSameNamespace,
tests.HTTPRouteRewritePath,
}
cSuite.Run(t, higressTests)