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/.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 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 }