Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: e2e test opt #746

Merged
merged 31 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
51d0bd8
e2e test opt
sjcsjc123 Dec 31, 2023
bc63be0
add makefile
sjcsjc123 Dec 31, 2023
edbc3f7
fix ci
sjcsjc123 Dec 31, 2023
b721224
add makefile
sjcsjc123 Dec 31, 2023
9c57b0a
fix ci
sjcsjc123 Jan 1, 2024
d5092f3
add makefile
sjcsjc123 Jan 2, 2024
048db2d
e2e test opt
sjcsjc123 Jan 2, 2024
bf13230
Merge remote-tracking branch 'origin/e2e-test-opt' into e2e-test-opt
sjcsjc123 Jan 2, 2024
c481798
fix ci
sjcsjc123 Jan 2, 2024
176523e
Merge branch 'main' into e2e-test-opt
sjcsjc123 Jan 3, 2024
237302c
Merge remote-tracking branch 'origin/e2e-test-opt' into e2e-test-opt
sjcsjc123 Jan 3, 2024
b1284db
try run ci again
sjcsjc123 Jan 3, 2024
4f8d074
try run ci again
sjcsjc123 Jan 3, 2024
a44be14
try run ci again
sjcsjc123 Jan 3, 2024
e1cd225
try run ci again
sjcsjc123 Jan 4, 2024
6282e1a
Merge remote-tracking branch 'origin/e2e-test-opt' into e2e-test-opt
sjcsjc123 Jan 12, 2024
e3929d3
update
sjcsjc123 Jan 12, 2024
6b17394
update
sjcsjc123 Jan 12, 2024
644e064
add makefile
sjcsjc123 Jan 12, 2024
9c3f629
add e2e
sjcsjc123 Jan 12, 2024
5594f8e
fix ci
sjcsjc123 Jan 12, 2024
1878d9c
add check cleanup flag
sjcsjc123 Jan 12, 2024
7fbbff9
Merge remote-tracking branch 'origin/e2e-test-opt' into e2e-test-opt
sjcsjc123 Jan 16, 2024
0dc1e86
update e2e
sjcsjc123 Jan 16, 2024
8b9be9d
update e2e
sjcsjc123 Jan 16, 2024
c59a0be
try run ci again
sjcsjc123 Jan 17, 2024
ce1fa51
add README.md
sjcsjc123 Jan 22, 2024
f1a3785
add readme
sjcsjc123 Jan 24, 2024
437c97e
rename
sjcsjc123 Jan 24, 2024
09c47f1
update comment
sjcsjc123 Jan 24, 2024
36e39e5
fix ci
sjcsjc123 Jan 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Makefile.core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,30 @@ include tools/lint.mk
.PHONY: gateway-conformance-test
gateway-conformance-test:

# higress-conformance-test-prepare prepares the environment for higress conformance tests.
.PHONY: higress-conformance-test-prepare
higress-conformance-test-prepare: $(tools/kind) delete-cluster create-cluster docker-build kube-load-image install-dev

# higress-conformance-test runs ingress api conformance tests.
.PHONY: higress-conformance-test
higress-conformance-test: $(tools/kind) delete-cluster create-cluster docker-build kube-load-image install-dev run-higress-e2e-test delete-cluster

# higress-conformance-test-clean cleans the environment for higress conformance tests.
.PHONY: higress-conformance-test-clean
higress-conformance-test-clean: $(tools/kind) delete-cluster

# higress-wasmplugin-test-prepare prepares the environment for higress wasmplugin tests.
.PHONY: higress-wasmplugin-test-prepare
higress-wasmplugin-test-prepare: $(tools/kind) delete-cluster create-cluster docker-build kube-load-image install-dev-wasmplugin

# higress-wasmplugin-test runs ingress wasmplugin tests.
.PHONY: higress-wasmplugin-test
higress-wasmplugin-test: $(tools/kind) delete-cluster create-cluster docker-build kube-load-image install-dev-wasmplugin run-higress-e2e-test-wasmplugin delete-cluster

# higress-wasmplugin-test-clean cleans the environment for higress wasmplugin tests.
.PHONY: higress-wasmplugin-test-clean
higress-wasmplugin-test-clean: $(tools/kind) delete-cluster

# create-cluster creates a kube cluster with kind.
.PHONY: create-cluster
create-cluster: $(tools/kind)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/conformance/tests/go-wasm-sni-misdirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var WasmPluginsSniMisdirect = suite.ConformanceTest{
cliCertOut, cliKeyOut := cert.MustGenerateCertWithCA(t, cert.ClientCertType, caCert, caKey, nil)
fooSecret := kubernetes.ConstructTLSSecret("higress-conformance-infra", "foo-secret", svcCertOut.Bytes(), svcKeyOut.Bytes())
fooSecretCACert := kubernetes.ConstructCASecret("higress-conformance-infra", "foo-secret-cacert", caCertOut.Bytes())
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{fooSecret, fooSecretCACert}, suite.Cleanup)
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{fooSecret, fooSecretCACert}, true)

