Skip to content

Commit 1679571

Browse files
committed
feat(test): add --timeout flag to t/ runner and make test
Add a configurable per-package test timeout flag to the t/ runner. Previously the timeout was hardcoded to 30m (or 180m with --race), which caused the 21million/live test to time out on slower machines. Usage: make test TIMEOUT=90m cd t && ./t --suite=all --timeout=60m Defaults remain unchanged: 30m normal, 180m with --race. An explicit --timeout overrides both.
1 parent cc9e2cb commit 1679571

4 files changed

Lines changed: 26 additions & 14 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ make test-upgrade # Upgrade tests
154154

155155
# Use variables for more control
156156
make test TAGS=integration2 PKG=systest/vector
157+
make test TIMEOUT=90m # Override per-package timeout (default: 30m)
157158
```
158159

159160
Run `make help` to see all available targets and variables.

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ else
9898
endif
9999
else
100100
@echo "Running test suite: $(or $(SUITE),all)"
101-
$(MAKE) -C t test args="--suite=$(or $(SUITE),all) $(if $(PKG),--pkg=\"$(PKG)\") $(if $(TEST),--test=\"$(TEST)\")"
101+
$(MAKE) -C t test args="--suite=$(or $(SUITE),all) $(if $(PKG),--pkg=\"$(PKG)\") $(if $(TEST),--test=\"$(TEST)\") $(if $(TIMEOUT),--timeout=$(TIMEOUT))"
102102
endif
103103

104104
.PHONY: test-all
@@ -205,6 +205,7 @@ help: ## Show available targets and variables
205205
@echo " TAGS Go build tags - bypasses t/ runner (e.g., make test TAGS=integration2)"
206206
@echo " PKG Limit to specific package (e.g., make test PKG=systest/export)"
207207
@echo " TEST Run specific test function (e.g., make test TEST=TestGQLSchema)"
208+
@echo " TIMEOUT Per-package test timeout (e.g., make test TIMEOUT=60m). Default: 30m"
208209
@echo " FUZZ Enable fuzz testing (e.g., make test FUZZ=1)"
209210
@echo " FUZZTIME Fuzz duration per package (e.g., make test FUZZ=1 FUZZTIME=60s)"
210211
@echo ""
@@ -223,4 +224,5 @@ help: ## Show available targets and variables
223224
@echo " make test TAGS=upgrade PKG=acl TEST=TestACL # specific upgrade test"
224225
@echo " make test FUZZ=1 PKG=dql FUZZTIME=30s # fuzz dql package for 30s"
225226
@echo " make test SUITE=systest PKG=systest/backup/filesystem # systest for backup pkg"
227+
@echo " make test TIMEOUT=90m # all suites with 90m timeout"
226228
@echo " make test-benchmark PKG=posting # benchmark posting package"

TESTING.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ For more control, pass variables to `make test`:
335335
| `TAGS` | Go build tags - bypasses t/ runner | `make test TAGS=integration2` |
336336
| `PKG` | Limit to specific package | `make test PKG=systest/export` |
337337
| `TEST` | Run specific test function | `make test TEST=TestGQLSchema` |
338+
| `TIMEOUT` | Per-package test timeout | `make test TIMEOUT=90m` |
338339
| `FUZZ` | Enable fuzz testing | `make test FUZZ=1` |
339340
| `FUZZTIME` | Fuzz duration per package | `make test FUZZ=1 FUZZTIME=60s` |
340341

@@ -578,15 +579,16 @@ cd t && go build .
578579

579580
### Key Flags
580581

581-
| Flag | Description |
582-
| ------------- | ------------------------------------------------------------------ |
583-
| `--suite=X` | Select test suite(s): all, ldbc, load, unit, systest, vector, core |
584-
| `--pkg=X` | Run specific package |
585-
| `--test=X` | Run specific test function |
586-
| `-j=N` | Concurrency (default: 1) |
587-
| `--keep` | Keep cluster running after tests |
588-
| `-r` | Remove all test containers |
589-
| `--skip-slow` | Skip slow packages |
582+
| Flag | Description |
583+
| --------------- | ------------------------------------------------------------------ |
584+
| `--suite=X` | Select test suite(s): all, ldbc, load, unit, systest, vector, core |
585+
| `--pkg=X` | Run specific package |
586+
| `--test=X` | Run specific test function |
587+
| `--timeout=X` | Per-package timeout (e.g. 60m, 2h). Default: 30m (180m with --race)|
588+
| `-j=N` | Concurrency (default: 1) |
589+
| `--keep` | Keep cluster running after tests |
590+
| `-r` | Remove all test containers |
591+
| `--skip-slow` | Skip slow packages |
590592

591593
---
592594

t/t.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ var (
9292
tmp = pflag.String("tmp", "", "Temporary directory used to download data.")
9393
downloadResources = pflag.BoolP("download", "d", true,
9494
"Flag to specify whether to download resources or not")
95-
race = pflag.Bool("race", false, "Set true to build with race")
95+
race = pflag.Bool("race", false, "Set true to build with race")
96+
testTimeout = pflag.String("timeout", "",
97+
"Timeout for each test package (e.g. 60m, 2h). Defaults to 30m (180m with --race).")
9698
skip = pflag.String("skip", "",
9799
"comma separated list of packages that needs to be skipped. "+
98100
"Package Check uses string.Contains(). Please check the flag carefully")
@@ -423,12 +425,17 @@ func sanitizeFilename(pkg string) string {
423425
func runTestsFor(ctx context.Context, pkg, prefix string, xmlFile string) error {
424426
args := []string{"gotestsum", "--junitfile", xmlFile, "--format", "standard-verbose", "--max-fails", "1", "--",
425427
"-v", "-failfast", "-tags=integration"}
426-
if *race {
428+
switch {
429+
case *testTimeout != "":
430+
args = append(args, "-timeout", *testTimeout)
431+
case *race:
427432
args = append(args, "-timeout", "180m")
433+
default:
434+
args = append(args, "-timeout", "30m")
435+
}
436+
if *race {
428437
// Todo: There are few race errors in tests itself. Enable this once that is fixed.
429438
// args = append(args, "-race")
430-
} else {
431-
args = append(args, "-timeout", "30m")
432439
}
433440

434441
if *count > 0 {

0 commit comments

Comments
 (0)