Skip to content

Commit 31e6f7d

Browse files
committed
docs(testing): add make examples and remove completed improvements
Add "With make:" examples alongside every go test and ./t command block in TESTING.md, showing how to run the same tests via make test with arguments or dedicated test-* targets. This makes the make interface discoverable inline rather than only in the Quick Start. Remove the "Completed Improvements" section from Future Improvement Ideas — these items are now reflected throughout the guide itself.
1 parent 793fe9c commit 31e6f7d

1 file changed

Lines changed: 104 additions & 35 deletions

File tree

TESTING.md

Lines changed: 104 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ Use `go test` to run one easy test on types package:
273273

274274
```bash
275275
go test -v ./types/... -run TestConvert
276+
277+
# Or with make (runs all unit tests, not just one)
278+
make test-unit
276279
```
277280

278281
**Expected output:**
@@ -294,6 +297,9 @@ ok github.com/dgraph-io/dgraph/v25/types (cached)
294297
295298
```bash
296299
cd t && go build . && ./t --test=TestGQLSchema
300+
301+
# Or with make
302+
make test TEST=TestGQLSchema
297303
```
298304

299305
If both pass, you're ready to run all test types!
@@ -501,6 +507,19 @@ go test ./types/...
501507
go test -v ./types/... -run TestConvert
502508
```
503509

510+
**With make:**
511+
512+
```bash
513+
# Run all unit tests (no Docker, no build tags)
514+
make test-unit
515+
516+
# Run unit tests for a specific package
517+
make test-unit PKG=types
518+
519+
# Run a specific unit test
520+
make test-unit PKG=types TEST=TestConvert
521+
```
522+
504523
### Identifying a unit test
505524

506525
- No `//go:build` tag at the top of the file = unit test
@@ -586,6 +605,19 @@ cd t && go build .
586605
./t -r
587606
```
588607

608+
**With make:**
609+
610+
```bash
611+
# Run a suite
612+
make test SUITE=core
613+
614+
# Run specific package
615+
make test SUITE=integration PKG=systest/export
616+
617+
# Run single test
618+
make test TEST=TestExportAndLoadJson
619+
```
620+
589621
### Key Flags
590622

591623
| Flag | Description |
@@ -621,6 +653,16 @@ cd t && go build .
621653
./t --pkg=systest/export --keep
622654
```
623655

656+
**With make:**
657+
658+
```bash
659+
# Run all tests in a package (make builds the runner automatically)
660+
make test SUITE=integration PKG=systest/export
661+
662+
# Run single test
663+
make test TEST=TestExportAndLoadJson
664+
```
665+
624666
### Method 2: Manual Cluster + go test
625667

626668
For fine-grained control, manually start a cluster and run tests against it.
@@ -693,6 +735,19 @@ Using `t/` runner:
693735
./t --suite=systest
694736
```
695737

738+
**With make:**
739+
740+
```bash
741+
# Run all systest packages
742+
make test-systest
743+
744+
# Run specific systest package
745+
make test SUITE=systest PKG=systest/export
746+
747+
# Run specific test by name
748+
make test TEST=TestExportAndLoadJson
749+
```
750+
696751
### Key Environment Variables
697752

698753
| Variable | Purpose | Set by |
@@ -738,6 +793,19 @@ go test -v --tags=integration2 ./systest/integration2/
738793
go test -v --tags=integration2 --run '^TestName$' ./pkg/
739794
```
740795

796+
**With make:**
797+
798+
```bash
799+
# Run all integration2 tests
800+
make test-integration2
801+
802+
# Run integration2 tests for a specific package
803+
make test TAGS=integration2 PKG=systest/vector
804+
805+
# Run a specific integration2 test
806+
make test TAGS=integration2 PKG=systest/vector TEST=TestVectorSearch
807+
```
808+
741809
### Version & Binary Management
742810

