Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1c26e38
feat(build): auto cross-compile Linux binary on macOS
mlwelles Jan 29, 2026
cae957b
feat(test): auto-detect Linux binary path in test runner
mlwelles Jan 29, 2026
c4f9643
chore(test): update docker-compose files for GOPATH_LINUX_BIN
mlwelles Jan 29, 2026
af85b07
docs: add TESTING.md and update testing documentation
mlwelles Jan 29, 2026
f5ea00d
Merge remote-tracking branch 'origin/main' into test-env-setup-tweaks
mlwelles Jan 29, 2026
6f19ad6
docs: improve testing section in CONTRIBUTING.md
mlwelles Jan 29, 2026
7525c69
docs: clarify auto-install in TESTING.md Required Tools section
mlwelles Jan 29, 2026
2e38198
docs: fix markdownlint issues in TESTING.md
mlwelles Jan 29, 2026
d6a56f2
chore: rename GOPATH_LINUX_BIN to LINUX_GOBIN
mlwelles Jan 29, 2026
59968e0
docs: add unified test interface design
mlwelles Jan 29, 2026
fa8125b
chore: add .worktrees/ to gitignore for worktree isolation
mlwelles Jan 29, 2026
0c61f06
docs: add implementation plan for unified test interface
mlwelles Jan 29, 2026
f0a4af8
feat: add auto-generated help target with ## comments
mlwelles Jan 29, 2026
02cf551
feat: add routing logic for TAGS, FUZZ, SUITE in test target
mlwelles Jan 29, 2026
7abc818
feat: add helper targets for common test workflows
mlwelles Jan 29, 2026
6530522
docs: add Quick Start section for unified test interface
mlwelles Jan 29, 2026
8ada5b5
docs: update TESTING.md to mark unified test interface as complete
mlwelles Jan 29, 2026
0e1a90f
fix: correct test-integration description (uses TAGS, not t/ runner)
mlwelles Jan 29, 2026
0df10b0
docs: add help comments for Docker image targets
mlwelles Jan 29, 2026
319f221
docs: improve help output with clearer variable examples
mlwelles Jan 29, 2026
f8692f2
docs: show underlying command in test-* helper target descriptions
mlwelles Jan 29, 2026
6abd1a8
docs: update test documentation for make target VAR=value syntax
mlwelles Jan 29, 2026
d970cf5
feat: dynamically discover available SUITE and TAGS values in make help
mlwelles Jan 29, 2026
20769f5
docs: change 'same as:' to 'i.e.' in test target descriptions
mlwelles Jan 29, 2026
c84d6d7
docs: update help examples to 'make test VAR=val' format and add test…
mlwelles Jan 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ systest/bulk_live/live/**/*.rdf
systest/bulk_live/live/**/*.txt
x/log_test/*.enc
*.buf
.osgrep
.worktrees/
39 changes: 22 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,28 @@ then use this local image to test Dgraph in your local Docker setup.

### Testing

Dgraph employs a ~~complex~~ sophisticated testing framework that includes extensive test coverage.
Due to the comprehensive nature of these tests, a complete test run can take several hours,
depending on your hardware. To manage this complex testing process efficiently, we've developed a
custom test framework implemented in Go, which resides in the [./t](/t) directory. This specialized
framework provides enhanced control and flexibility beyond what's available through standard Go
testing framework.

For dependencies, runner flags and instructions for running tests on non-Linux machines, see the
[README](t/README.md) in the [_t_](t) folder.

Other integration tests do not use the testing framework located in the `t` folder. Consult the
[github workflow definitions](.github/workflows) folder to discover the tests we run as part of our
continuous integration process.

Non-integration unit tests exist for many core packages that can be exercised without invoking the
testing framework. For instance, to unit test the core DQL parsing package:
`go test github.com/dgraph-io/dgraph/v25/dql`.
Dgraph employs a ~~complex~~ sophisticated testing framework with extensive test coverage. A full
test run can take several hours. We've developed a custom test runner in Go in the [t/](t)
directory, providing control and flexibility beyond the standard Go testing framework.

The simplest way to run tests is via Make:

```bash
# Run all tests
make test

# Run specific test types
make test-unit # Unit tests only (no Docker)
make test-integration2 # Integration2 tests via dgraphtest
make test-upgrade # Upgrade tests

# Use variables for more control
make test TAGS=integration2 PKG=systest/vector
```

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

For a comprehensive testing guide, see [TESTING.md](TESTING.md).

## Contributing

Expand Down
167 changes: 141 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ BUILD_DATE ?= $(shell git log -1 --format=%ci)
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILD_VERSION ?= $(shell git describe --always --tags)

GOPATH ?= $(shell go env GOPATH)
export GOPATH ?= $(shell go env GOPATH)
GOHOSTOS := $(shell go env GOHOSTOS)
GOHOSTARCH := $(shell go env GOHOSTARCH)

# On non-Linux systems, use a separate directory for Linux binaries
ifeq ($(GOHOSTOS),linux)
export LINUX_GOBIN ?= $(GOPATH)/bin
else
export LINUX_GOBIN ?= $(GOPATH)/linux_$(GOHOSTARCH)
endif

######################
# Build & Release Parameters
Expand All @@ -20,18 +29,18 @@ GOPATH ?= $(shell go env GOPATH)
DGRAPH_VERSION ?= local

.PHONY: all
all: dgraph
all: dgraph ## Build all targets

.PHONY: dgraph
dgraph:
dgraph: ## Build dgraph binary
$(MAKE) -w -C $@ all

.PHONY: dgraph-coverage
dgraph-coverage:
$(MAKE) -w -C dgraph test-coverage-binary

.PHONY: version
version:
version: ## Show build version info
@echo Dgraph: ${BUILD_VERSION}
@echo Build: ${BUILD}
@echo Codename: ${BUILD_CODENAME}
Expand All @@ -40,30 +49,115 @@ version:
@echo Go version: $(shell go version)

.PHONY: install
install:
@echo "Installing Dgraph..."; \
$(MAKE) -C dgraph install; \
install: ## Install dgraph binary
@echo "Installing dgraph ($(GOHOSTOS)/$(GOHOSTARCH))..."
@$(MAKE) -C dgraph install
ifneq ($(GOHOSTOS),linux)
@mkdir -p $(LINUX_GOBIN)
@echo "Installing dgraph (linux/$(GOHOSTARCH))..."
@GOOS=linux GOARCH=$(GOHOSTARCH) $(MAKE) -C dgraph dgraph
@mv dgraph/dgraph $(LINUX_GOBIN)/dgraph
@echo "Installed dgraph (linux/$(GOHOSTARCH)) to $(LINUX_GOBIN)/dgraph"
endif


.PHONY: uninstall
uninstall:
uninstall: ## Uninstall dgraph binary
@echo "Uninstalling Dgraph ..."; \
$(MAKE) -C dgraph uninstall; \

.PHONY: test
test: docker-image
@mv dgraph/dgraph ${GOPATH}/bin/dgraph
@$(MAKE) -C t test
.PHONY: dgraph-installed
dgraph-installed:
@if [ ! -f "$(GOPATH)/bin/dgraph" ] || [ ! -f "$(LINUX_GOBIN)/dgraph" ]; then \
echo "Dgraph binary missing, running make install..."; \
$(MAKE) install; \
fi

.PHONY: image-local local-image
image-local local-image:
.PHONY: test
test: dgraph-installed local-image ## Run tests (see 'make help' for options)
ifdef TAGS
@echo "Running tests with tags: $(TAGS)"
go test -v --tags="$(TAGS)" \
$(if $(TEST),--run="$(TEST)") \
$(if $(PKG),./$(PKG)/...,./...)
else ifdef FUZZ
@echo "Discovering and running fuzz tests..."
ifdef PKG
go test -v -fuzz=Fuzz -fuzztime=$(or $(FUZZTIME),300s) ./$(PKG)/...
else
@grep -r "^func Fuzz" --include="*_test.go" -l . 2>/dev/null | \
xargs -I{} dirname {} | sort -u | while read dir; do \
echo "Fuzzing $$dir..."; \
go test -v -fuzz=Fuzz -fuzztime=$(or $(FUZZTIME),300s) ./$$dir/...; \
done
endif
else
@echo "Running test suite: $(or $(SUITE),all)"
$(MAKE) -C t test args="--suite=$(or $(SUITE),all) $(if $(PKG),--pkg=\"$(PKG)\") $(if $(TEST),--test=\"$(TEST)\")"
endif

.PHONY: test-all
test-all: ## All test suites via t/ runner (i.e. 'make test SUITE=all')
@SUITE=all $(MAKE) test

.PHONY: test-unit
test-unit: ## Unit tests, no Docker (i.e. 'make test SUITE=unit')
@SUITE=unit $(MAKE) test

.PHONY: test-core
test-core: ## Core tests (i.e. 'make test SUITE=core')
@SUITE=core $(MAKE) test

.PHONY: test-integration
test-integration: ## Integration tests (i.e. 'make test TAGS=integration')
@TAGS=integration $(MAKE) test

.PHONY: test-integration2
test-integration2: ## Integration2 tests via dgraphtest (i.e. 'make test TAGS=integration2')
@TAGS=integration2 $(MAKE) test

.PHONY: test-upgrade
test-upgrade: ## Upgrade tests (i.e. 'make test TAGS=upgrade')
@TAGS=upgrade $(MAKE) test

.PHONY: test-systest
test-systest: ## System integration tests (i.e. 'make test SUITE=systest')
@SUITE=systest $(MAKE) test

.PHONY: test-vector
test-vector: ## Vector search tests (i.e. 'make test SUITE=vector')
@SUITE=vector $(MAKE) test

.PHONY: test-fuzz
test-fuzz: ## Fuzz tests, auto-discovers packages (i.e. 'make test FUZZ=1')
@FUZZ=1 $(MAKE) test

.PHONY: test-ldbc
test-ldbc: ## LDBC benchmark tests (i.e. 'make test SUITE=ldbc')
@SUITE=ldbc $(MAKE) test

.PHONY: test-load
test-load: ## Heavy load tests (i.e. 'make test SUITE=load')
@SUITE=load $(MAKE) test

.PHONY: test-benchmark
test-benchmark: ## Go benchmarks (i.e. 'go test -bench')
go test -bench=. -benchmem $(if $(PKG),./$(PKG)/...,./...)

.PHONY: local-image
local-image: ## Build local Docker image (dgraph/dgraph:local)
@echo building local docker image
@GOOS=linux GOARCH=amd64 $(MAKE) dgraph
@mkdir -p linux
@mv ./dgraph/dgraph ./linux/dgraph
@docker build -f contrib/Dockerfile -t dgraph/dgraph:local .
@rm -r linux

.PHONY: image-local
image-local: local-image ## Alias for local-image

.PHONY: docker-image
docker-image: dgraph
docker-image: dgraph ## Build Docker image (dgraph/dgraph:$VERSION)
@mkdir -p linux
@cp ./dgraph/dgraph ./linux/dgraph
docker build -f contrib/Dockerfile -t dgraph/dgraph:$(DGRAPH_VERSION) .
Expand Down Expand Up @@ -93,14 +187,35 @@ linux-dependency:
sudo apt-get -y install protobuf-compiler

.PHONY: help
help:
@echo
@echo Build commands:
@echo " make [all] - Build all targets [EE]"
@echo " make dgraph - Build dgraph binary"
@echo " make install - Install all targets"
@echo " make uninstall - Uninstall known targets"
@echo " make version - Show current build info"
@echo " make help - This help"
@echo " make test - Make local image and run t.go"
@echo
help: ## Show available targets and variables
@echo "Usage: make [target] [VAR=value ...]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
@echo ""
@echo "Variables that can be passed to 'test':"
@echo " SUITE Select t/ runner suite (e.g., make test SUITE=systest)"
@echo " TAGS Go build tags - bypasses t/ runner (e.g., make test TAGS=integration2)"
@echo " PKG Limit to specific package (e.g., make test PKG=systest/export)"
@echo " TEST Run specific test function (e.g., make test TEST=TestGQLSchema)"
@echo " FUZZ Enable fuzz testing (e.g., make test FUZZ=1)"
@echo " FUZZTIME Fuzz duration per package (e.g., make test FUZZ=1 FUZZTIME=60s)"
@echo ""
@printf " Available SUITE values: "
@grep -o 'allowed := \[\]string{[^}]*}' t/t.go 2>/dev/null | \
sed 's/allowed := \[\]string{"\([^}]*\)"}/\1/' | \
tr -d '"' | tr ',' ' ' || echo "all, unit, core, systest, vector, ldbc, load"
@printf " Available TAGS values: "
@grep -roh "//go:build [a-z0-9]*" --include="*_test.go" . 2>/dev/null | \
awk '{print $$2}' | \
grep -E '^(integration|integration2|upgrade)$$' | \
sort -u | tr '\n' ' ' && echo ""
@echo ""
@echo "Examples:"
@echo " make test TAGS=integration2 PKG=systest/vector # integration2 tests for vector"
@echo " make test TAGS=upgrade PKG=acl TEST=TestACL # specific upgrade test"
@echo " make test FUZZ=1 PKG=dql FUZZTIME=30s # fuzz dql package for 30s"
@echo " make test SUITE=systest PKG=systest/backup/filesystem # systest for backup pkg"
@echo " make test-benchmark PKG=posting # benchmark posting package"
Loading
Loading