From ccd464225a0c89aa60ccf9977187cbde1297a2ea Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 9 Oct 2023 10:38:01 +0300 Subject: [PATCH 1/2] PMM-7 fix tests and a small improvement. (#720) * PMM-7 fix tests and a small improvement. * PMM-7 use docker compose v2. * PMM-7 add extra wait. * PMM-7 stabilize tests. --- .github/workflows/go.yml | 1 + Makefile | 4 ++-- exporter/currentop_collector_test.go | 4 ++-- exporter/v1_compatibility.go | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5632159ea..839eb9603 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -41,5 +41,6 @@ jobs: - name: Test run: | TEST_MONGODB_IMAGE=${{ matrix.image }} make test-cluster + sleep 10 make test-race make test-cluster-clean diff --git a/Makefile b/Makefile index 47b608827..65d91fcc1 100644 --- a/Makefile +++ b/Makefile @@ -104,7 +104,7 @@ test-race: env ## Run all tests with race flag. go test -race -v -timeout 30s ./... test-cluster: env ## Starts MongoDB test cluster. Use env var TEST_MONGODB_IMAGE to set flavor and version. Example: TEST_MONGODB_IMAGE=mongo:3.6 make test-cluster - docker-compose up -d + docker compose up -d --wait test-cluster-clean: env ## Stops MongoDB test cluster. - docker-compose down --remove-orphans + docker compose down --remove-orphans diff --git a/exporter/currentop_collector_test.go b/exporter/currentop_collector_test.go index 5e9d07917..da8b432fa 100644 --- a/exporter/currentop_collector_test.go +++ b/exporter/currentop_collector_test.go @@ -31,7 +31,7 @@ import ( ) func TestCurrentopCollector(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() var wg sync.WaitGroup @@ -48,7 +48,7 @@ func TestCurrentopCollector(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - for i := 0; i < 3; i++ { + for i := 0; i < 300; i++ { coll := fmt.Sprintf("testcol_%02d", i) _, err := database.Collection(coll).InsertOne(ctx, bson.M{"f1": 1, "f2": "2"}) assert.NoError(t, err) diff --git a/exporter/v1_compatibility.go b/exporter/v1_compatibility.go index 69589c4fd..55f9274ad 100644 --- a/exporter/v1_compatibility.go +++ b/exporter/v1_compatibility.go @@ -971,7 +971,7 @@ func replSetMetrics(m bson.M) []prometheus.Metric { for _, m := range repl.Members { if m.StateStr == "PRIMARY" { primaryOpTime = m.OptimeDate.Time() - gotPrimary = true + gotPrimary = !primaryOpTime.IsZero() break } From a1a34274a04f7c21cc0157b83c3b77a0a18137b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 01:48:47 +0300 Subject: [PATCH 2/2] Bump docker/setup-qemu-action from 2 to 3 (#712) Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2 to 3. - [Release notes](https://github.com/docker/setup-qemu-action/releases) - [Commits](https://github.com/docker/setup-qemu-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/setup-qemu-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee16b103f..05c8d0c35 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx id: buildx