diff --git a/Makefile.core.mk b/Makefile.core.mk index 333351798..ac58fc4ff 100644 --- a/Makefile.core.mk +++ b/Makefile.core.mk @@ -305,7 +305,7 @@ run-higress-e2e-test: kubectl wait --timeout=10m -n higress-system deployment/higress-controller --for=condition=Available @echo -e "\n\033[36mWaiting higress-gateway to be ready...\033[0m\n" kubectl wait --timeout=10m -n higress-system deployment/higress-gateway --for=condition=Available - go test -v -tags conformance ./test/e2e/e2e_test.go --ingress-class=higress --debug=true --test-area=all + go test -v -tags conformance ./test/e2e/e2e_test.go --ingress-class=higress --debug=true --test-area=all --execute-tests=$(TEST_SHORTNAME) # run-higress-e2e-test-run starts to run ingress e2e conformance tests. .PHONY: run-higress-e2e-test-run @@ -315,7 +315,7 @@ run-higress-e2e-test-run: kubectl wait --timeout=10m -n higress-system deployment/higress-controller --for=condition=Available @echo -e "\n\033[36mWaiting higress-gateway to be ready...\033[0m\n" kubectl wait --timeout=10m -n higress-system deployment/higress-gateway --for=condition=Available - go test -v -tags conformance ./test/e2e/e2e_test.go --ingress-class=higress --debug=true --test-area=run + go test -v -tags conformance ./test/e2e/e2e_test.go --ingress-class=higress --debug=true --test-area=run --execute-tests=$(TEST_SHORTNAME) # run-higress-e2e-test-clean starts to clean ingress e2e tests. .PHONY: run-higress-e2e-test-clean @@ -345,7 +345,7 @@ run-higress-e2e-test-wasmplugin: kubectl wait --timeout=10m -n higress-system deployment/higress-controller --for=condition=Available @echo -e "\n\033[36mWaiting higress-gateway to be ready...\033[0m\n" kubectl wait --timeout=10m -n higress-system deployment/higress-gateway --for=condition=Available - go test -v -tags conformance ./test/e2e/e2e_test.go -isWasmPluginTest=true -wasmPluginType=$(PLUGIN_TYPE) -wasmPluginName=$(PLUGIN_NAME) --ingress-class=higress --debug=true --test-area=all + go test -v -tags conformance ./test/e2e/e2e_test.go -isWasmPluginTest=true -wasmPluginType=$(PLUGIN_TYPE) -wasmPluginName=$(PLUGIN_NAME) --ingress-class=higress --debug=true --test-area=all --execute-tests=$(TEST_SHORTNAME) # run-higress-e2e-test-wasmplugin-run starts to run ingress e2e conformance tests. .PHONY: run-higress-e2e-test-wasmplugin-run @@ -355,7 +355,7 @@ run-higress-e2e-test-wasmplugin-run: kubectl wait --timeout=10m -n higress-system deployment/higress-controller --for=condition=Available @echo -e "\n\033[36mWaiting higress-gateway to be ready...\033[0m\n" kubectl wait --timeout=10m -n higress-system deployment/higress-gateway --for=condition=Available - go test -v -tags conformance ./test/e2e/e2e_test.go -isWasmPluginTest=true -wasmPluginType=$(PLUGIN_TYPE) -wasmPluginName=$(PLUGIN_NAME) --ingress-class=higress --debug=true --test-area=run + go test -v -tags conformance ./test/e2e/e2e_test.go -isWasmPluginTest=true -wasmPluginType=$(PLUGIN_TYPE) -wasmPluginName=$(PLUGIN_NAME) --ingress-class=higress --debug=true --test-area=run --execute-tests=$(TEST_SHORTNAME) # run-higress-e2e-test-wasmplugin-clean starts to clean ingress e2e tests. .PHONY: run-higress-e2e-test-wasmplugin-clean diff --git a/test/README.md b/test/README.md index dec426b17..4a7ab87ef 100644 --- a/test/README.md +++ b/test/README.md @@ -22,6 +22,7 @@ Higress provides make target to run ingress api conformance tests and wasmplugin + Build ALL GO WasmPlugins for testing: `make higress-wasmplugin-test` + Only build one GO WasmPlugin for testing: `PLUGIN_NAME=request-block make higress-wasmplugin-test` + Only build one CPP WasmPlugin for testing: `PLUGIN_TYPE=CPP PLUGIN_NAME=key_auth make higress-wasmplugin-test` + + Only run the specific test, splited by comma `TEST_SHORTNAME=WasmPluginsIPRestrictionAllow,WasmPluginsIPRestrictionDeny make higress-wasmplugin-test` It can be divided into below steps: diff --git a/test/README_CN.md b/test/README_CN.md index 3bcec4bc3..058eef697 100644 --- a/test/README_CN.md +++ b/test/README_CN.md @@ -22,6 +22,7 @@ Higress 提供了运行 Ingress API 一致性测试和 wasmplugin 测试的 make + 为测试构建所有 GO WasmPlugins: `make higress-wasmplugin-test` + 仅为一个 GO WasmPlugin 构建测试: `PLUGIN_NAME=request-block make higress-wasmplugin-test` + 仅为一个 CPP WasmPlugin 构建测试: `PLUGIN_TYPE=CPP PLUGIN_NAME=key_auth make higress-wasmplugin-test` + + 仅运行指定测试,用逗号分隔 `TEST_SHORTNAME=WasmPluginsIPRestrictionAllow,WasmPluginsIPRestrictionDeny make higress-wasmplugin-test` 可以分为以下步骤: diff --git a/test/e2e/conformance/utils/flags/flags.go b/test/e2e/conformance/utils/flags/flags.go index 9b2d4317c..0d53f2de4 100644 --- a/test/e2e/conformance/utils/flags/flags.go +++ b/test/e2e/conformance/utils/flags/flags.go @@ -23,6 +23,7 @@ var ( CleanupBaseResources = flag.Bool("cleanup-base-resources", true, "Whether to cleanup base test resources after the run") SupportedFeatures = flag.String("supported-features", "", "Supported features included in conformance tests suites") ExemptFeatures = flag.String("exempt-features", "", "Exempt Features excluded from conformance tests suites") + ExecuteTests = flag.String("execute-tests", "", "Execute the specific conformance tests") IsWasmPluginTest = flag.Bool("isWasmPluginTest", false, "Determine if run wasm plugin conformance test") WasmPluginType = flag.String("wasmPluginType", "GO", "Define wasm plugin type, currently supports GO, CPP") WasmPluginName = flag.String("wasmPluginName", "", "Define wasm plugin name") diff --git a/test/e2e/conformance/utils/suite/suite.go b/test/e2e/conformance/utils/suite/suite.go index f958084a4..b7302e5a4 100644 --- a/test/e2e/conformance/utils/suite/suite.go +++ b/test/e2e/conformance/utils/suite/suite.go @@ -15,6 +15,7 @@ package suite import ( "fmt" + "strings" "testing" "github.com/alibaba/higress/test/e2e/conformance/utils/config" @@ -43,6 +44,7 @@ type ConformanceTestSuite struct { BaseManifests []string Applier kubernetes.Applier SkipTests sets.Set + ExecuteTests sets.Set TimeoutConfig config.TimeoutConfig SupportedFeatures sets.Set } @@ -51,6 +53,7 @@ type ConformanceTestSuite struct { type Options struct { SupportedFeatures sets.Set ExemptFeatures sets.Set + ExecuteTests string EnableAllSupportedFeatures bool Client client.Client @@ -116,6 +119,7 @@ func New(s Options) *ConformanceTestSuite { BaseManifests: s.BaseManifests, SupportedFeatures: s.SupportedFeatures, GatewayAddress: s.GatewayAddress, + ExecuteTests: sets.NewSet(), Applier: kubernetes.Applier{ NamespaceLabels: s.NamespaceLabels, }, @@ -134,6 +138,13 @@ func New(s Options) *ConformanceTestSuite { } } + testNames := strings.Split(s.ExecuteTests, ",") + for i := range testNames { + if testNames[i] != "" { + suite.ExecuteTests = suite.ExecuteTests.Insert(testNames[i]) + } + } + return suite } @@ -232,6 +243,10 @@ func (test *ConformanceTest) Run(t *testing.T, suite *ConformanceTestSuite) { t.Skipf("🏊🏼 Skipping %s: test explicitly skipped", test.ShortName) } + if len(suite.ExecuteTests) > 0 && !suite.ExecuteTests.Contains(test.ShortName) { + t.Skipf("🏊🏼 Skipping %s: test explicitly skipped", test.ShortName) + } + t.Logf("🔥 Running Conformance Test: %s", test.ShortName) for _, manifestLocation := range test.PreDeleteRs { diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 007fe7818..4ccf6beb0 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -50,6 +50,7 @@ func TestHigressConformanceTests(t *testing.T) { WasmPluginName: *flags.WasmPluginName, WasmPluginType: *flags.WasmPluginType, }, + ExecuteTests: *flags.ExecuteTests, GatewayAddress: "localhost", EnableAllSupportedFeatures: true, IsEnvoyConfigTest: *flags.IsEnvoyConfigTest,