Commit 974923a
authored
feat(test): simplify macOS testing with automatic cross-compilation (#9585)
## Summary
This PR eliminates manual setup for running integration tests on macOS
and introduces a unified test interface via Make.
### Key Features
**1. Automatic Cross-Compilation (macOS)**
Previously, macOS developers had to manually cross-compile a Linux
binary and juggle environment variables. Now, `make install` handles
everything automatically.
**2. Unified Test Interface**
A single `make test` entry point that routes to the appropriate test
runner based on variables:
```bash
# Run all tests (default)
make test
# Use variables to control what runs
make test SUITE=systest # Run systest suite via t/ runner
make test TAGS=integration2 # Run integration2 tests via go test
make test FUZZ=1 PKG=dql # Fuzz test the dql package
make test TAGS=upgrade PKG=acl # Run ACL upgrade tests
```
**3. Convenient Shortcuts**
Every SUITE and TAGS value has a corresponding helper target:
```bash
# SUITE-based targets
make test-all # All test suites (i.e. 'make test SUITE=all')
make test-unit # Unit tests, no Docker (i.e. 'make test SUITE=unit')
make test-core # Core tests (i.e. 'make test SUITE=core')
make test-systest # System integration tests (i.e. 'make test SUITE=systest')
make test-vector # Vector search tests (i.e. 'make test SUITE=vector')
make test-ldbc # LDBC benchmark tests (i.e. 'make test SUITE=ldbc')
make test-load # Heavy load tests (i.e. 'make test SUITE=load')
# TAGS-based targets
make test-integration # Integration tests (i.e. 'make test TAGS=integration')
make test-integration2 # Integration2 tests (i.e. 'make test TAGS=integration2')
make test-upgrade # Upgrade tests (i.e. 'make test TAGS=upgrade')
# Other
make test-fuzz # Fuzz tests (i.e. 'make test FUZZ=1')
make test-benchmark PKG=posting # Benchmark a specific package
```
**4. Dynamic Discovery**
`make help` dynamically discovers available SUITE values from `t/t.go`
and TAGS values from test file build directives.
### Changes
- **Build automation**: `make install` auto-detects the OS and builds
both native and Linux binaries on non-Linux systems
- **Unified test target**: `make test` routes to t/ runner or `go test`
based on `SUITE`, `TAGS`, `FUZZ` variables
- **Complete helper targets**: Every SUITE and TAGS value has a
corresponding `test-*` target
- **Dynamic help**: `make help` shows available SUITE/TAGS values
discovered from the codebase
- **Environment variable**: Introduced `LINUX_GOBIN` to specify where
Linux binaries are stored for Docker tests
- **Docker compose**: All systest docker-compose files updated to use
`${LINUX_GOBIN:-$GOPATH/bin}` for binary mounting
- **Documentation**: Updated TESTING.md, CONTRIBUTING.md with
comprehensive examples
### Before (macOS)
```bash
make install
mv $GOPATH/bin/dgraph $GOPATH/bin/dgraph_osx
GOOS=linux make install
mv $GOPATH/bin/linux_arm64/dgraph $GOPATH/bin/dgraph
export DGRAPH_BINARY=$GOPATH/bin/dgraph_osx
cd t && ./t --pkg=<package>
```
### After (macOS or Linux)
```bash
make install
make test SUITE=systest PKG=systest/export
```
### `make help` Output
```
Usage: make [target] [VAR=value ...]
Targets:
all Build all targets
dgraph Build dgraph binary
docker-image Build Docker image (dgraph/dgraph:$VERSION)
help Show available targets and variables
image-local Alias for local-image
install Install dgraph binary
local-image Build local Docker image (dgraph/dgraph:local)
test-all All test suites via t/ runner (i.e. 'make test SUITE=all')
test-benchmark Go benchmarks (i.e. 'go test -bench')
test-core Core tests (i.e. 'make test SUITE=core')
test-fuzz Fuzz tests, auto-discovers packages (i.e. 'make test FUZZ=1')
test-integration Integration tests (i.e. 'make test TAGS=integration')
test-integration2 Integration2 tests via dgraphtest (i.e. 'make test TAGS=integration2')
test-ldbc LDBC benchmark tests (i.e. 'make test SUITE=ldbc')
test-load Heavy load tests (i.e. 'make test SUITE=load')
test-systest System integration tests (i.e. 'make test SUITE=systest')
test-unit Unit tests, no Docker (i.e. 'make test SUITE=unit')
test-upgrade Upgrade tests (i.e. 'make test TAGS=upgrade')
test-vector Vector search tests (i.e. 'make test SUITE=vector')
test Run tests (see 'make help' for options)
uninstall Uninstall dgraph binary
version Show build version info
Variables that can be passed to 'test':
SUITE Select t/ runner suite (e.g., make test SUITE=systest)
TAGS Go build tags - bypasses t/ runner (e.g., make test TAGS=integration2)
PKG Limit to specific package (e.g., make test PKG=systest/export)
TEST Run specific test function (e.g., make test TEST=TestGQLSchema)
FUZZ Enable fuzz testing (e.g., make test FUZZ=1)
FUZZTIME Fuzz duration per package (e.g., make test FUZZ=1 FUZZTIME=60s)
Available SUITE values: all ldbc load unit systest vector core
Available TAGS values: integration integration2 upgrade
Examples:
make test TAGS=integration2 PKG=systest/vector # integration2 tests for vector
make test TAGS=upgrade PKG=acl TEST=TestACL # specific upgrade test
make test FUZZ=1 PKG=dql FUZZTIME=30s # fuzz dql package for 30s
make test SUITE=systest PKG=systest/backup/filesystem # systest for backup pkg
make test-benchmark PKG=posting # benchmark posting package
```
## Test plan
- [x] Run `make install` on macOS and verify both binaries are created
- [x] Run `make check` in `t/` directory
- [x] Verify `make test-unit` routes to t/ runner with `--suite=unit`
- [x] Verify `make test TAGS=integration2 PKG=types` runs go test
directly
- [x] Verify `make test FUZZ=1 PKG=dql FUZZTIME=5s` runs fuzz tests
- [x] Verify `make test-benchmark PKG=types` runs benchmarks
- [x] Verify `make help` shows all targets, variables, and discovered
SUITE/TAGS values
- [x] Verify every SUITE value has a corresponding `test-*` target
- [x] Verify every TAGS value has a corresponding `test-*` target
- [x] Verify Linux CI still works as expected1 parent 408e8f8 commit 974923a
44 files changed
Lines changed: 2420 additions & 213 deletions
File tree
- dgraph
- systest
- 1million
- 21million
- bulk
- live
- acl/restore
- audit_encrypted
- audit
- backup
- advanced-scenarios
- 127-Namespace
- acl-nonAcl
- deleted-namespace
- encryption
- filesystem
- minio-large
- minio
- multi-tenancy
- nfs-backup
- bgindex
- bulk_live
- bulk
- live
- cdc
- cloud
- export
- group-delete
- ldbc
- loader-benchmark
- loader
- multi-tenancy
- online-restore
- plugin
- t
- scripts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
157 | 162 | | |
158 | 163 | | |
159 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
13 | 27 | | |
14 | 28 | | |
15 | 29 | | |
| |||
20 | 34 | | |
21 | 35 | | |
22 | 36 | | |
23 | | - | |
| 37 | + | |
24 | 38 | | |
25 | 39 | | |
26 | | - | |
| 40 | + | |
27 | 41 | | |
28 | 42 | | |
29 | 43 | | |
30 | 44 | | |
31 | 45 | | |
32 | 46 | | |
33 | 47 | | |
34 | | - | |
| 48 | + | |
35 | 49 | | |
36 | 50 | | |
37 | 51 | | |
| |||
40 | 54 | | |
41 | 55 | | |
42 | 56 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
46 | 68 | | |
47 | 69 | | |
48 | | - | |
| 70 | + | |
49 | 71 | | |
50 | 72 | | |
51 | 73 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
56 | 80 | | |
57 | | - | |
58 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
59 | 155 | | |
60 | 156 | | |
61 | 157 | | |
62 | 158 | | |
63 | 159 | | |
64 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
65 | 164 | | |
66 | | - | |
| 165 | + | |
67 | 166 | | |
68 | 167 | | |
69 | 168 | | |
| |||
93 | 192 | | |
94 | 193 | | |
95 | 194 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
0 commit comments