Skip to content

Commit

Permalink
e2e test opt
Browse files Browse the repository at this point in the history
Signed-off-by: sjcsjc123 <[email protected]>
  • Loading branch information
sjcsjc123 committed Dec 31, 2023
1 parent 89c7277 commit 51d0bd8
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 19 deletions.
17 changes: 8 additions & 9 deletions test/e2e/conformance/utils/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import (
)

var (
IngressClassName = flag.String("ingress-class", "higress", "Name of IngressClass to use for tests")
ShowDebug = flag.Bool("debug", false, "Whether to print debug logs")
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")
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")
IsEnvoyConfigTest = flag.Bool("isEnvoyConfigTest", false, "Determine if run envoy config conformance test")
IngressClassName = flag.String("ingress-class", "higress", "Name of IngressClass to use for tests")
ShowDebug = flag.Bool("debug", false, "Whether to print debug logs")
SupportedFeatures = flag.String("supported-features", "", "Supported features included in conformance tests suites")
ExemptFeatures = flag.String("exempt-features", "", "Exempt Features excluded from conformance tests suites")
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")
IsEnvoyConfigTest = flag.Bool("isEnvoyConfigTest", false, "Determine if run envoy config conformance test")
)
8 changes: 4 additions & 4 deletions test/e2e/conformance/utils/suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,22 @@ func New(s Options) *ConformanceTestSuite {

// Setup ensures the base resources required for conformance tests are installed
// in the cluster. It also ensures that all relevant resources are ready.
func (suite *ConformanceTestSuite) Setup(t *testing.T) {
func (suite *ConformanceTestSuite) Setup(t *testing.T, cleanup bool) {
t.Logf("📦 Test Setup: Ensuring IngressClass has been accepted")

suite.Applier.IngressClass = suite.IngressClassName

t.Logf("📦 Test Setup: Applying base manifests")

for _, baseManifest := range suite.BaseManifests {
suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, baseManifest, suite.Cleanup)
suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, baseManifest, cleanup)
}

t.Logf("📦 Test Setup: Applying programmatic resources")
secret := kubernetes.MustCreateSelfSignedCertSecret(t, "higress-conformance-web-backend", "certificate", []string{"*"})
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{secret}, suite.Cleanup)
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{secret}, cleanup)
secret = kubernetes.MustCreateSelfSignedCertSecret(t, "higress-conformance-infra", "tls-validity-checks-certificate", []string{"*"})
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{secret}, suite.Cleanup)
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{secret}, cleanup)

t.Logf("📦 Test Setup: Ensuring Pods from base manifests are ready")
namespaces := []string{
Expand Down
66 changes: 60 additions & 6 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/alibaba/higress/test/e2e/conformance/utils/suite"
)

func TestHigressConformanceTests(t *testing.T) {
func TestPrepareHigressConformanceTests(t *testing.T) {
flag.Parse()

cfg, err := config.GetConfig()
Expand All @@ -40,10 +40,37 @@ func TestHigressConformanceTests(t *testing.T) {
require.NoError(t, v1.AddToScheme(client.Scheme()))

cSuite := suite.New(suite.Options{
Client: client,
IngressClassName: *flags.IngressClassName,
Debug: *flags.ShowDebug,
CleanupBaseResources: *flags.CleanupBaseResources,
Client: client,
IngressClassName: *flags.IngressClassName,
Debug: *flags.ShowDebug,
WASMOptions: suite.WASMOptions{
IsWasmPluginTest: *flags.IsWasmPluginTest,
WasmPluginName: *flags.WasmPluginName,
WasmPluginType: *flags.WasmPluginType,
},
GatewayAddress: "localhost",
EnableAllSupportedFeatures: true,
IsEnvoyConfigTest: *flags.IsEnvoyConfigTest,
})

cSuite.Setup(t, false)
}

func TestRunHigressConformanceTests(t *testing.T) {
flag.Parse()

cfg, err := config.GetConfig()
require.NoError(t, err)

client, err := client.New(cfg, client.Options{})
require.NoError(t, err)

require.NoError(t, v1.AddToScheme(client.Scheme()))

cSuite := suite.New(suite.Options{
Client: client,
IngressClassName: *flags.IngressClassName,
Debug: *flags.ShowDebug,
WASMOptions: suite.WASMOptions{
IsWasmPluginTest: *flags.IsWasmPluginTest,
WasmPluginName: *flags.WasmPluginName,
Expand All @@ -54,6 +81,33 @@ func TestHigressConformanceTests(t *testing.T) {
IsEnvoyConfigTest: *flags.IsEnvoyConfigTest,
})

cSuite.Setup(t)
cSuite.Run(t, tests.ConformanceTests)
}

func TestCleanHigressConformanceTests(t *testing.T) {
flag.Parse()

cfg, err := config.GetConfig()
require.NoError(t, err)

client, err := client.New(cfg, client.Options{})
require.NoError(t, err)

require.NoError(t, v1.AddToScheme(client.Scheme()))

cSuite := suite.New(suite.Options{
Client: client,
IngressClassName: *flags.IngressClassName,
Debug: *flags.ShowDebug,
WASMOptions: suite.WASMOptions{
IsWasmPluginTest: *flags.IsWasmPluginTest,
WasmPluginName: *flags.WasmPluginName,
WasmPluginType: *flags.WasmPluginType,
},
GatewayAddress: "localhost",
EnableAllSupportedFeatures: true,
IsEnvoyConfigTest: *flags.IsEnvoyConfigTest,
})

cSuite.Setup(t, true)
}

0 comments on commit 51d0bd8

Please sign in to comment.