743811
**Automatic version handling:**
@@ -948,6 +1016,19 @@ go test -v --tags=upgrade ./worker/
9481016
go test -v --tags=upgrade -run '^TestUpgradeName$' ./pkg/
9491017
```
9501018

1019+
**With make:**
1020+
1021+
```bash
1022+
# Run all upgrade tests
1023+
make test-upgrade
1024+
1025+
# Run upgrade tests for a specific package
1026+
make test TAGS=upgrade PKG=acl
1027+
1028+
# Run a specific upgrade test
1029+
make test TAGS=upgrade PKG=acl TEST=TestACL
1030+
```
1031+
9511032
### Where Upgrade Tests Live
9521033

9531034
| Package | Tests |
@@ -1222,6 +1303,19 @@ go test -v --tags=integration --run 'TestPluginTestSuite/TestPasswordReturn/subt
12221303
go test -v --tags=upgrade --run 'TestPluginTestSuite/TestPasswordReturn' ./systest/plugin/
12231304
```
12241305

1306+
**With make:**
1307+
1308+
```bash
1309+
# Run the plugin systest package via t/ runner
1310+
make test SUITE=systest PKG=systest/plugin
1311+
1312+
# Run a specific test
1313+
make test SUITE=systest PKG=systest/plugin TEST=TestPluginTestSuite/TestPasswordReturn
1314+
1315+
# Run in upgrade mode
1316+
make test TAGS=upgrade PKG=systest/plugin TEST=TestPluginTestSuite/TestPasswordReturn
1317+
```
1318+
12251319
**When NOT to use:**
12261320

12271321
- Simple one-off tests → use regular `func TestX(t *testing.T)`
@@ -1258,6 +1352,16 @@ go test -v ./dql -fuzz=Fuzz -fuzztime=5m
12581352
go test -v ./dql -fuzz=Fuzz -fuzztime=300s -fuzzminimizetime=120s
12591353
```
12601354

1355+
**With make:**
1356+
1357+
```bash
1358+
# Run all fuzz tests (default 300s per package)
1359+
make test-fuzz
1360+
1361+
# Fuzz a specific package with custom duration
1362+
make test FUZZ=1 PKG=dql FUZZTIME=5m
1363+
```
1364+
12611365
### CI Workflow
12621366

12631367
- `ci-dgraph-fuzz.yml` (runs on PRs)
@@ -1276,41 +1380,6 @@ go test -v ./dql -fuzz=Fuzz -fuzztime=300s -fuzzminimizetime=120s
12761380

12771381
## Future Improvement Ideas
12781382

1279-
### ✅ Completed Improvements
1280-
1281-
The following items from the original wishlist have been implemented:
1282-
1283-
- **✅ OS detection and automatic binary handling:** The Makefile now detects the host OS at runtime
1284-
and automatically builds the correct binaries. On macOS, `make install` builds both native and
1285-
Linux binaries without manual intervention.
1286-
1287-
- **✅ Automatic binary path management:** The `LINUX_GOBIN` environment variable is automatically
1288-
set based on OS. Docker Compose files use `${LINUX_GOBIN:-$GOPATH/bin}` to mount the correct
1289-
binary.
1290-
1291-
- **✅ No manual setup scripts required:** The `make test` target now depends on `dgraph-installed`
1292-
which automatically builds binaries if missing. Dependency checking scripts in `t/scripts/` can
1293-
auto-install missing tools with `AUTO_INSTALL=true`.
1294-
1295-
- **✅ Prerequisites handled automatically:** Running `make test` validates dependencies and builds
1296-
required binaries before running tests.
1297-
1298-
- **✅ Unified test interface:** A single `make test` entry point that accepts arguments to run any
1299-
test type (unit, integration, integration2, upgrade, fuzz) with environment variables for control.
1300-
The default (`make test` with no args) runs `integration` suite plus `integration2` for a fast
1301-
feedback loop (~30 min). Use `make test-all` to run every test.
1302-
1303-
- **✅ Example commands that "just work":** The following now work as expected:
1304-
1305-
```bash
1306-
make test SUITE=systest
1307-
make test FUZZ=1 PKG=dql
1308-
make test TAGS=upgrade PKG=acl
1309-
make test SUITE=systest PKG=systest/plugin
1310-
```
1311-
1312-
### Remaining Ideas
1313-
13141383
The following improvements could still enhance the developer experience:
13151384

13161385
- **Extend t/ runner:** Have the `t/` runner also handle unit and integration2 tests, providing a

0 commit comments

Comments
 (0)