test: add Gateway API v1.4 conformance CI (#4135)

Signed-off-by: EndlessSeeker <1766508902@qq.com>
This commit is contained in:
EndlessSeeker
2026-07-14 19:49:58 +08:00
committed by GitHub
parent 152f14b171
commit afb72b81cb
22 changed files with 454 additions and 59 deletions

View File

@@ -18,6 +18,7 @@ Higress e2e tests are mainly focusing on two parts for now:
Higress provides make target to run ingress api conformance tests and wasmplugin tests,
+ API Tests: `make higress-conformance-test`
+ Gateway API Tests: `make gateway-conformance-test`
+ WasmPlugin Tests: `make higress-wasmplugin-test`
+ Build all Go WasmPlugins for testing: `make higress-wasmplugin-test`
+ Build tests for a specific Go WasmPlugin only: `PLUGIN_NAME=request-block make higress-wasmplugin-test`
@@ -71,15 +72,6 @@ The test environment reusability is primarily achieved through the following tar
## Gateway APIs Conformance Tests
Gateway API Conformance tests are based on the suite provided by `kubernetes-sig/gateway-api`, we can reuse that,
and decide what conformance tests we need to open. Conformance tests of Gateway API.
Run `make gateway-conformance-test` to execute the upstream Gateway API v1.4.0 Conformance Suite. The default scope is the required `GATEWAY-HTTP` Core profile (`Gateway`, `HTTPRoute`, and `ReferenceGrant`); Extended features are not enabled.
This API covers a broad set of features and use cases and has been implemented widely.
This combination of both a large feature set and variety of implementations requires
clear conformance definitions and tests to ensure the API provides a consistent experience wherever it is used.
Gateway API includes a set of conformance tests. These create a series of Gateways and Routes with the specified
GatewayClass, and test that the implementation matches the API specification.
Each release contains a set of conformance tests, these will continue to expand as the API evolves.
Currently conformance tests cover the majority of Core capabilities in the standard channel, in addition to some Extended capabilities.
The runner imports the upstream suite and its embedded manifests directly, so Higress does not maintain copies of official test cases. Set `GATEWAY_CONFORMANCE_RUN_TEST=<ShortName>` only when debugging one upstream test. The default PR workflow always runs the complete Core profile and stores the generated report as a CI artifact.

View File

@@ -18,6 +18,7 @@ Higress E2E 测试主要关注两个部分:
Higress 提供了运行 Ingress API 一致性测试和 wasmplugin 测试的 make 目标,
+ API 测试: `make higress-conformance-test`
+ Gateway API 测试: `make gateway-conformance-test`
+ WasmPlugin 测试: `make higress-wasmplugin-test`
+ 为测试构建所有 GO WasmPlugins: `make higress-wasmplugin-test`
+ 仅为一个 GO WasmPlugin 构建测试: `PLUGIN_NAME=request-block make higress-wasmplugin-test`
@@ -70,12 +71,6 @@ Higress 提供了运行 Ingress API 一致性测试和 wasmplugin 测试的 make
## Gateway API 一致性测试
Gateway API 一致性测试基于 `kubernetes-sig/gateway-api` 提供的套件,我们可以重复使用它,并决定我们需要打开哪些 Gateway API 的一致性测试
执行 `make gateway-conformance-test` 可运行上游 Gateway API v1.4.0 Conformance Suite。默认范围只包含 `GATEWAY-HTTP` Profile 的必选 Core 能力:`Gateway``HTTPRoute``ReferenceGrant`,不启用 Extended 能力
此 API 包含一系列广泛的功能和用例,并已得到广泛实现
这个大的功能集和各种实现的结合需要明确的一致性定义和测试,以确保在任何地方使用该 API 时都提供一致的体验。
Gateway API 包括一组一致性测试。这些测试创建具有指定 GatewayClass 的一系列 Gateways 和 Routes并测试实现是否符合 API 规范。
每个发布版本都包含一组一致性测试,随着 API 的演进,这些测试将不断扩展。
目前,一致性测试覆盖了标准通道中的大多数核心功能,以及一些扩展功能。
Runner 直接引用上游 Suite 及其内嵌 manifestsHigress 不复制维护官方测试用例。只有调试单个上游用例时才设置 `GATEWAY_CONFORMANCE_RUN_TEST=<ShortName>`;默认 PR 流水线始终执行完整 Core Profile并将官方报告保存为 CI artifact

View File

@@ -13,3 +13,46 @@
// limitations under the License.
package gateway
import (
"context"
"net"
"os"
"testing"
"sigs.k8s.io/gateway-api/conformance"
"sigs.k8s.io/gateway-api/conformance/utils/roundtripper"
)
const dialLocalhostEnv = "HIGRESS_GATEWAY_API_TEST_DIAL_LOCALHOST"
const localHTTPPortEnv = "HIGRESS_GATEWAY_API_TEST_LOCAL_HTTP_PORT"
const localHTTPSPortEnv = "HIGRESS_GATEWAY_API_TEST_LOCAL_HTTPS_PORT"
func TestGatewayAPIConformance(t *testing.T) {
opts := conformance.DefaultOptions(t)
if os.Getenv(dialLocalhostEnv) == "true" {
opts.RoundTripper = &roundtripper.DefaultRoundTripper{
Debug: opts.Debug,
TimeoutConfig: opts.TimeoutConfig,
CustomDialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
_, port, err := net.SplitHostPort(address)
if err != nil {
return nil, err
}
switch port {
case "80":
if localPort := os.Getenv(localHTTPPortEnv); localPort != "" {
port = localPort
}
case "443":
if localPort := os.Getenv(localHTTPSPortEnv); localPort != "" {
port = localPort
}
}
var dialer net.Dialer
return dialer.DialContext(ctx, network, net.JoinHostPort("127.0.0.1", port))
},
}
}
conformance.RunConformanceWithOptions(t, opts)
}