diff --git a/.github/.codecov.yml b/.github/.codecov.yml index f6674cde2..fab584a31 100644 --- a/.github/.codecov.yml +++ b/.github/.codecov.yml @@ -24,6 +24,10 @@ coverage: paths: - tools/* # only include coverage in "tools/" folder informational: true # Always pass check + test: # declare a new status context "test" + paths: + - test/* # only include coverage in "test/" folder + informational: true # Always pass check # internal: # declare a new status context "internal" # paths: # - internal/* # only include coverage in "internal/" folder diff --git a/Makefile b/Makefile index dedc25e11..1941bde6c 100644 --- a/Makefile +++ b/Makefile @@ -172,7 +172,7 @@ test-api: @$(MAKE) go.test.api ## test-e2e: Run e2e test -test-api: +test-e2e: @$(MAKE) go.test.e2e ## updates: Check for updates to go.mod dependencies. ✨ diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk index 113625ef6..44918d01c 100644 --- a/scripts/make-rules/golang.mk +++ b/scripts/make-rules/golang.mk @@ -201,9 +201,9 @@ go.test.api: ## go.test.e2e: Run e2e test .PHONY: go.test.e2e -go.test.e2e: +go.test.e2e: tools.verify.ginkgo @echo "===========> Run e2e test" - @$(ROOT_DIR)/scripts/install/test.sh openim::test::e2e + @$(TOOLS_DIR)/ginkgo -v $(ROOT_DIR)/test/e2e ## go.demo: Run demo .PHONY: go.demo diff --git a/test/e2e/README.md b/test/e2e/README.md index 6779d0592..1e73dbaec 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -90,7 +90,7 @@ ginkgo -v --randomizeAllSpecs --randomizeSuites --failOnPending --cover --trace You can also run a specific test or group of tests by specifying the path to the test directory: ```bash -ginkgo -v ./test/e2e/chat/ +ginkgo -v ./test/e2e/chat ``` Or you can use Makefile to run the tests: diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index b70bf6651..d1d6c5509 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -1,2 +1,37 @@ package e2e +import ( + "testing" + + gettoken "github.com/openimsdk/open-im-server/v3/test/e2e/api/token" + "github.com/openimsdk/open-im-server/v3/test/e2e/api/user" +) + +// RunE2ETests checks configuration parameters (specified through flags) and then runs +// E2E tests using the Ginkgo runner. +// If a "report directory" is specified, one or more JUnit test reports will be +// generated in this directory, and cluster logs will also be saved. +// This function is called on each Ginkgo node in parallel mode. +func RunE2ETests(t *testing.T) { + + // Example usage of new functions + token, _ := gettoken.GetUserToken("openIM123456") + + // Example of getting user info + _ = user.GetUsersInfo(token, []string{"user1", "user2"}) + + // Example of updating user info + _ = user.UpdateUserInfo(token, "user1", "NewNickname", "https://github.com/openimsdk/open-im-server/blob/main/assets/logo/openim-logo.png") + + // Example of getting users' online status + _ = user.GetUsersOnlineStatus(token, []string{"user1", "user2"}) + + // Example of forcing a logout + _ = user.ForceLogout(token, "4950983283", 2) + + // Example of checking user account + _ = user.CheckUserAccount(token, []string{"openIM123456", "anotherUserID"}) + + // Example of getting users + _ = user.GetUsers(token, 1, 100) +} diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index df8caf702..d578a988b 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -1 +1,23 @@ package e2e + +import ( + "flag" + "testing" + + "github.com/openimsdk/open-im-server/v3/test/e2e/framework/config" +) + +// handleFlags sets up all flags and parses the command line. +func handleFlags() { + config.CopyFlags(config.Flags, flag.CommandLine) + flag.Parse() +} + +func TestMain(m *testing.M) { + handleFlags() + m.Run() +} + +func TestE2E(t *testing.T) { + RunE2ETests(t) +} \ No newline at end of file