Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

*: split unit test according to upstream MySQL #416

Merged
merged 5 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ GO := GO111MODULE=on go
GOBUILD := CGO_ENABLED=0 $(GO) build
GOTEST := CGO_ENABLED=1 $(GO) test
PACKAGES := $$(go list ./... | grep -vE 'tests|cmd|vendor|pbmock')
PACKAGES_RELAY := $$(go list ./... | grep -vE 'tests|cmd|vendor|pbmock' | grep 'github.com/pingcap/dm/relay')
PACKAGES_SYNCER := $$(go list ./... | grep -vE 'tests|cmd|vendor|pbmock' | grep 'github.com/pingcap/dm/syncer')
PACKAGES_PKG_BINLOG := $$(go list ./... | grep -vE 'tests|cmd|vendor|pbmock' | grep 'github.com/pingcap/dm/pkg/binlog')
amyangfei marked this conversation as resolved.
Show resolved Hide resolved
PACKAGES_OTHERS := $$(go list ./... | grep -vE 'tests|cmd|vendor|pbmock|github.com/pingcap/dm/relay|github.com/pingcap/dm/syncer|github.com/pingcap/dm/pkg/binlog')
FILES := $$(find . -name "*.go" | grep -vE "vendor")
TOPDIRS := $$(ls -d */ | grep -vE "vendor")
SHELL := /usr/bin/env bash
Expand Down Expand Up @@ -67,15 +71,32 @@ debug-tools:

test: unit_test integration_test

unit_test:
define run_unit_test
@echo "running unit test for packages:" $(1)
bash -x ./tests/wait_for_mysql.sh
mkdir -p $(TEST_DIR)
which $(FAILPOINT) >/dev/null 2>&1 || $(GOBUILD) -o $(FAILPOINT) github.com/pingcap/failpoint/failpoint-ctl
$(FAILPOINT_ENABLE)
@export log_level=error; \
$(GOTEST) -covermode=atomic -coverprofile="$(TEST_DIR)/cov.unit_test.out" $(TEST_RACE_FLAG) $(PACKAGES) \
$(GOTEST) -covermode=atomic -coverprofile="$(TEST_DIR)/cov.$(2).out" $(TEST_RACE_FLAG) $(1) \
|| { $(FAILPOINT_DISABLE); exit 1; }
$(FAILPOINT_DISABLE)
endef

unit_test:
$(call run_unit_test,$(PACKAGES),unit_test)

unit_test_relay:
$(call run_unit_test,$(PACKAGES_RELAY),unit_test_relay)

unit_test_syncer:
$(call run_unit_test,$(PACKAGES_SYNCER),unit_test_syncer)

unit_test_pkg_binlog:
$(call run_unit_test,$(PACKAGES_PKG_BINLOG),unit_test_pkg_binlog)

unit_test_others:
$(call run_unit_test,$(PACKAGES_OTHERS),unit_test_others)

check: fmt lint vet terror_check

Expand Down Expand Up @@ -151,7 +172,7 @@ coverage_fix_cover_mode:
coverage: coverage_fix_cover_mode
GO111MODULE=off go get github.com/zhouqiang-cl/gocovmerge
gocovmerge "$(TEST_DIR)"/cov.* | grep -vE ".*.pb.go|.*.__failpoint_binding__.go" > "$(TEST_DIR)/all_cov.out"
grep -vE ".*.pb.go|.*.__failpoint_binding__.go" $(TEST_DIR)/cov.unit_test.out > $(TEST_DIR)/unit_test.out
gocovmerge "$(TEST_DIR)"/cov.unit_test*.out | grep -vE ".*.pb.go|.*.__failpoint_binding__.go" > $(TEST_DIR)/unit_test.out
ifeq ("$(JenkinsCI)", "1")
GO111MODULE=off go get github.com/mattn/goveralls
@goveralls -coverprofile=$(TEST_DIR)/all_cov.out -service=jenkins-ci -repotoken $(COVERALLS_TOKEN)
Expand Down
2 changes: 1 addition & 1 deletion dm/worker/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (t *testServer) TestTaskAutoResume(c *C) {
c.Assert(err, IsNil)

// check task in paused state
c.Assert(utils.WaitSomething(10, 100*time.Millisecond, func() bool {
c.Assert(utils.WaitSomething(100, 100*time.Millisecond, func() bool {
for _, st := range s.worker.QueryStatus(taskName) {
if st.Name == taskName && st.Stage == pb.Stage_Paused {
return true
Expand Down