Skip to content

fix(test): make test defaults to fast suite + macOS compat#9609

Closed
mlwelles wants to merge 14 commits intodgraph-io:mainfrom
mlwelles:fix/shiva-test-mac-os
Closed

fix(test): make test defaults to fast suite + macOS compat#9609
mlwelles wants to merge 14 commits intodgraph-io:mainfrom
mlwelles:fix/shiva-test-mac-os

Conversation

@mlwelles
Copy link
Copy Markdown
Contributor

@mlwelles mlwelles commented Feb 23, 2026

Summary

  • Change make test default from --suite=all (~60+ min) to unit,systest,core + integration2 (~30 min) for faster local feedback
  • Add $(origin) guards on all test-* targets to prevent confusing variable conflicts (e.g., make test-unit SUITE=ldbc now errors with a clear message)
  • Add test-suite target — runs t/ runner suites (defaults to all, accepts SUITE= arg)
  • Add test-full target — runs every test in the repo (all suites + integration2 + upgrade + fuzz)
  • Remove broken test-integration target — TAGS=integration bypassed the t/ runner, skipping Docker Compose orchestration and plugin compilation that integration tests require. These tests should be run via SUITE= which routes through the t/ runner.
  • Fix macOS test compatibility — automatic cross-compilation for Go plugins, LINUX_GOBIN handling in Docker Compose files, cross-compiler detection script
  • Fix macOS plugin loading — enable CGO when cross-compiling the dgraph binary so the resulting ELF is dynamically linked and can dlopen() Go plugin .so files. Without CGO, the binary was statically linked and plugin.Open() silently failed.
  • Fix gotestsum PATH resolutiont/t.go now resolves gotestsum via $GOPATH/bin absolute path instead of relying on $PATH, which fails on machines where $GOPATH/bin is not in PATH
  • Add make deps and make setup — top-level targets for dependency checking and auto-installation (replaces cd t && make check)
  • Separate tool deps from build artifact checkst/Makefile check is split into deps (external tools only) and check (tools + binary verification). make setup calls deps so it no longer requires the dgraph binary to exist.
  • Add --timeout flag to t/ runner and make test
  • Update docs — TESTING.md, CONTRIBUTING.md reflect new defaults, targets, and make setup for onboarding

Cross-compilation details (macOS → Linux)

The install and local-image targets now cross-compile with:

  • CGO_ENABLED=1 — produces a dynamically linked binary (required for dlopen()/plugin support)
  • CC=$(LINUX_CC) — uses architecture-appropriate cross-compiler (aarch64-unknown-linux-gnu-gcc on ARM, x86_64-unknown-linux-gnu-gcc on x86)
  • BUILD_TAGS= — disables jemalloc (Linux jemalloc headers not available on macOS cross-toolchain)
  • EXTLDFLAGS=-fuse-ld=bfd — uses BFD linker since gold linker is not shipped with cross-compiler toolchains

On Linux, all targets behave as before (native CGO, native jemalloc, default linker).

Make targets after this PR

Target What it runs
make test Default: unit, systest, core + integration2 (~30 min)
make test SUITE=all All t/ runner suites only
make test-suite All t/ runner suites (default), or make test-suite SUITE=unit
make test-full All suites + integration2 + upgrade + fuzz
make test-unit Unit tests only
make test-core Core tests only
make test-systest System integration tests only
make test-integration2 Integration2 tests via dgraphtest
make test-upgrade Upgrade tests
make test-fuzz Fuzz tests
make deps Check tool dependencies (pass AUTO_INSTALL=true to auto-install)
make setup Auto-install all tool dependencies

Variable conflict guards

Convenience targets now reject conflicting CLI variables:

$ make test-unit SUITE=ldbc
Makefile:120: *** SUITE= cannot be passed to test-unit; use 'make test SUITE=...' instead.  Stop.

Test plan

  • make test → prints "Running test suites: unit, systest, core" then "Running integration2 tests..."
  • make test SUITE=all → runs only all suites, no integration2 appended
  • make test TAGS=integration2 → runs only integration2
  • make test FUZZ=1 → runs only fuzz
  • make test-unit SUITE=ldbc → errors with clear message
  • make test-integration2 TAGS=upgrade → errors with clear message
  • make test-fuzz FUZZ=0 → errors with clear message
  • make test-unit PKG=query → works (PKG is a filter, not a conflict)
  • make help → reflects new defaults
  • make setup → auto-installs missing tool dependencies (no binary required)
  • Linux: make clean setup test-suite PKG=systest/plugin → all 7 plugin tests pass
  • macOS (ARM): make clean setup test-suite PKG=systest/plugin → all 7 plugin tests pass
  • docker inspect dgraph/dgraph:local --format '{{.Architecture}}'arm64 on M-series Mac
  • Full make test run completes within ~30 min threshold

