Skip to content

CBG-4686 increase wait time for windows/race #7600

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

Merged
merged 2 commits into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions base/util_test_norace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2025-Present Couchbase, Inc.
//
// Use of this software is governed by the Business Source License included
// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
// in that file, in accordance with the Business Source License, use of this
// software will be governed by the Apache License, Version 2.0, included in
// the file licenses/APL2.txt.

//go:build !race
// +build !race

package base

import "testing"

// IsRaceDetectorEnabled returns true if compiled with -race. Intended to be used for testing only.
func IsRaceDetectorEnabled(t *testing.T) bool {
return false
}
19 changes: 19 additions & 0 deletions base/util_test_race.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2025-Present Couchbase, Inc.
//
// Use of this software is governed by the Business Source License included
// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
// in that file, in accordance with the Business Source License, use of this
// software will be governed by the Apache License, Version 2.0, included in
// the file licenses/APL2.txt.

//go:build race
// +build race

package base

import "testing"

// IsRaceDetectorEnabled returns true if compiled with -race. Intended to be used for testing only
func IsRaceDetectorEnabled(t *testing.T) bool {
return true
}
13 changes: 10 additions & 3 deletions db/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"encoding/json"
"fmt"
"log"
"runtime"
"runtime/debug"
"sort"
"strconv"
Expand Down Expand Up @@ -3363,6 +3364,12 @@ func TestUpdateCalculatedStatsPanic(t *testing.T) {
}

func Test_waitForBackgroundManagersToStop(t *testing.T) {
// use testing/synctest to have fake time once go 1.25 is available. In the meantime, windows and -race are
// slow enough thatthe time is increased, but this keeps interactive testing fast.
waitTime := 50 * time.Millisecond
if runtime.GOOS == "windows" || base.IsRaceDetectorEnabled(t) {
waitTime = 1 * time.Second
}
t.Run("single unstoppable process", func(t *testing.T) {
bgMngr := &BackgroundManager{
name: "test_unstoppable_runner",
Expand All @@ -3375,7 +3382,7 @@ func Test_waitForBackgroundManagersToStop(t *testing.T) {
require.NoError(t, err)

startTime := time.Now()
deadline := 50 * time.Millisecond
deadline := waitTime
waitForBackgroundManagersToStop(ctx, deadline, []*BackgroundManager{bgMngr})
assert.Greater(t, time.Since(startTime), deadline)
assert.Equal(t, BackgroundProcessStateStopping, bgMngr.GetRunState())
Expand All @@ -3393,7 +3400,7 @@ func Test_waitForBackgroundManagersToStop(t *testing.T) {
require.NoError(t, err)

startTime := time.Now()
deadline := 100 * time.Millisecond
deadline := waitTime
waitForBackgroundManagersToStop(ctx, deadline, []*BackgroundManager{bgMngr})
assert.Less(t, time.Since(startTime), deadline)
assert.Equal(t, BackgroundProcessStateStopped, bgMngr.GetRunState())
Expand Down Expand Up @@ -3421,7 +3428,7 @@ func Test_waitForBackgroundManagersToStop(t *testing.T) {
require.NoError(t, err)

startTime := time.Now()
deadline := 100 * time.Millisecond
deadline := waitTime
waitForBackgroundManagersToStop(ctx, deadline, []*BackgroundManager{stoppableBgMngr, unstoppableBgMngr})
assert.Greater(t, time.Since(startTime), deadline)
assert.Equal(t, BackgroundProcessStateStopped, stoppableBgMngr.GetRunState())
Expand Down
Loading