Skip to content

Commit 524e29b

Browse files
committed
chore(test): support cross-platform test environment setup
Add GOPATH_LINUX_BIN to separate Linux binary paths from native binaries on non-Linux hosts (e.g., macOS). On Linux, GOPATH_LINUX_BIN defaults to $GOPATH/bin; on other platforms it defaults to $GOPATH/linux_$GOARCH. - Update all docker-compose.yml volume mounts to use GOPATH_LINUX_BIN - Add auto-build of dgraph binary when missing (make install + t.go) - Cross-compile Linux binary on non-Linux hosts during make install - Modularize t/Makefile dependency checks into individual scripts
1 parent df3e9d9 commit 524e29b

40 files changed

Lines changed: 947 additions & 121 deletions

Makefile

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ BUILD_DATE ?= $(shell git log -1 --format=%ci)
99
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
1010
BUILD_VERSION ?= $(shell git describe --always --tags)
1111

12-
GOPATH ?= $(shell go env GOPATH)
12+
export GOPATH ?= $(shell go env GOPATH)
13+
GOHOSTOS := $(shell go env GOHOSTOS)
14+
GOHOSTARCH := $(shell go env GOHOSTARCH)
15+
16+
# On non-Linux systems, use a separate directory for Linux binaries
17+
ifeq ($(GOHOSTOS),linux)
18+
export GOPATH_LINUX_BIN ?= $(GOPATH)/bin
19+
else
20+
export GOPATH_LINUX_BIN ?= $(GOPATH)/linux_$(GOHOSTARCH)
21+
endif
1322

1423
######################
1524
# Build & Release Parameters
@@ -41,17 +50,31 @@ version:
4150

4251
.PHONY: install
4352
install:
44-
@echo "Installing Dgraph..."; \
45-
$(MAKE) -C dgraph install; \
53+
@echo "Installing dgraph ($(GOHOSTOS)/$(GOHOSTARCH))..."
54+
@$(MAKE) -C dgraph install
55+
ifneq ($(GOHOSTOS),linux)
56+
@mkdir -p $(GOPATH_LINUX_BIN)
57+
@echo "Installing dgraph (linux/$(GOHOSTARCH))..."
58+
@GOOS=linux GOARCH=$(GOHOSTARCH) $(MAKE) -C dgraph dgraph
59+
@mv dgraph/dgraph $(GOPATH_LINUX_BIN)/dgraph
60+
@echo "Installed dgraph (linux/$(GOHOSTARCH)) to $(GOPATH_LINUX_BIN)/dgraph"
61+
endif
62+
4663

4764
.PHONY: uninstall
4865
uninstall:
4966
@echo "Uninstalling Dgraph ..."; \
5067
$(MAKE) -C dgraph uninstall; \
5168

69+
.PHONY: dgraph-installed
70+
dgraph-installed:
71+
@if [ ! -f "$(GOPATH)/bin/dgraph" ] || [ ! -f "$(GOPATH_LINUX_BIN)/dgraph" ]; then \
72+
echo "Dgraph binary missing, running make install..."; \
73+
$(MAKE) install; \
74+
fi
75+
5276
.PHONY: test
53-
test: docker-image
54-
@mv dgraph/dgraph ${GOPATH}/bin/dgraph
77+
test: dgraph-installed
5578
@$(MAKE) -C t test
5679

5780
.PHONY: image-local local-image
@@ -104,3 +127,5 @@ help:
104127
@echo " make help - This help"
105128
@echo " make test - Make local image and run t.go"
106129
@echo
130+
131+

dgraph/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ install: jemalloc
8686
fi
8787
@go mod tidy
8888
@go install $(BUILD_FLAGS)
89-
@echo "Installed $(BIN) to $(INSTALL_TARGET)"
89+
@echo "Installed $(BIN) ($(GOOS)/$(GOARCH)) to $(INSTALL_TARGET)"
9090
@if [ "$(HAS_SHA256SUM)" ] ; then \
9191
echo "New SHA256:" `sha256sum $(INSTALL_TARGET) 2>/dev/null | cut -c-64` ; \
9292
fi

