Skip to content

Commit

Permalink
Increase test timeouts
Browse files Browse the repository at this point in the history
This PR increases the timeouts for tests using TestTimeout, as well as the `go
test` timeout, to avoid frequent failures in slow machines.

Closes: google#611
  • Loading branch information
NightTsarina committed Dec 31, 2021
1 parent 7cd413d commit 6462f86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ $(DEPDIR)/%.d: ;
# This instruction loads any dependency includes for our targets.
-include $(patsubst %,$(DEPDIR)/%.d,$(TARGETS))

# Set the timeout for tests run under the race detector.
timeout := 120s
# Set the timeout for tests.
test_timeout := 20s
testrace_timeout := 4m
ifeq ($(CI),true)
timeout := 10m
test_timeout := 100s
testrace_timeout := 20m
endif
# Let the benchmarks run for a long time. The timeout is for the total time of
# all benchmarks, not per bench.
Expand Down Expand Up @@ -170,19 +172,19 @@ $(PREFIX)/bin/%: %

.PHONY: test check
check test: $(GOFILES) $(GOGENFILES) $(GOTESTFILES) | print-version $(LOGO_GO) .dep-stamp
go test $(GO_TEST_FLAGS) -gcflags "$(GO_GCFLAGS)" -timeout 10s ./...
go test $(GO_TEST_FLAGS) -gcflags "$(GO_GCFLAGS)" -timeout ${test_timeout} ./...

.PHONY: testrace
testrace: $(GOFILES) $(GOGENFILES) $(GOTESTFILES) | print-version $(LOGO_GO) .dep-stamp
go test $(GO_TEST_FLAGS) -gcflags "$(GO_GCFLAGS)" -timeout ${timeout} -race -v ./...
go test $(GO_TEST_FLAGS) -gcflags "$(GO_GCFLAGS)" -timeout ${testrace_timeout} -race -v ./...

.PHONY: smoke
smoke: $(GOFILES) $(GOGENFILES) $(GOTESTFILES) | print-version $(LOGO_GO) .dep-stamp
go test $(GO_TEST_FLAGS) -gcflags "$(GO_GCFLAGS)" -timeout 1s -test.short ./...

.PHONY: regtest
regtest: $(GOFILES) $(GOGENFILES) $(GOTESTFILES) | print-version $(LOGO_GO) .dep-stamp
go test $(GO_TEST_FLAGS) -gcflags "$(GO_GCFLAGS)" -v -timeout=${timeout} ./...
go test $(GO_TEST_FLAGS) -gcflags "$(GO_GCFLAGS)" -v -timeout=${testrace_timeout} ./...

TESTRESULTS ?= test-results
TESTCOVERPROFILE ?= out.coverprofile
Expand Down
2 changes: 1 addition & 1 deletion internal/mtail/examples_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"golang.org/x/sys/unix"
)

const exampleTimeout = 2 * time.Second
const exampleTimeout = 10 * time.Second

var exampleProgramTests = []struct {
programfile string // Example program file.
Expand Down

0 comments on commit 6462f86

Please sign in to comment.