From 8c50d6dd7c9734d09345d3c8d8094f75e8fe6e41 Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Tue, 11 Feb 2025 14:57:21 +0900 Subject: [PATCH 1/2] Fix test failures --- Makefile | 4 ++++ test/complex/main_test.go | 25 ++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 9fce58303..31be92218 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,10 @@ test: ## runs integration tests that require local applications such as MongoDB go clean -testcache go test -tags integration -race ./... +test-complex: ## runs complex tests that take a long time + go clean -testcache + go test -tags complex -race -v ./test/complex/... + bench: ## runs benchmark tests rm -f pipe output.txt mem.prof cpu.prof bench.test mkfifo pipe diff --git a/test/complex/main_test.go b/test/complex/main_test.go index cd96b3886..76453cf92 100644 --- a/test/complex/main_test.go +++ b/test/complex/main_test.go @@ -73,17 +73,20 @@ func TestMain(m *testing.M) { } be, err := backend.New(&backend.Config{ - AdminUser: helper.AdminUser, - AdminPassword: helper.AdminPassword, - UseDefaultProject: helper.UseDefaultProject, - ClientDeactivateThreshold: helper.ClientDeactivateThreshold, - SnapshotThreshold: helper.SnapshotThreshold, - AuthWebhookCacheSize: helper.AuthWebhookSize, - AuthWebhookCacheTTL: helper.AuthWebhookCacheTTL.String(), - ProjectCacheSize: helper.ProjectCacheSize, - ProjectCacheTTL: helper.ProjectCacheTTL.String(), - AdminTokenDuration: helper.AdminTokenDuration, - GatewayAddr: fmt.Sprintf("localhost:%d", helper.RPCPort), + AdminUser: helper.AdminUser, + AdminPassword: helper.AdminPassword, + UseDefaultProject: helper.UseDefaultProject, + ClientDeactivateThreshold: helper.ClientDeactivateThreshold, + SnapshotThreshold: helper.SnapshotThreshold, + AuthWebhookMaxWaitInterval: helper.AuthWebhookMaxWaitInterval.String(), + AuthWebhookMinWaitInterval: helper.AuthWebhookMinWaitInterval.String(), + AuthWebhookRequestTimeout: helper.AuthWebhookRequestTimeout.String(), + AuthWebhookCacheSize: helper.AuthWebhookSize, + AuthWebhookCacheTTL: helper.AuthWebhookCacheTTL.String(), + ProjectCacheSize: helper.ProjectCacheSize, + ProjectCacheTTL: helper.ProjectCacheTTL.String(), + AdminTokenDuration: helper.AdminTokenDuration, + GatewayAddr: fmt.Sprintf("localhost:%d", helper.RPCPort), }, &mongo.Config{ ConnectionURI: helper.MongoConnectionURI, YorkieDatabase: shardedDBNameForServer, From 28e98881421276859ff086388ec15517662da914 Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Tue, 11 Feb 2025 15:12:59 +0900 Subject: [PATCH 2/2] Update ci-target-check for complex test --- .github/workflows/ci.yml | 223 +++++++++++++++++++-------------------- 1 file changed, 111 insertions(+), 112 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c31ae4bc6..56b621738 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,19 +2,19 @@ name: CI on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] paths-ignore: - - 'api/docs/**' - - 'build/charts/**' - - 'design/**' - - '**/*.md' - - '**/*.txt' - - '**/.gitignore' + - "api/docs/**" + - "build/charts/**" + - "design/**" + - "**/*.md" + - "**/*.txt" + - "**/.gitignore" env: - GO_VERSION: '1.23' + GO_VERSION: "1.23" jobs: ci-target-check: @@ -26,26 +26,27 @@ jobs: complex-test: ${{ steps.ci-target-check.outputs.complex-test }} steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: CI target check by path - uses: dorny/paths-filter@v3 - id: ci-target-check - with: - filters: | - build: '**' - bench: - - 'pkg/**' - - 'server/**' - - 'client/**' - - 'admin/**' - - 'api/converter/**' - - complex-test: - - 'server/backend/database/**' - - 'pkg/document/**' - - 'client/**' + - name: Checkout code + uses: actions/checkout@v4 + + - name: CI target check by path + uses: dorny/paths-filter@v3 + id: ci-target-check + with: + filters: | + build: '**' + bench: + - 'pkg/**' + - 'server/**' + - 'client/**' + - 'admin/**' + - 'api/converter/**' + + complex-test: + - 'test/complex/**' + - 'server/backend/database/**' + - 'pkg/document/**' + - 'client/**' build: name: build @@ -55,43 +56,43 @@ jobs: if: ${{ needs.ci-target-check.outputs.build == 'true' }} steps: - - name: Set up Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GO_VERSION }} + - name: Set up Go ${{ env.GO_VERSION }} + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} - - name: Setup buf action - uses: bufbuild/buf-setup-action@v1 - with: - github_token: ${{ github.token }} + - name: Setup buf action + uses: bufbuild/buf-setup-action@v1 + with: + github_token: ${{ github.token }} - - name: Check out code - uses: actions/checkout@v4 + - name: Check out code + uses: actions/checkout@v4 - - name: Get tools dependencies - run: make tools + - name: Get tools dependencies + run: make tools - - name: Lint - run: make lint + - name: Lint + run: make lint - - name: Lint proto files - uses: bufbuild/buf-lint-action@v1 + - name: Lint proto files + uses: bufbuild/buf-lint-action@v1 - - name: Build - run: make build + - name: Build + run: make build - - name: Stack - run: docker compose -f build/docker/docker-compose.yml up --build -d + - name: Stack + run: docker compose -f build/docker/docker-compose.yml up --build -d - - name: Test - run: go test -tags integration -race -coverprofile=coverage.txt -covermode=atomic -v ./... + - name: Test + run: go test -tags integration -race -coverprofile=coverage.txt -covermode=atomic -v ./... - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - with: - file: ./coverage.txt - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./coverage.txt + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} bench: name: bench @@ -102,38 +103,37 @@ jobs: if: ${{ needs.ci-target-check.outputs.bench == 'true' }} steps: - - - name: Set up Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Check out code - uses: actions/checkout@v4 - - - name: Stack - run: docker compose -f build/docker/docker-compose.yml up --build -d - - - name: Bench - run: make bench - - - name: Download previous benchmark data - uses: actions/cache@v3 - with: - path: ./cache - key: ${{ runner.os }}-benchmark - - - name: Store benchmark result - uses: benchmark-action/github-action-benchmark@v1 - if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} - with: - name: Go Benchmark - tool: 'go' - output-file-path: output.txt - external-data-json-path: ./cache/benchmark-data.json - fail-on-alert: false - github-token: ${{ secrets.GITHUB_TOKEN }} - comment-always: true + - name: Set up Go ${{ env.GO_VERSION }} + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Check out code + uses: actions/checkout@v4 + + - name: Stack + run: docker compose -f build/docker/docker-compose.yml up --build -d + + - name: Bench + run: make bench + + - name: Download previous benchmark data + uses: actions/cache@v3 + with: + path: ./cache + key: ${{ runner.os }}-benchmark + + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1 + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + with: + name: Go Benchmark + tool: "go" + output-file-path: output.txt + external-data-json-path: ./cache/benchmark-data.json + fail-on-alert: false + github-token: ${{ secrets.GITHUB_TOKEN }} + comment-always: true complex-test: name: complex-test @@ -143,35 +143,34 @@ jobs: if: ${{ needs.ci-target-check.outputs.complex-test == 'true' }} steps: + - name: Set up Go ${{ env.GO_VERSION }} + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} - - name: Set up Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v3 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Check out code - uses: actions/checkout@v4 + - name: Check out code + uses: actions/checkout@v4 - - name: Check Docker Compose Version - run: docker compose --version + - name: Check Docker Compose Version + run: docker compose --version - - name: Run the Config server, Shard 1 and Shard 2 - run: docker compose -f build/docker/sharding/docker-compose.yml up --build -d --wait config1 shard1-1 shard2-1 + - name: Run the Config server, Shard 1 and Shard 2 + run: docker compose -f build/docker/sharding/docker-compose.yml up --build -d --wait config1 shard1-1 shard2-1 - - name: Initialize the Config server - run: docker compose -f build/docker/sharding/docker-compose.yml exec config1 mongosh test /scripts/init-config1.js + - name: Initialize the Config server + run: docker compose -f build/docker/sharding/docker-compose.yml exec config1 mongosh test /scripts/init-config1.js - - name: Initialize the Shard 1 - run: docker compose -f build/docker/sharding/docker-compose.yml exec shard1-1 mongosh test /scripts/init-shard1-1.js + - name: Initialize the Shard 1 + run: docker compose -f build/docker/sharding/docker-compose.yml exec shard1-1 mongosh test /scripts/init-shard1-1.js - - name: Initialize the Shard 2 - run: docker compose -f build/docker/sharding/docker-compose.yml exec shard2-1 mongosh test /scripts/init-shard2-1.js + - name: Initialize the Shard 2 + run: docker compose -f build/docker/sharding/docker-compose.yml exec shard2-1 mongosh test /scripts/init-shard2-1.js - - name: Run the Mongos - run: docker compose -f build/docker/sharding/docker-compose.yml up --build -d --wait mongos1 + - name: Run the Mongos + run: docker compose -f build/docker/sharding/docker-compose.yml up --build -d --wait mongos1 - - name: Initialize the Mongos - run: docker compose -f build/docker/sharding/docker-compose.yml exec mongos1 mongosh test /scripts/init-mongos1.js + - name: Initialize the Mongos + run: docker compose -f build/docker/sharding/docker-compose.yml exec mongos1 mongosh test /scripts/init-mongos1.js - - name: Run the tests with complex tag - run: go test -tags complex -race -v ./test/complex/... + - name: Run the tests with complex tag + run: go test -tags complex -race -v ./test/complex/...