testcases := []http.Assertion{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var HTTPRouteDownstreamEncryption = suite.ConformanceTest{
cliCertOut, cliKeyOut := cert.MustGenerateCertWithCA(t, cert.ClientCertType, caCert, caKey, nil)
fooSecret := kubernetes.ConstructTLSSecret("higress-conformance-infra", "foo-secret", svcCertOut.Bytes(), svcKeyOut.Bytes())
fooSecretCACert := kubernetes.ConstructCASecret("higress-conformance-infra", "foo-secret-cacert", caCertOut.Bytes())
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{fooSecret, fooSecretCACert}, suite.Cleanup)
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{fooSecret, fooSecretCACert}, true)

testcases := []http.Assertion{
{
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/conformance/tests/httproute-https-without-sni.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var HTTPHttpsWithoutSni = suite.ConformanceTest{
_, _, caCert, caKey := cert.MustGenerateCaCert(t)
svcCertOut, svcKeyOut := cert.MustGenerateCertWithCA(t, cert.ServerCertType, caCert, caKey, []string{"foo.com"})
fooSecret := kubernetes.ConstructTLSSecret("higress-conformance-infra", "foo-secret", svcCertOut.Bytes(), svcKeyOut.Bytes())
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{fooSecret}, suite.Cleanup)
suite.Applier.MustApplyObjectsWithCleanup(t, suite.Client, suite.TimeoutConfig, []client.Object{fooSecret}, true)

testcases := []http.Assertion{
{
Expand Down
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")
)
2 changes: 1 addition & 1 deletion test/e2e/conformance/utils/kubernetes/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
28 changes: 13 additions & 15 deletions test/e2e/conformance/utils/suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type ConformanceTestSuite struct {
GatewayAddress string
IngressClassName string
Debug bool
Cleanup bool
BaseManifests []string
Applier kubernetes.Applier
SkipTests sets.Set
Expand All @@ -56,10 +55,7 @@ type Options struct {
// Options for wasm extended features
WASMOptions

// CleanupBaseResources indicates whether or not the base test
// resources such as Gateways should be cleaned up after the run.
CleanupBaseResources bool
TimeoutConfig config.TimeoutConfig
TimeoutConfig config.TimeoutConfig

// IsEnvoyConfigTest indicates whether or not the test is for envoy config
IsEnvoyConfigTest bool
Expand Down Expand Up @@ -105,7 +101,6 @@ func New(s Options) *ConformanceTestSuite {
RoundTripper: roundTripper,
IngressClassName: s.IngressClassName,
Debug: s.Debug,
Cleanup: s.CleanupBaseResources,
BaseManifests: s.BaseManifests,
SupportedFeatures: s.SupportedFeatures,
GatewayAddress: s.GatewayAddress,
Expand All @@ -126,27 +121,24 @@ func New(s Options) *ConformanceTestSuite {
}
}

suite.Applier.IngressClass = suite.IngressClassName

return suite
}

// 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) {
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, false)
}

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}, false)
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}, false)

t.Logf("📦 Test Setup: Ensuring Pods from base manifests are ready")
namespaces := []string{
Expand All @@ -159,7 +151,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 {
Expand All @@ -169,6 +161,12 @@ func (suite *ConformanceTestSuite) Run(t *testing.T, tests []ConformanceTest) {
}
}

// Cleanup ensures that all resources created by the test suite are cleaned up.
func (suite *ConformanceTestSuite) Cleanup(t *testing.T) {
t.Logf("🧹 Test Cleanup: Ensuring all resources are cleaned up")
suite.Applier.MustDelete(t, suite.Client, suite.TimeoutConfig, "base/manifests.yaml")
}

func globalConformanceTestsListInfo(tests []ConformanceTest) string {
var cases string
for index, test := range tests {
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 @@ -16,19 +16,19 @@ package test

import (
"flag"
"github.com/alibaba/higress/test/e2e/conformance/tests"
"testing"

"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/e2e/conformance/tests"
"github.com/alibaba/higress/test/e2e/conformance/utils/flags"
"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,9 @@ 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,
Expand All @@ -55,5 +54,60 @@ func TestHigressConformanceTests(t *testing.T) {
})

cSuite.Setup(t)
}

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,
WasmPluginType: *flags.WasmPluginType,
},
GatewayAddress: "localhost",
EnableAllSupportedFeatures: true,
IsEnvoyConfigTest: *flags.IsEnvoyConfigTest,
})

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.Cleanup(t)
}
Loading