@@ -59,10 +59,14 @@ endef
59
59
60
60
TEST_TIMEOUT := 20m
61
61
62
+ # TODO: INTEG_TEST should be functional tests
62
63
INTEG_TEST_ROOT := ./host
63
64
INTEG_TEST_XDC_ROOT := ./host/xdc
64
65
INTEG_TEST_NDC_ROOT := ./host/ndc
65
66
67
+ PERSISTENCE_INTEGRATION_TEST_ROOT := ./common/persistence/tests
68
+ DB_TOOL_INTEGRATION_TEST_ROOT := ./tools/tests
69
+
66
70
PROTO_ROOT := proto
67
71
PROTO_FILES = $(shell find ./$(PROTO_ROOT ) /internal -name "* .proto")
68
72
PROTO_DIRS = $(sort $(dir $(PROTO_FILES ) ) )
@@ -75,7 +79,7 @@ ALL_SCRIPTS := $(shell find . -name "*.sh")
75
79
# TODO (jeremy): Replace below with build tags and `go test ./...` for targets
76
80
TEST_DIRS := $(sort $(dir $(filter % _test.go,$(ALL_SRC ) ) ) )
77
81
INTEG_TEST_DIRS := $(filter $(INTEG_TEST_ROOT ) / $(INTEG_TEST_NDC_ROOT ) /,$(TEST_DIRS ) )
78
- UNIT_TEST_DIRS := $(filter-out $(INTEG_TEST_ROOT ) % $(INTEG_TEST_XDC_ROOT ) % $(INTEG_TEST_NDC_ROOT ) % ,$(TEST_DIRS ) )
82
+ UNIT_TEST_DIRS := $(filter-out $(INTEG_TEST_ROOT ) % $(INTEG_TEST_XDC_ROOT ) % $(INTEG_TEST_NDC_ROOT ) % $( PERSISTENCE_INTEGRATION_TEST_ROOT ) % $( DB_TOOL_INTEGRATION_TEST_ROOT ) % ,$(TEST_DIRS ) )
79
83
80
84
# go.opentelemetry.io/otel/sdk/metric@v0.31.0 - there are breaking changes in v0.32.0.
81
85
# github.com/urfave/cli/v2@v2.4.0 - needs to accept comma in values before unlocking https://github.com/urfave/cli/pull/1241.
@@ -87,6 +91,8 @@ PINNED_DEPENDENCIES := \
87
91
# Code coverage output files.
88
92
COVER_ROOT := ./.coverage
89
93
UNIT_COVER_PROFILE := $(COVER_ROOT ) /unit_coverprofile.out
94
+ INTEGRATION_COVER_PROFILE := $(COVER_ROOT ) /integration_coverprofile.out
95
+ DB_TOOL_COVER_PROFILE := $(COVER_ROOT ) /db_tool_coverprofile.out
90
96
INTEG_COVER_PROFILE := $(COVER_ROOT ) /integ_$(PERSISTENCE_DRIVER ) _coverprofile.out
91
97
INTEG_XDC_COVER_PROFILE := $(COVER_ROOT ) /integ_xdc_$(PERSISTENCE_DRIVER ) _coverprofile.out
92
98
INTEG_NDC_COVER_PROFILE := $(COVER_ROOT ) /integ_ndc_$(PERSISTENCE_DRIVER ) _coverprofile.out
@@ -254,32 +260,34 @@ build-tests:
254
260
@printf $(COLOR ) " Build tests..."
255
261
@go test -exec=" true" -count=0 -tags=esintegration $(TEST_DIRS )
256
262
257
- unit-test :
263
+ unit-test : clean-test-results
258
264
@printf $(COLOR ) " Run unit tests..."
259
- $(foreach UNIT_TEST_DIR,$(UNIT_TEST_DIRS ) ,\
260
- @go test $(UNIT_TEST_DIR ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race | tee -a test.log \
261
- $(NEWLINE ) )
265
+ @go test $(UNIT_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race | tee -a test.log
266
+ @! grep -q " ^--- FAIL" test.log
267
+
268
+ db-integration-test : clean-test-results
269
+ @printf $(COLOR ) " Run integration tests..."
270
+ @go test $(PERSISTENCE_INTEGRATION_TEST_ROOT ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) | tee -a test.log
271
+ @go test $(DB_TOOL_INTEGRATION_TEST_ROOT ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) | tee -a test.log
262
272
@! grep -q " ^--- FAIL" test.log
263
273
274
+ # TODO: rename it to functional-test
264
275
integration-test : clean-test-results
265
276
@printf $(COLOR ) " Run integration tests..."
266
- $(foreach INTEG_TEST_DIR,$(INTEG_TEST_DIRS ) ,\
267
- @go test $(INTEG_TEST_DIR ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race | tee -a test.log \
268
- $(NEWLINE ) )
277
+ @go test $(INTEG_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race | tee -a test.log
269
278
# Need to run xdc tests with race detector off because of ringpop bug causing data race issue.
270
279
@go test $(INTEG_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) | tee -a test.log
271
280
@! grep -q "^--- FAIL" test.log
272
281
282
+ # TODO: rename it to functional-test
273
283
integration-with-fault-injection-test : clean-test-results
274
284
@printf $(COLOR ) " Run integration tests with fault injection..."
275
- $(foreach INTEG_TEST_DIR,$(INTEG_TEST_DIRS ) ,\
276
- @go test $(INTEG_TEST_DIR ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race -PersistenceFaultInjectionRate=0.005 | tee -a test.log \
277
- $(NEWLINE ) )
285
+ @go test $(INTEG_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race -PersistenceFaultInjectionRate=0.005 | tee -a test.log
278
286
# Need to run xdc tests with race detector off because of ringpop bug causing data race issue.
279
287
@go test $(INTEG_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -PersistenceFaultInjectionRate=0.005 | tee -a test.log
280
288
@! grep -q "^--- FAIL" test.log
281
289
282
- test : unit-test integration-test integration-with-fault-injection-test
290
+ test : unit-test db-integration-test integration-test integration-with-fault-injection-test
283
291
284
292
# #### Coverage #####
285
293
$(COVER_ROOT ) :
@@ -288,20 +296,24 @@ $(COVER_ROOT):
288
296
unit-test-coverage : $(COVER_ROOT )
289
297
@printf $(COLOR ) " Run unit tests with coverage..."
290
298
@echo " mode: atomic" > $(UNIT_COVER_PROFILE )
291
- $(foreach UNIT_TEST_DIR,$(patsubst ./% /,% ,$(UNIT_TEST_DIRS ) ) ,\
292
- @mkdir -p $(COVER_ROOT ) /$(UNIT_TEST_DIR ) ; \
293
- go test ./$(UNIT_TEST_DIR ) -timeout=$(TEST_TIMEOUT ) -race -coverprofile=$(COVER_ROOT ) /$(UNIT_TEST_DIR ) /coverprofile.out || exit 1; \
294
- grep -v -e " ^mode: \w\+" $(COVER_ROOT ) /$(UNIT_TEST_DIR ) /coverprofile.out >> $(UNIT_COVER_PROFILE ) || true \
295
- $(NEWLINE ) )
299
+ @go test ./$(UNIT_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) -race -coverprofile=$(UNIT_COVER_PROFILE ) || exit 1;
300
+
301
+ db-integration-test-coverage : $(COVER_ROOT )
302
+ @printf $(COLOR ) " Run integration tests with coverage..."
303
+ @go test $(PERSISTENCE_INTEGRATION_TEST_ROOT ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -coverpkg=" ./common/..." -coverprofile=$(INTEGRATION_COVER_PROFILE )
304
+ @go test $(DB_TOOL_INTEGRATION_TEST_ROOT ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -coverpkg=" ./tools/..." -coverprofile=$(DB_TOOL_COVER_PROFILE )
296
305
306
+ # TODO: rename it to functional-test
297
307
integration-test-coverage : $(COVER_ROOT )
298
308
@printf $(COLOR ) " Run integration tests with coverage with $( PERSISTENCE_DRIVER) driver..."
299
309
@go test $(INTEG_TEST_ROOT ) -timeout=$(TEST_TIMEOUT ) -race $(TEST_TAG ) -persistenceType=$(PERSISTENCE_TYPE ) -persistenceDriver=$(PERSISTENCE_DRIVER ) $(INTEG_TEST_COVERPKG ) -coverprofile=$(INTEG_COVER_PROFILE )
300
310
311
+ # TODO: rename it to functional-test
301
312
integration-test-xdc-coverage : $(COVER_ROOT )
302
313
@printf $(COLOR ) " Run integration test for cross DC with coverage with $( PERSISTENCE_DRIVER) driver..."
303
314
@go test $(INTEG_TEST_XDC_ROOT ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -persistenceType=$(PERSISTENCE_TYPE ) -persistenceDriver=$(PERSISTENCE_DRIVER ) $(INTEG_TEST_COVERPKG ) -coverprofile=$(INTEG_XDC_COVER_PROFILE )
304
315
316
+ # TODO: rename it to functional-test
305
317
integration-test-ndc-coverage : $(COVER_ROOT )
306
318
@printf $(COLOR ) " Run integration test for NDC with coverage with $( PERSISTENCE_DRIVER) driver..."
307
319
@go test $(INTEG_TEST_NDC_ROOT ) -timeout=$(TEST_TIMEOUT ) -race $(TEST_TAG ) -persistenceType=$(PERSISTENCE_TYPE ) -persistenceDriver=$(PERSISTENCE_DRIVER ) $(INTEG_TEST_COVERPKG ) -coverprofile=$(INTEG_NDC_COVER_PROFILE )
0 commit comments