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 27 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
7 changes: 7 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ It can be divided into below steps:
2. Prepare resources and install them into cluster, like backend services/deployments.
3. Load conformance tests we choose to open in `e2e_test.go` / `higressTests Slice`, and run them one by one, fail if it is not expected.

> Note: You can use `TestArea` flag to control which area you want to run.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

简单说明要复用e2e环境的步骤是怎样即可,可以加一小节。
另外可以帮忙把这篇README搞一个中文版本吗 🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已添加

> - TestAreaAll: will prepare all resources and run all conformance tests.
> - TestAreaSetup: will only prepare resources.
> - TestAreaRun: will only run conformance tests.
>
> When developing, you can use `TestAreaSetup` to prepare resources only once, and then use `TestAreaRun` to run conformance tests anywhere.

### How to write a test case

To add a new test case, you firstly need to add `xxx.go` and `xxx.yaml` in `test/ingress/conformance/tests`. `xxx.yaml` is the Ingress resource you need to apply in the cluster, `xxx.go` defines the HigressConformanceTest.
Expand Down
1 change: 1 addition & 0 deletions test/e2e/conformance/utils/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 run setup only, run to run run only, clean to run clean only")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"run to run run only" 😄 that's confused.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已更改解释

)
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
8 changes: 7 additions & 1 deletion test/e2e/conformance/utils/suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

const (
TestAreaAll = "all"
TestAreaSetup = "setup"
TestAreaRun = "run"
)

// ConformanceTestSuite defines the test suite used to run Gateway API
// conformance tests.
type ConformanceTestSuite struct {
Expand Down Expand Up @@ -159,7 +165,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 Down
15 changes: 13 additions & 2 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package test

import (
"flag"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -54,6 +55,16 @@ func TestHigressConformanceTests(t *testing.T) {
IsEnvoyConfigTest: *flags.IsEnvoyConfigTest,
})

cSuite.Setup(t)
cSuite.Run(t, tests.ConformanceTests)
// Run the test suite
testArea := *flags.TestArea
testArea = strings.ToLower(testArea)
switch testArea {
case suite.TestAreaAll:
cSuite.Setup(t)
cSuite.Run(t, tests.ConformanceTests)
case suite.TestAreaRun:
cSuite.Run(t, tests.ConformanceTests)
case suite.TestAreaSetup:
cSuite.Setup(t)
}
}
Loading