59
59
60
60
TEST_TIMEOUT := 20m
61
61
62
- # TODO: INTEG_TEST should be functional tests
63
- INTEG_TEST_ROOT := ./host
64
- INTEG_TEST_XDC_ROOT := ./host/xdc
65
- INTEG_TEST_NDC_ROOT := ./host/ndc
66
-
67
- PERSISTENCE_INTEGRATION_TEST_ROOT := ./common/persistence/tests
68
- DB_TOOL_INTEGRATION_TEST_ROOT := ./tools/tests
69
62
70
63
PROTO_ROOT := proto
71
64
PROTO_FILES = $(shell find ./$(PROTO_ROOT ) /internal -name "* .proto")
@@ -76,10 +69,15 @@ PROTO_OUT := api
76
69
ALL_SRC := $(shell find . -name "* .go")
77
70
ALL_SRC += go.mod
78
71
ALL_SCRIPTS := $(shell find . -name "* .sh")
79
- # TODO (jeremy): Replace below with build tags and `go test ./...` for targets
72
+
80
73
TEST_DIRS := $(sort $(dir $(filter % _test.go,$(ALL_SRC ) ) ) )
81
- INTEG_TEST_DIRS := $(filter $(INTEG_TEST_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 ) )
74
+ FUNCTIONAL_TEST_ROOT := ./tests
75
+ FUNCTIONAL_TEST_XDC_ROOT := ./tests/xdc
76
+ FUNCTIONAL_TEST_NDC_ROOT := ./tests/ndc
77
+ DB_INTEGRATION_TEST_ROOT := ./common/persistence/tests
78
+ DB_TOOL_INTEGRATION_TEST_ROOT := ./tools/tests
79
+ INTEGRATION_TEST_DIRS := $(DB_INTEGRATION_TEST_ROOT ) $(DB_TOOL_INTEGRATION_TEST_ROOT )
80
+ UNIT_TEST_DIRS := $(filter-out $(FUNCTIONAL_TEST_ROOT ) % $(FUNCTIONAL_TEST_XDC_ROOT ) % $(FUNCTIONAL_TEST_NDC_ROOT ) % $(DB_INTEGRATION_TEST_ROOT ) % $(DB_TOOL_INTEGRATION_TEST_ROOT ) % ,$(TEST_DIRS ) )
83
81
84
82
# go.opentelemetry.io/otel/sdk/metric@v0.31.0 - there are breaking changes in v0.32.0.
85
83
# github.com/urfave/cli/v2@v2.4.0 - needs to accept comma in values before unlocking https://github.com/urfave/cli/pull/1241.
@@ -89,26 +87,26 @@ PINNED_DEPENDENCIES := \
89
87
github.com/urfave/cli/v2@v2.4.0
90
88
91
89
# Code coverage output files.
92
- COVER_ROOT := ./.coverage
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
96
- INTEG_COVER_PROFILE := $(COVER_ROOT ) /integ_ $(PERSISTENCE_DRIVER ) _coverprofile.out
97
- INTEG_XDC_COVER_PROFILE := $(COVER_ROOT ) /integ_xdc_ $(PERSISTENCE_DRIVER ) _coverprofile.out
98
- INTEG_NDC_COVER_PROFILE := $(COVER_ROOT ) /integ_ndc_ $(PERSISTENCE_DRIVER ) _coverprofile.out
99
- SUMMARY_COVER_PROFILE := $(COVER_ROOT ) /summary.out
90
+ COVER_ROOT := ./.coverage
91
+ UNIT_COVER_PROFILE := $(COVER_ROOT ) /unit_coverprofile.out
92
+ INTEGRATION_COVER_PROFILE := $(COVER_ROOT ) /integration_coverprofile.out
93
+ DB_TOOL_COVER_PROFILE := $(COVER_ROOT ) /db_tool_coverprofile.out
94
+ FUNCTIONAL_COVER_PROFILE := $(COVER_ROOT ) /functional_ $(PERSISTENCE_DRIVER ) _coverprofile.out
95
+ FUNCTIONAL_XDC_COVER_PROFILE := $(COVER_ROOT ) /functional_xdc_ $(PERSISTENCE_DRIVER ) _coverprofile.out
96
+ FUNCTIONAL_NDC_COVER_PROFILE := $(COVER_ROOT ) /functional_ndc_ $(PERSISTENCE_DRIVER ) _coverprofile.out
97
+ SUMMARY_COVER_PROFILE := $(COVER_ROOT ) /summary.out
100
98
101
99
# DB
102
100
SQL_USER ?= temporal
103
101
SQL_PASSWORD ?= temporal
104
102
105
- # Need the following option to have integration tests count towards coverage. godoc below:
103
+ # Need the following option to have integration and functional tests count towards coverage. godoc below:
106
104
# -coverpkg pkg1,pkg2,pkg3
107
105
# Apply coverage analysis in each test to the given list of packages.
108
106
# The default is for each test to analyze only the package being tested.
109
107
# Packages are specified as import paths.
110
- INTEG_TEST_COVERPKG := -coverpkg="$(MODULE_ROOT ) /client/..., $( MODULE_ROOT ) / common/...,$(MODULE_ROOT ) /service /..."
111
-
108
+ INTEGRATION_TEST_COVERPKG := -coverpkg="$(MODULE_ROOT ) /common/persistence/ ...,$(MODULE_ROOT ) /tools /..."
109
+ FUNCTIONAL_TEST_COVERPKG := -coverpkg=" $( MODULE_ROOT ) /client/..., $( MODULE_ROOT ) /common/..., $( MODULE_ROOT ) /service/..., $( MODULE_ROOT ) /temporal/..., $( MODULE_ROOT ) /tools/..."
112
110
# #### Tools #####
113
111
update-checkers :
114
112
@printf $(COLOR ) " Install/update check tools..."
@@ -262,32 +260,31 @@ build-tests:
262
260
263
261
unit-test : clean-test-results
264
262
@printf $(COLOR ) " Run unit tests..."
265
- @go test $(UNIT_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race | tee -a test.log
263
+ @go test $(UNIT_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) $(TEST_DIRS ) -race | tee -a test.log
266
264
@! grep -q " ^--- FAIL" test.log
267
265
268
- db- integration-test : clean-test-results
266
+ integration-test : clean-test-results
269
267
@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
268
+ @go test $(INTEGRATION_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race | tee -a test.log
272
269
@! grep -q " ^--- FAIL" test.log
273
270
274
- # TODO: rename it to functional -test
275
- integration-test : clean-test-results
276
- @printf $( COLOR ) " Run integration tests... "
277
- @go test $(INTEG_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race | tee -a test.log
271
+ functional-test : clean -test-results
272
+ @printf $( COLOR ) " Run functional tests... "
273
+ @go test $( FUNCTIONAL_TEST_ROOT ) -timeout= $( TEST_TIMEOUT ) $( TEST_TAG ) -race | tee -a test.log
274
+ @go test $(FUNCTIONAL_TEST_NDC_ROOT ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race | tee -a test.log
278
275
# Need to run xdc tests with race detector off because of ringpop bug causing data race issue.
279
- @go test $(INTEG_TEST_XDC_ROOT ) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) | tee -a test.log
276
+ @go test $(FUNCTIONAL_TEST_XDC_ROOT ) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) | tee -a test.log
280
277
@! grep -q "^--- FAIL" test.log
281
278
282
- # TODO: rename it to functional-test
283
- integration-with-fault-injection-test : clean-test-results
279
+ functional-with-fault-injection-test : clean-test-results
284
280
@printf $(COLOR ) " Run integration tests with fault injection..."
285
- @go test $(INTEG_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race -PersistenceFaultInjectionRate=0.005 | tee -a test.log
281
+ @go test $(FUNCTIONAL_TEST_ROOT ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race -PersistenceFaultInjectionRate=0.005 | tee -a test.log
282
+ @go test $(FUNCTIONAL_TEST_NDC_ROOT ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -race -PersistenceFaultInjectionRate=0.005 | tee -a test.log
286
283
# Need to run xdc tests with race detector off because of ringpop bug causing data race issue.
287
- @go test $(INTEG_TEST_XDC_ROOT ) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -PersistenceFaultInjectionRate=0.005 | tee -a test.log
284
+ @go test $(FUNCTIONAL_TEST_XDC_ROOT ) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -PersistenceFaultInjectionRate=0.005 | tee -a test.log
288
285
@! grep -q "^--- FAIL" test.log
289
286
290
- test : unit-test db- integration-test integration -test integration -with-fault-injection-test
287
+ test : unit-test integration-test functional -test functional -with-fault-injection-test
291
288
292
289
# #### Coverage #####
293
290
$(COVER_ROOT ) :
@@ -296,27 +293,23 @@ $(COVER_ROOT):
296
293
unit-test-coverage : $(COVER_ROOT )
297
294
@printf $(COLOR ) " Run unit tests with coverage..."
298
295
@echo " mode: atomic" > $(UNIT_COVER_PROFILE )
299
- @go test ./$(UNIT_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) -race -coverprofile=$(UNIT_COVER_PROFILE ) || exit 1;
296
+ @go test ./$(UNIT_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) -race -tags=unittest - coverprofile=$(UNIT_COVER_PROFILE ) || exit 1;
300
297
301
- db- integration-test-coverage : $(COVER_ROOT )
298
+ integration-test-coverage : $(COVER_ROOT )
302
299
@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 )
300
+ @go test $(INTEGRATION_TEST_DIRS ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) $(INTEGRATION_TEST_COVERPKG ) -coverprofile=$(INTEGRATION_COVER_PROFILE )
305
301
306
- # TODO: rename it to functional-test
307
- integration-test-coverage : $(COVER_ROOT )
308
- @printf $(COLOR ) " Run integration tests with coverage with $( PERSISTENCE_DRIVER) driver..."
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 )
310
-
311
- # TODO: rename it to functional-test
312
- integration-test-xdc-coverage : $(COVER_ROOT )
313
- @printf $(COLOR ) " Run integration test for cross DC with coverage with $( PERSISTENCE_DRIVER) driver..."
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 )
315
-
316
- # TODO: rename it to functional-test
317
- integration-test-ndc-coverage : $(COVER_ROOT )
318
- @printf $(COLOR ) " Run integration test for NDC with coverage with $( PERSISTENCE_DRIVER) driver..."
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 )
302
+ functional-test-coverage : $(COVER_ROOT )
303
+ @printf $(COLOR ) " Run functional tests with coverage with $( PERSISTENCE_DRIVER) driver..."
304
+ @go test $(FUNCTIONAL_TEST_ROOT ) -timeout=$(TEST_TIMEOUT ) -race $(TEST_TAG ) -persistenceType=$(PERSISTENCE_TYPE ) -persistenceDriver=$(PERSISTENCE_DRIVER ) $(FUNCTIONAL_TEST_COVERPKG ) -coverprofile=$(FUNCTIONAL_COVER_PROFILE )
305
+
306
+ functional-test-xdc-coverage : $(COVER_ROOT )
307
+ @printf $(COLOR ) " Run functional test for cross DC with coverage with $( PERSISTENCE_DRIVER) driver..."
308
+ @go test $(FUNCTIONAL_TEST_XDC_ROOT ) -timeout=$(TEST_TIMEOUT ) $(TEST_TAG ) -persistenceType=$(PERSISTENCE_TYPE ) -persistenceDriver=$(PERSISTENCE_DRIVER ) $(FUNCTIONAL_TEST_COVERPKG ) -coverprofile=$(FUNCTIONAL_XDC_COVER_PROFILE )
309
+
310
+ functional-test-ndc-coverage : $(COVER_ROOT )
311
+ @printf $(COLOR ) " Run functional test for NDC with coverage with $( PERSISTENCE_DRIVER) driver..."
312
+ @go test $(FUNCTIONAL_TEST_NDC_ROOT ) -timeout=$(TEST_TIMEOUT ) -race $(TEST_TAG ) -persistenceType=$(PERSISTENCE_TYPE ) -persistenceDriver=$(PERSISTENCE_DRIVER ) $(FUNCTIONAL_TEST_COVERPKG ) -coverprofile=$(FUNCTIONAL_NDC_COVER_PROFILE )
320
313
321
314
.PHONY : $(SUMMARY_COVER_PROFILE )
322
315
$(SUMMARY_COVER_PROFILE ) : $(COVER_ROOT )
0 commit comments