feat: e2e test opt (#746)

Signed-off-by: sjcsjc123 <1401189096@qq.com>
This commit is contained in:
SJC
2024-01-26 16:45:33 +08:00
committed by GitHub
parent c41264816e
commit a624351f84
8 changed files with 214 additions and 7 deletions

View File

@@ -27,4 +27,5 @@ var (
WasmPluginType = flag.String("wasmPluginType", "GO", "Define wasm plugin type, currently supports GO, CPP")
WasmPluginName = flag.String("wasmPluginName", "", "Define wasm plugin name")
IsEnvoyConfigTest = flag.Bool("isEnvoyConfigTest", false, "Determine if run envoy config conformance test")
TestArea = flag.String("test-area", "all", "Test area to run, like all to run setup/run/clean, setup to prepare test environment, run to run test cases, clean to clean test environment")
)

View File

@@ -206,7 +206,7 @@ func (a Applier) MustDelete(t *testing.T, c client.Client, timeoutConfig config.
// }
// }
t.Logf("🏗 Deleting %s %s %s", uObj.GetName(), uObj.GetKind(), uObj.GetNamespace())
t.Logf("🚮 Deleting %s %s %s", uObj.GetName(), uObj.GetKind(), uObj.GetNamespace())
err = c.Delete(ctx, uObj)
require.NoErrorf(t, err, "error delete resource")
}

View File

@@ -24,6 +24,13 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)
const (
TestAreaAll = "all"
TestAreaSetup = "setup"
TestAreaRun = "run"
TessAreaClean = "clean"
)
// ConformanceTestSuite defines the test suite used to run Gateway API
// conformance tests.
type ConformanceTestSuite struct {
@@ -159,7 +166,7 @@ func (suite *ConformanceTestSuite) Setup(t *testing.T) {
t.Logf("🌱 Supported Features: %+v", suite.SupportedFeatures.UnsortedList())
}
// RunWithTests runs the provided set of conformance tests.
// Run runs the provided set of conformance tests.
func (suite *ConformanceTestSuite) Run(t *testing.T, tests []ConformanceTest) {
t.Logf("🚀 Start Running %d Test Cases: \n\n%s", len(tests), globalConformanceTestsListInfo(tests))
for _, test := range tests {
@@ -169,6 +176,17 @@ func (suite *ConformanceTestSuite) Run(t *testing.T, tests []ConformanceTest) {
}
}
// Clean cleans up the base resources installed by Setup.
func (suite *ConformanceTestSuite) Clean(t *testing.T) {
if suite.Cleanup {
t.Logf("🧹 Test Cleanup: Ensuring base resources have been cleaned up")
for _, baseManifest := range suite.BaseManifests {
suite.Applier.MustDelete(t, suite.Client, suite.TimeoutConfig, baseManifest)
}
}
}
func globalConformanceTestsListInfo(tests []ConformanceTest) string {
var cases string
for index, test := range tests {