dgraph/docker-compose.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
service: zero
1212
volumes:
1313
- type: bind
14-
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
14+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
1515
target: /gobin
1616
read_only: true
1717
command:
@@ -32,7 +32,7 @@ services:
3232
service: zero
3333
volumes:
3434
- type: bind
35-
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
35+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
3636
target: /gobin
3737
read_only: true
3838
command:
@@ -52,7 +52,7 @@ services:
5252
service: zero
5353
volumes:
5454
- type: bind
55-
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
55+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
5656
target: /gobin
5757
read_only: true
5858
command:
@@ -64,7 +64,7 @@ services:
6464
working_dir: /data/alpha1
6565
volumes:
6666
- type: bind
67-
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
67+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
6868
target: /gobin
6969
read_only: true
7070
- type: bind
@@ -94,7 +94,7 @@ services:
9494
- alpha1
9595
volumes:
9696
- type: bind
97-
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
97+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
9898
target: /gobin
9999
read_only: true
100100
- type: bind
@@ -124,7 +124,7 @@ services:
124124
- alpha2
125125
volumes:
126126
- type: bind
127-
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
127+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
128128
target: /gobin
129129
read_only: true
130130
- type: bind
@@ -154,7 +154,7 @@ services:
154154
- alpha3
155155
volumes:
156156
- type: bind
157-
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
157+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
158158
target: /gobin
159159
read_only: true
160160
- type: bind
@@ -184,7 +184,7 @@ services:
184184
- alpha4
185185
volumes:
186186
- type: bind
187-
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
187+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
188188
target: /gobin
189189
read_only: true
190190
- type: bind
@@ -214,7 +214,7 @@ services:
214214
- alpha5
215215
volumes:
216216
- type: bind
217-
source: ${GOPATH:?GOPATH environment variable is required but not set}/bin
217+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
218218
target: /gobin
219219
read_only: true
220220
- type: bind

systest/1million/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- "6080"
1111
volumes:
1212
- type: bind
13-
source: $GOPATH/bin
13+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
1414
target: /gobin
1515
read_only: true
1616
- type: volume

systest/21million/bulk/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- "6080"
1111
volumes:
1212
- type: bind
13-
source: $GOPATH/bin
13+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
1414
target: /gobin
1515
read_only: true
1616
- type: volume

systest/21million/live/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
- "9080"
1313
volumes:
1414
- type: bind
15-
source: $GOPATH/bin
15+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
1616
target: /gobin
1717
read_only: true
1818
command:
@@ -28,7 +28,7 @@ services:
2828
- "6080"
2929
volumes:
3030
- type: bind
31-
source: $GOPATH/bin
31+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
3232
target: /gobin
3333
read_only: true
3434
command:

systest/acl/restore/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- 9080
1111
volumes:
1212
- type: bind
13-
source: $GOPATH/bin
13+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
1414
target: /gobin
1515
read_only: true
1616
- type: bind
@@ -38,7 +38,7 @@ services:
3838
- 6080
3939
volumes:
4040
- type: bind
41-
source: $GOPATH/bin
41+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
4242
target: /gobin
4343
read_only: true
4444
command:

systest/audit/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- "9080"
99
volumes:
1010
- type: bind
11-
source: $GOPATH/bin
11+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
1212
target: /gobin
1313
read_only: true
1414
- type: bind
@@ -28,7 +28,7 @@ services:
2828
- "6080"
2929
volumes:
3030
- type: bind
31-
source: $GOPATH/bin
31+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
3232
target: /gobin
3333
read_only: true
3434
- type: bind

systest/audit_encrypted/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- "9080"
99
volumes:
1010
- type: bind
11-
source: $GOPATH/bin
11+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
1212
target: /gobin
1313
read_only: true
1414
- type: bind
@@ -32,7 +32,7 @@ services:
3232
- "6080"
3333
volumes:
3434
- type: bind
35-
source: $GOPATH/bin
35+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
3636
target: /gobin
3737
read_only: true
3838
- type: bind

systest/backup/advanced-scenarios/127-Namespace/docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
- 9080
1515
volumes:
1616
- type: bind
17-
source: $GOPATH/bin
17+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
1818
target: /gobin
1919
read_only: true
2020
- type: bind
@@ -37,7 +37,7 @@ services:
3737
- 6080
3838
volumes:
3939
- type: bind
40-
source: $GOPATH/bin
40+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
4141
target: /gobin
4242
read_only: true
4343
- data-volume:/data/backups/
@@ -57,7 +57,7 @@ services:
5757
- 9080
5858
volumes:
5959
- type: bind
60-
source: $GOPATH/bin
60+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
6161
target: /gobin
6262
read_only: true
6363
- type: bind
@@ -79,7 +79,7 @@ services:
7979
- 6080
8080
volumes:
8181
- type: bind
82-
source: $GOPATH/bin
82+
source: ${GOPATH_LINUX_BIN:-$GOPATH/bin}
8383
target: /gobin
8484
read_only: true
8585
- data-volume:/data/backups/

0 commit comments

Comments
 (0)