aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/insert_module_test.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-08-22 15:23:22 -0400
committerGopher Robot <gobot@golang.org>2023-08-23 16:58:07 +0000
commit76f4137fe5bb3d97d1ffa28cb490e71a96d5dcb9 (patch)
treec9df4b3814fad5dec21b74dfc3b4c52fb35ce5b1 /internal/postgres/insert_module_test.go
parentedcdbe543d8f35f3b18c96a63080f96b3912a7d9 (diff)
downloadgo-x-pkgsite-76f4137fe5bb3d97d1ffa28cb490e71a96d5dcb9.tar.xz
all: remove arbitrary hard-coded timeouts in tests
If a test times out, that implies that it got stuck on something. By default, the Go testing package dumps goroutines when its own timeout is passed, which prints a goroutine dump, helping to reveal what was stuck. Adding an arbitrary timeout on top of the testing package's own timeout is, in my experience, almost always counterproductive. If the arbitrary timeout catches a real hang, it causes the test to fail instead of dumping goroutines, making it much harder to see what was stuck. On the other hand, if the timeouts are set aggressively enough to make the test fail early, they are often too aggressive for CI testing, causing flakes that then have to be triaged on an ongoing basis. On balance, the value of saving a minute or two for developers who have introduced a hang is not worth the cost of suppressing debugging information and causing flakes that have to be triaged. Fixes #61556. For #59347. Change-Id: I0263d0d9b18283470f100e5a0155818b87b5312f Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/521837 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'internal/postgres/insert_module_test.go')
-rw-r--r--internal/postgres/insert_module_test.go15
1 files changed, 5 insertions, 10 deletions
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go
index ee3c25a2..aa4fed40 100644
--- a/internal/postgres/insert_module_test.go
+++ b/internal/postgres/insert_module_test.go
@@ -195,8 +195,7 @@ func TestUpsertModule(t *testing.T) {
t.Parallel()
testDB, release := acquire(t)
defer release()
- ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
- defer cancel()
+ ctx := context.Background()
m := sample.Module("upsert.org", "v1.2.3", "dir/p")
@@ -285,8 +284,7 @@ func TestInsertModuleNewCoverage(t *testing.T) {
t.Parallel()
testDB, release := acquire(t)
defer release()
- ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
- defer cancel()
+ ctx := context.Background()
m := sample.DefaultModule()
newCoverage := licensecheck.Coverage{
@@ -447,8 +445,7 @@ func TestPostgres_NewerAlternative(t *testing.T) {
// alternative version.
testDB, release := acquire(t)
defer release()
- ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
- defer cancel()
+ ctx := context.Background()
const (
altVersion = "v1.2.0"
@@ -488,8 +485,7 @@ func TestMakeValidUnicode(t *testing.T) {
t.Parallel()
testDB, release := acquire(t)
defer release()
- ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
- defer cancel()
+ ctx := context.Background()
db := testDB.Underlying()
@@ -529,8 +525,7 @@ func TestLock(t *testing.T) {
// that wants the lock eventually gets it.
testDB, release := acquire(t)
defer release()
- ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
- defer cancel()
+ ctx := context.Background()
db := testDB.Underlying()