Shiva and others added 7 commits February 19, 2026 18:19
When running `make test` (--suite=all), the load and ldbc download
blocks in t/t.go shared the same *tmp directory. The ldbc block's
MakeDirEmpty call wiped files downloaded by the load block, causing
systest/1million to fail with missing schema files.

Hoist directory initialization above both download blocks so
MakeDirEmpty runs exactly once. Both datasets coexist in the same
directory since their filenames don't overlap. Also use a dedicated
subdirectory (dgraph-test-data) instead of bare os.TempDir() to
avoid wiping the system temp directory.

Add testSuiteContainsAny() helper to replace repeated
testSuiteContains("x") || testSuiteContains("y") patterns.
30 Docker Compose files hardcoded $GOPATH/bin as the binary mount
source. On macOS, this mounts the native macOS binary into Linux
containers, causing them to fail on startup.

Replace all 78 occurrences with ${LINUX_GOBIN:-$GOPATH/bin} to match
the pattern already used in dgraph/docker-compose.yml. On Linux,
LINUX_GOBIN defaults to $GOPATH/bin (no change). On macOS, it points
to the cross-compiled Linux binary directory.
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.
Remove empty if-branch flagged by staticcheck SA9003 in t/t.go and
fix markdown table alignment in TESTING.md for prettier compliance.
The default `make test` (no args) previously ran --suite=all (~60+ min).
Now it runs unit,systest,core suites plus integration2 tests (~30 min)
for a faster local feedback loop.

Changes:
- Split the else branch in `test` target: SUITE set → explicit suite;
  nothing set → default (unit,systest,core + integration2)
- Add $(origin) guards on all test-* targets to prevent confusing
  variable conflicts (e.g. `make test-unit SUITE=ldbc` now errors)
- Add `test-suites` target (runs all t/ runner suites via SUITE=all)
- Add `test-everything` target (all suites + integration + integration2
  + upgrade + fuzz)
- Update TESTING.md, CONTRIBUTING.md, AGENTS.md to reflect new defaults
- Update `make help` output with new default description
@mlwelles mlwelles requested a review from a team as a code owner February 23, 2026 20:00
Resolve conflicts in Makefile and CONTRIBUTING.md, keeping the PR's
dual-command default (unit,systest,core + integration2) and the
SUITE=all example line.
Shorter, clearer name for the target that runs every test in the repo
(all suites + integration + integration2 + upgrade + fuzz).
test-suite now accepts an optional SUITE= argument (defaults to all),
making it a flexible entry point for running any t/ runner suite.
AGENTS.md is a local Claude Code config file that should not be
tracked in version control.
…s-compilation

- Remove broken test-integration target: TAGS=integration bypassed the t/
  runner, skipping Docker Compose orchestration and plugin compilation that
  integration tests require. Use SUITE= to route through the t/ runner instead.
- Fix gotestsum PATH resolution in t/t.go: add gotestsumBin() that resolves
  to $GOPATH/bin/gotestsum instead of relying on PATH lookup, which fails on
  machines where $GOPATH/bin is not in PATH.
- Add cross-compilation support for Go plugins on macOS: detect non-Linux
  hosts and set CGO_ENABLED=1, CC to the appropriate cross-compiler, and
  use the BFD linker (both testutil/plugin.go and dgraphtest/local_cluster.go).
- Add check-cross-compiler.sh dependency check script.
- Add top-level make deps and make setup targets for dependency management.
- Update TESTING.md and CONTRIBUTING.md to document new targets and recommend
  make setup for first-time onboarding.
- Remove test-integration from test-full (redundant: SUITE=all covers it).
The local-image and install targets cross-compiled the dgraph binary
without CGO, producing a statically linked binary that cannot dlopen()
Go plugin .so files. This caused all plugin tests to fail on macOS
with "Invalid tokenizer anagram".

Changes:
- Add LINUX_CC variable for architecture-aware cross-compiler selection
- Enable CGO_ENABLED=1 with cross-compiler in install and local-image
- Use BFD linker (-fuse-ld=bfd) since gold is not in cross-toolchains
- Skip jemalloc (BUILD_TAGS=) for cross-compilation (headers unavailable)
- Add EXTLDFLAGS support to dgraph/Makefile for external linker flags
- Split t/Makefile check into deps (tools) + check (tools + binary)
- Top-level setup now calls t/deps so it no longer requires the binary
@mlwelles
Copy link
Copy Markdown
Contributor Author

Closing fork PR — reopening from upstream branch to fix CI permission issues (label, Trunk token).

@mlwelles mlwelles closed this Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant