-
Notifications
You must be signed in to change notification settings - Fork 827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate integration tests and unit tests #3760
Changes from 6 commits
e638c74
50de6dc
aab7c7e
f3b37a5
14e935a
dedcde7
5155dc5
9b1362c
416017f
7fda9eb
b956827
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,10 +59,14 @@ endef | |
|
||
TEST_TIMEOUT := 20m | ||
|
||
# TODO: INTEG_TEST should be functional tests | ||
INTEG_TEST_ROOT := ./host | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about renaming this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do in the following PR |
||
INTEG_TEST_XDC_ROOT := ./host/xdc | ||
INTEG_TEST_NDC_ROOT := ./host/ndc | ||
|
||
INTEGRATION_TEST_ROOT := ./common/persistence/tests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: DB_INTEGRATION_TEST_ROOT There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It also include ES tests and any future dependency integration tests. So I want to just use integration tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ES is also DB in this context. The path clearly points to persistence integration tests. If we have more integration tests in future, we will have another root and another var for it. So I would call this: |
||
DB_TOOL_INTEGRATION_TEST_ROOT := ./tools/tests | ||
|
||
PROTO_ROOT := proto | ||
PROTO_FILES = $(shell find ./$(PROTO_ROOT)/internal -name "*.proto") | ||
PROTO_DIRS = $(sort $(dir $(PROTO_FILES))) | ||
|
@@ -75,7 +79,7 @@ ALL_SCRIPTS := $(shell find . -name "*.sh") | |
# TODO (jeremy): Replace below with build tags and `go test ./...` for targets | ||
TEST_DIRS := $(sort $(dir $(filter %_test.go,$(ALL_SRC)))) | ||
INTEG_TEST_DIRS := $(filter $(INTEG_TEST_ROOT)/ $(INTEG_TEST_NDC_ROOT)/,$(TEST_DIRS)) | ||
UNIT_TEST_DIRS := $(filter-out $(INTEG_TEST_ROOT)% $(INTEG_TEST_XDC_ROOT)% $(INTEG_TEST_NDC_ROOT)%,$(TEST_DIRS)) | ||
UNIT_TEST_DIRS := $(filter-out $(INTEG_TEST_ROOT)% $(INTEG_TEST_XDC_ROOT)% $(INTEG_TEST_NDC_ROOT)% $(INTEGRATION_TEST_ROOT)% $(DB_TOOL_INTEGRATION_TEST_ROOT)%,$(TEST_DIRS)) | ||
|
||
# go.opentelemetry.io/otel/sdk/metric@v0.31.0 - there are breaking changes in v0.32.0. | ||
# 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 := \ | |
# Code coverage output files. | ||
COVER_ROOT := ./.coverage | ||
UNIT_COVER_PROFILE := $(COVER_ROOT)/unit_coverprofile.out | ||
INTEGRATION_COVER_PROFILE := $(COVER_ROOT)/integration_coverprofile.out | ||
DB_TOOL_COVER_PROFILE := $(COVER_ROOT)/db_tool_coverprofile.out | ||
INTEG_COVER_PROFILE := $(COVER_ROOT)/integ_$(PERSISTENCE_DRIVER)_coverprofile.out | ||
INTEG_XDC_COVER_PROFILE := $(COVER_ROOT)/integ_xdc_$(PERSISTENCE_DRIVER)_coverprofile.out | ||
INTEG_NDC_COVER_PROFILE := $(COVER_ROOT)/integ_ndc_$(PERSISTENCE_DRIVER)_coverprofile.out | ||
|
@@ -254,13 +260,20 @@ build-tests: | |
@printf $(COLOR) "Build tests..." | ||
@go test -exec="true" -count=0 -tags=esintegration $(TEST_DIRS) | ||
|
||
unit-test: | ||
unit-test: clean-test-results | ||
@printf $(COLOR) "Run unit tests..." | ||
$(foreach UNIT_TEST_DIR,$(UNIT_TEST_DIRS),\ | ||
@go test $(UNIT_TEST_DIR) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -race | tee -a test.log \ | ||
$(NEWLINE)) | ||
@! grep -q "^--- FAIL" test.log | ||
|
||
db-integration-test: clean-test-results | ||
@printf $(COLOR) "Run integration tests..." | ||
@go test $(INTEGRATION_TEST_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) | tee -a test.log | ||
@go test $(DB_TOOL_INTEGRATION_TEST_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) | tee -a test.log | ||
@! grep -q "^--- FAIL" test.log | ||
|
||
# TODO: rename it to functional-test | ||
integration-test: clean-test-results | ||
@printf $(COLOR) "Run integration tests..." | ||
$(foreach INTEG_TEST_DIR,$(INTEG_TEST_DIRS),\ | ||
|
@@ -270,6 +283,7 @@ integration-test: clean-test-results | |
@go test $(INTEG_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) | tee -a test.log | ||
@! grep -q "^--- FAIL" test.log | ||
|
||
# TODO: rename it to functional-test | ||
integration-with-fault-injection-test: clean-test-results | ||
@printf $(COLOR) "Run integration tests with fault injection..." | ||
$(foreach INTEG_TEST_DIR,$(INTEG_TEST_DIRS),\ | ||
|
@@ -279,7 +293,7 @@ integration-with-fault-injection-test: clean-test-results | |
@go test $(INTEG_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -PersistenceFaultInjectionRate=0.005 | tee -a test.log | ||
@! grep -q "^--- FAIL" test.log | ||
|
||
test: unit-test integration-test integration-with-fault-injection-test | ||
test: unit-test db-integration-test integration-test integration-with-fault-injection-test | ||
|
||
##### Coverage ##### | ||
$(COVER_ROOT): | ||
|
@@ -294,14 +308,22 @@ unit-test-coverage: $(COVER_ROOT) | |
grep -v -e "^mode: \w\+" $(COVER_ROOT)/$(UNIT_TEST_DIR)/coverprofile.out >> $(UNIT_COVER_PROFILE) || true \ | ||
$(NEWLINE)) | ||
|
||
db-integration-test-coverage: $(COVER_ROOT) | ||
@printf $(COLOR) "Run integration tests with coverage..." | ||
@go test $(INTEGRATION_TEST_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) $(INTEG_TEST_COVERPKG) -coverprofile=$(INTEGRATION_COVER_PROFILE) | ||
@go test $(DB_TOOL_INTEGRATION_TEST_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) $(INTEG_TEST_COVERPKG) -coverprofile=$(DB_TOOL_COVER_PROFILE) | ||
|
||
# TODO: rename it to functional-test | ||
integration-test-coverage: $(COVER_ROOT) | ||
@printf $(COLOR) "Run integration tests with coverage with $(PERSISTENCE_DRIVER) driver..." | ||
@go test $(INTEG_TEST_ROOT) -timeout=$(TEST_TIMEOUT) -race $(TEST_TAG) -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) $(INTEG_TEST_COVERPKG) -coverprofile=$(INTEG_COVER_PROFILE) | ||
|
||
# TODO: rename it to functional-test | ||
integration-test-xdc-coverage: $(COVER_ROOT) | ||
@printf $(COLOR) "Run integration test for cross DC with coverage with $(PERSISTENCE_DRIVER) driver..." | ||
@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) | ||
|
||
# TODO: rename it to functional-test | ||
integration-test-ndc-coverage: $(COVER_ROOT) | ||
@printf $(COLOR) "Run integration test for NDC with coverage with $(PERSISTENCE_DRIVER) driver..." | ||
@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) | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to address these TODOs first (in separate PR). Otherwise, we gonna have two different integration test sets and w/o looking at this PR it would be extremely hard to understand "why?".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you can do it right after. Just please don't postpone it.