@@ -18,11 +18,20 @@ ifeq ($(GOPATH),)
1818 $(error GOPATH is not set. Please set it explicitly, e.g. export GOPATH=$$HOME/go)
1919endif
2020
21- # On non-Linux systems, use a separate directory for Linux binaries
21+ # On non-Linux systems, use a separate directory for Linux binaries and
22+ # a cross-compiler so that CGO is available (required for plugin support).
2223ifeq ($(GOHOSTOS ) ,linux)
2324 export LINUX_GOBIN ?= $(GOPATH ) /bin
25+ LINUX_CC ?= gcc
2426else
2527 export LINUX_GOBIN ?= $(GOPATH ) /linux_$(GOHOSTARCH )
28+ ifeq ($(GOHOSTARCH),arm64)
29+ LINUX_CC ?= aarch64-unknown-linux-gnu-gcc
30+ else ifeq ($(GOHOSTARCH),amd64)
31+ LINUX_CC ?= x86_64-unknown-linux-gnu-gcc
32+ else
33+ LINUX_CC ?= gcc
34+ endif
2635endif
2736
2837# #####################
@@ -60,7 +69,7 @@ install: ## Install dgraph binary
6069ifneq ($(GOHOSTOS ) ,linux)
6170 @mkdir -p $(LINUX_GOBIN)
6271 @echo "Installing dgraph (linux/$(GOHOSTARCH))..."
63- @GOOS=linux GOARCH=$(GOHOSTARCH) $( MAKE) -C dgraph dgraph
72+ @GOOS=linux GOARCH=$(GOHOSTARCH) CGO_ENABLED=1 CC=$(LINUX_CC) $( MAKE) -C dgraph BUILD_TAGS= EXTLDFLAGS=-fuse-ld=bfd dgraph
6473 @mv dgraph/dgraph $(LINUX_GOBIN)/dgraph
6574 @echo "Installed dgraph (linux/$(GOHOSTARCH)) to $(LINUX_GOBIN)/dgraph"
6675endif
@@ -73,13 +82,18 @@ uninstall: ## Uninstall dgraph binary
7382
7483.PHONY : dgraph-installed
7584dgraph-installed :
76- @if [ ! -f " $( GOPATH) /bin/dgraph" ] || [ ! -f " $( LINUX_GOBIN) /dgraph" ]; then \
77- echo " Dgraph binary missing, running make install..." ; \
78- $(MAKE ) install; \
79- fi
85+ $(MAKE ) install
86+
87+ .PHONY : check-deps
88+ check-deps : # # Check test dependencies (pass AUTO_INSTALL=true to auto-install missing ones)
89+ $(MAKE ) -C t check-deps
90+
91+ .PHONY : setup
92+ setup : # # Install all test dependencies automatically
93+ $(MAKE ) check-deps AUTO_INSTALL=true
8094
8195.PHONY : test
82- test : dgraph-installed local-image # # Run tests (see 'make help' for options )
96+ test : check-deps dgraph-installed local-image # # Run tests (default: integration + integration2 )
8397ifdef TAGS
8498 @echo "Running tests with tags: $(TAGS)"
8599 go test -v --tags="$(TAGS)" \
@@ -97,62 +111,83 @@ else
97111 done
98112endif
99113else
100- @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)\")"
114+ ifdef SUITE
115+ @echo "Running test suite: $(SUITE)"
116+ $(MAKE) -C t test args="--suite=$(SUITE) $(if $(PKG),--pkg=\"$(PKG)\") $(if $(TEST),--test=\"$(TEST)\") $(if $(TIMEOUT),--timeout=$(TIMEOUT))"
117+ else
118+ @echo "Running test suite: integration"
119+ $(MAKE) -C t test args="--suite=integration $(if $(PKG),--pkg=\"$(PKG)\") $(if $(TEST),--test=\"$(TEST)\") $(if $(TIMEOUT),--timeout=$(TIMEOUT))"
120+ @echo "Running integration2 tests..."
121+ go test -v --tags="integration2" \
122+ $(if $(TEST),--run="$(TEST)") \
123+ $(if $(PKG),./$(PKG)/...,./...)
124+ endif
102125endif
103-
104- .PHONY : test-all
105- test-all : # # All test suites via t/ runner (i.e. 'make test SUITE=all')
106- @SUITE=all $(MAKE ) test
107126
108127.PHONY : test-unit
109- test-unit : # # Unit tests, no Docker (i.e. 'make test SUITE=unit')
128+ test-unit : # # True unit tests only — no Docker, no integration build tag (i.e. 'make test SUITE=unit')
129+ $(if $(filter command line,$(origin SUITE ) ) ,$(error SUITE= cannot be passed to test-unit; use 'make test SUITE=...' instead) )
110130 @SUITE=unit $(MAKE ) test
111131
132+ .PHONY : test-integration
133+ test-integration : # # Integration tests via t/ runner with Docker (i.e. 'make test SUITE=integration')
134+ $(if $(filter command line,$(origin SUITE ) ) ,$(error SUITE= cannot be passed to test-integration; use 'make test SUITE=...' instead) )
135+ @SUITE=integration $(MAKE ) test
136+
112137.PHONY : test-core
113138test-core : # # Core tests (i.e. 'make test SUITE=core')
139+ $(if $(filter command line,$(origin SUITE ) ) ,$(error SUITE= cannot be passed to test-core; use 'make test SUITE=...' instead) )
114140 @SUITE=core $(MAKE ) test
115141
116- .PHONY : test-integration
117- test-integration : # # Integration tests (i.e. 'make test TAGS=integration')
118- @TAGS=integration $(MAKE ) test
119-
120142.PHONY : test-integration2
121143test-integration2 : # # Integration2 tests via dgraphtest (i.e. 'make test TAGS=integration2')
144+ $(if $(filter command line,$(origin TAGS ) ) ,$(error TAGS= cannot be passed to test-integration2; use 'make test TAGS=...' instead) )
122145 @TAGS=integration2 $(MAKE ) test
123146
124147.PHONY : test-upgrade
125148test-upgrade : # # Upgrade tests (i.e. 'make test TAGS=upgrade')
149+ $(if $(filter command line,$(origin TAGS ) ) ,$(error TAGS= cannot be passed to test-upgrade; use 'make test TAGS=...' instead) )
126150 @TAGS=upgrade $(MAKE ) test
127151
128152.PHONY : test-systest
129- test-systest : # # System integration tests (i.e. 'make test SUITE=systest')
153+ test-systest : # # All systest packages: systest-baseline + systest-heavy (i.e. 'make test SUITE=systest')
154+ $(if $(filter command line,$(origin SUITE ) ) ,$(error SUITE= cannot be passed to test-systest; use 'make test SUITE=...' instead) )
130155 @SUITE=systest $(MAKE ) test
131156
157+ .PHONY : test-integration-heavy
158+ test-integration-heavy : # # All heavy tests: systest-heavy + ldbc + load
159+ $(if $(filter command line,$(origin SUITE ) ) ,$(error SUITE= cannot be passed to test-integration-heavy; use 'make test SUITE=...' instead) )
160+ @SUITE=systest-heavy,ldbc,load $(MAKE ) test
161+
132162.PHONY : test-vector
133163test-vector : # # Vector search tests (i.e. 'make test SUITE=vector')
164+ $(if $(filter command line,$(origin SUITE ) ) ,$(error SUITE= cannot be passed to test-vector; use 'make test SUITE=...' instead) )
134165 @SUITE=vector $(MAKE ) test
135166
136167.PHONY : test-fuzz
137- test-fuzz : # # Fuzz tests, auto-discovers packages (i.e. 'make test FUZZ=1')
168+ test-fuzz : # # Fuzz tests (i.e. 'make test FUZZ=1')
169+ $(if $(filter command line,$(origin FUZZ ) ) ,$(error FUZZ= cannot be passed to test-fuzz; use 'make test FUZZ=...' instead) )
138170 @FUZZ=1 $(MAKE ) test
139171
140- .PHONY : test-ldbc
141- test-ldbc : # # LDBC benchmark tests (i.e. 'make test SUITE=ldbc')
142- @SUITE=ldbc $(MAKE ) test
143-
144- .PHONY : test-load
145- test-load : # # Heavy load tests (i.e. 'make test SUITE=load')
146- @SUITE=load $(MAKE ) test
172+ .PHONY : test-all
173+ test-all : # # Every test: all t/ suites + integration2 + upgrade + fuzz
174+ $(MAKE ) test SUITE=all
175+ $(MAKE ) test-integration2
176+ $(MAKE ) test-upgrade
177+ $(MAKE ) test-fuzz
147178
148179.PHONY : test-benchmark
149- test-benchmark : # # Go benchmarks (i.e. 'go test -bench')
180+ test-benchmark : check-deps # # Go benchmarks (i.e. 'go test -bench')
150181 go test -bench=. -benchmem $(if $(PKG ) ,./$(PKG ) /...,./...)
151182
152183.PHONY : local-image
153184local-image : # # Build local Docker image (dgraph/dgraph:local)
154185 @echo building local docker image
155- @GOOS=linux GOARCH=amd64 $(MAKE ) dgraph
186+ ifneq ($(GOHOSTOS ) ,linux)
187+ @GOOS=linux GOARCH=$(GOHOSTARCH) CGO_ENABLED=1 CC=$(LINUX_CC) $(MAKE) BUILD_TAGS= EXTLDFLAGS=-fuse-ld=bfd dgraph
188+ else
189+ @GOOS=linux GOARCH=$(GOHOSTARCH) $(MAKE) dgraph
190+ endif
156191 @mkdir -p linux
157192 @mv ./dgraph/dgraph ./linux/dgraph
158193 @docker build -f contrib/Dockerfile -t dgraph/dgraph:local .
@@ -161,6 +196,13 @@ local-image: ## Build local Docker image (dgraph/dgraph:local)
161196.PHONY : image-local
162197image-local : local-image # # Alias for local-image
163198
199+ .PHONY : clean
200+ clean : # # Clean build artifacts
201+ $(MAKE ) -C dgraph clean
202+ $(MAKE ) -C compose clean
203+ @rm -rf linux
204+ @go clean -testcache
205+
164206.PHONY : docker-image
165207docker-image : dgraph # # Build Docker image (dgraph/dgraph:$VERSION)
166208 @mkdir -p linux
@@ -201,10 +243,11 @@ help: ## Show available targets and variables
201243 awk ' BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
202244 @echo " "
203245 @echo " Variables that can be passed to 'test':"
204- @echo " SUITE Select t/ runner suite (e.g., make test SUITE=systest )"
246+ @echo " SUITE Select t/ runner suite (default: integration + integration2 )"
205247 @echo " TAGS Go build tags - bypasses t/ runner (e.g., make test TAGS=integration2)"
206248 @echo " PKG Limit to specific package (e.g., make test PKG=systest/export)"
207249 @echo " TEST Run specific test function (e.g., make test TEST=TestGQLSchema)"
250+ @echo " TIMEOUT Per-package test timeout (e.g., make test TIMEOUT=60m). Default: 30m"
208251 @echo " FUZZ Enable fuzz testing (e.g., make test FUZZ=1)"
209252 @echo " FUZZTIME Fuzz duration per package (e.g., make test FUZZ=1 FUZZTIME=60s)"
210253 @echo " "
@@ -215,12 +258,14 @@ help: ## Show available targets and variables
215258 @printf " Available TAGS values: "
216259 @grep -roh " //go:build [a-z0-9]*" --include=" *_test.go" . 2> /dev/null | \
217260 awk ' {print $$2}' | \
218- grep -E ' ^(integration| integration2|upgrade)$$' | \
261+ grep -E ' ^(integration2|upgrade)$$' | \
219262 sort -u | tr ' \n' ' ' && echo " "
263+ @echo " Note: 'integration' tests require the t/ runner (use SUITE=, not TAGS=)"
220264 @echo " "
221265 @echo " Examples:"
222266 @echo " make test TAGS=integration2 PKG=systest/vector # integration2 tests for vector"
223267 @echo " make test TAGS=upgrade PKG=acl TEST=TestACL # specific upgrade test"
224268 @echo " make test FUZZ=1 PKG=dql FUZZTIME=30s # fuzz dql package for 30s"
225269 @echo " make test SUITE=systest PKG=systest/backup/filesystem # systest for backup pkg"
270+ @echo " make test TIMEOUT=90m # all suites with 90m timeout"
226271 @echo " make test-benchmark PKG=posting # benchmark posting package"
0 commit comments