Skip to content

Commit

Permalink
Merge branch 'master' into issue-1339
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored May 17, 2021
2 parents c330e77 + 5059068 commit 940fc07
Show file tree
Hide file tree
Showing 16 changed files with 2,961 additions and 567 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ playground:

client:
@# Target: build the tiup-client component
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/tiup-client ./components/client
$(MAKE) -C components/client $(MAKECMDGOALS)

cluster:
@# Target: build the tiup-cluster component
Expand All @@ -71,7 +71,7 @@ dm:

bench:
@# Target: build the tiup-bench component
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/tiup-bench ./components/bench
$(MAKE) -C components/bench $(MAKECMDGOALS)

doc:
@# Target: build the tiup-doc component
Expand Down
116 changes: 116 additions & 0 deletions components/bench/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
.DEFAULT_GOAL := default

LANG=C
MAKEOVERRIDES =
targets:
@printf "%-30s %s\n" "Target" "Description"
@printf "%-30s %s\n" "------" "-----------"
@make -pqR : 2>/dev/null \
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \
| egrep -v -e '^[^[:alnum:]]' -e '^$@$$' \
| sort \
| xargs -I _ sh -c 'printf "%-30s " _; make _ -nB | (grep "^# Target:" || echo "") | tail -1 | sed "s/^# Target: //g"'

REPO := github.com/pingcap/tiup

GOOS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
GOARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
GOENV := GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH)
GO := $(GOENV) go
GOBUILD := $(GO) build $(BUILD_FLAGS)
GOTEST := GO111MODULE=on CGO_ENABLED=1 go test -p 3
SHELL := /usr/bin/env bash

_COMMIT := $(shell git describe --no-match --always --dirty)
_GITREF := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(if $(COMMIT),$(COMMIT),$(_COMMIT))
GITREF := $(if $(GITREF),$(GITREF),$(_GITREF))

LDFLAGS := -w -s
LDFLAGS += -X "$(REPO)/pkg/version.GitHash=$(COMMIT)"
LDFLAGS += -X "$(REPO)/pkg/version.GitRef=$(GITREF)"
LDFLAGS += $(EXTRA_LDFLAGS)

FILES := $$(find . -name "*.go")

FAILPOINT_ENABLE := $$(../../tools/bin/failpoint-ctl enable)
FAILPOINT_DISABLE := $$(../../tools/bin/failpoint-ctl disable)

default: check build
@# Target: run the checks and then build.

include ../../tests/Makefile

# Build components
build: components
@# Target: build tiup and all it's components

components: bench
@# Target: build the playground, client, cluster, dm, bench and server components

bench:
@# Target: build the tiup-bench component
$(GOBUILD) -ldflags '$(LDFLAGS)' -o ../../bin/tiup-bench .

check: fmt lint tidy check-static vet
@# Target: run all checkers. (fmt, lint, tidy, check-static and vet)

check-static:
@# Target: run the golangci-lint static check tool
../../tools/bin/golangci-lint run --config ../../tools/check/golangci.yaml ./... --deadline=3m --fix

lint:
@# Target: run the lint checker revive
@echo "linting"
../../tools/check/check-lint.sh
@../../tools/bin/revive -formatter friendly -config ../../tools/check/revive.toml $(FILES)

vet:
@# Target: run the go vet tool
$(GO) vet ./...

tidy:
@# Target: run tidy check
@echo "go mod tidy"
../../tools/check/check-tidy.sh

clean:
@# Target: run the build cleanup steps
@rm -rf bin
@rm -rf cover
@rm -rf tests/*/{bin/*.test,logs,cover/*.out}

test: failpoint-enable run-tests failpoint-disable
@# Target: run tests with failpoint enabled

# TODO: refactor integration tests base on v1 manifest
# run-tests: unit-test integration_test
run-tests: unit-test
@# Target: run the unit tests

# Run tests
unit-test:
@# Target: run the code coverage test phase
mkdir -p cover
TIUP_HOME=$(shell pwd)/../../tests/tiup $(GOTEST) ./... -covermode=count -coverprofile ../../cover/cov.unit-test.out

race: failpoint-enable
@# Target: run race check with failpoint enabled
TIUP_HOME=$(shell pwd)/../../tests/tiup $(GOTEST) -race ./... || { $(FAILPOINT_DISABLE); exit 1; }
@$(FAILPOINT_DISABLE)

failpoint-enable:
@# Target: enable failpoint
@$(FAILPOINT_ENABLE)

failpoint-disable:
@# Target: disable failpoint
@$(FAILPOINT_DISABLE)

fmt:
@# Target: run the go formatter utility
@echo "gofmt (simplify)"
@gofmt -s -l -w $(FILES) 2>&1
@echo "goimports (if installed)"
$(shell goimports -w $(FILES) 2>/dev/null)

11 changes: 11 additions & 0 deletions components/bench/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/tiup/components/bench

go 1.16

require (
github.com/go-sql-driver/mysql v1.6.0
github.com/magiconair/properties v1.8.5
github.com/pingcap/go-tpc v1.0.7
github.com/pingcap/go-ycsb v0.0.0-20210422030059-021df3b60d69
github.com/spf13/cobra v1.1.3
)
757 changes: 757 additions & 0 deletions components/bench/go.sum

Large diffs are not rendered by default.

116 changes: 116 additions & 0 deletions components/client/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
.DEFAULT_GOAL := default

LANG=C
MAKEOVERRIDES =
targets:
@printf "%-30s %s\n" "Target" "Description"
@printf "%-30s %s\n" "------" "-----------"
@make -pqR : 2>/dev/null \
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \
| egrep -v -e '^[^[:alnum:]]' -e '^$@$$' \
| sort \
| xargs -I _ sh -c 'printf "%-30s " _; make _ -nB | (grep "^# Target:" || echo "") | tail -1 | sed "s/^# Target: //g"'

REPO := github.com/pingcap/tiup

GOOS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
GOARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
GOENV := GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH)
GO := $(GOENV) go
GOBUILD := $(GO) build $(BUILD_FLAGS)
GOTEST := GO111MODULE=on CGO_ENABLED=1 go test -p 3
SHELL := /usr/bin/env bash

_COMMIT := $(shell git describe --no-match --always --dirty)
_GITREF := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(if $(COMMIT),$(COMMIT),$(_COMMIT))
GITREF := $(if $(GITREF),$(GITREF),$(_GITREF))

LDFLAGS := -w -s
LDFLAGS += -X "$(REPO)/pkg/version.GitHash=$(COMMIT)"
LDFLAGS += -X "$(REPO)/pkg/version.GitRef=$(GITREF)"
LDFLAGS += $(EXTRA_LDFLAGS)

FILES := $$(find . -name "*.go")

FAILPOINT_ENABLE := $$(../../tools/bin/failpoint-ctl enable)
FAILPOINT_DISABLE := $$(../../tools/bin/failpoint-ctl disable)

default: check build
@# Target: run the checks and then build.

include ../../tests/Makefile

# Build components
build: components
@# Target: build tiup and all it's components

components: client
@# Target: build the playground, client, cluster, dm, bench and server components

client:
@# Target: build the tiup-client component
$(GOBUILD) -ldflags '$(LDFLAGS)' -o ../../bin/tiup-client .

check: fmt lint tidy check-static vet
@# Target: run all checkers. (fmt, lint, tidy, check-static and vet)

check-static:
@# Target: run the golangci-lint static check tool
../../tools/bin/golangci-lint run --config ../../tools/check/golangci.yaml ./... --deadline=3m --fix

lint:
@# Target: run the lint checker revive
@echo "linting"
../../tools/check/check-lint.sh
@../../tools/bin/revive -formatter friendly -config ../../tools/check/revive.toml $(FILES)

vet:
@# Target: run the go vet tool
$(GO) vet ./...

tidy:
@# Target: run tidy check
@echo "go mod tidy"
../../tools/check/check-tidy.sh

clean:
@# Target: run the build cleanup steps
@rm -rf bin
@rm -rf cover
@rm -rf tests/*/{bin/*.test,logs,cover/*.out}

test: failpoint-enable run-tests failpoint-disable
@# Target: run tests with failpoint enabled

# TODO: refactor integration tests base on v1 manifest
# run-tests: unit-test integration_test
run-tests: unit-test
@# Target: run the unit tests

# Run tests
unit-test:
@# Target: run the code coverage test phase
mkdir -p cover
TIUP_HOME=$(shell pwd)/../../tests/tiup $(GOTEST) ./... -covermode=count -coverprofile ../../cover/cov.unit-test.out

race: failpoint-enable
@# Target: run race check with failpoint enabled
TIUP_HOME=$(shell pwd)/../../tests/tiup $(GOTEST) -race ./... || { $(FAILPOINT_DISABLE); exit 1; }
@$(FAILPOINT_DISABLE)

failpoint-enable:
@# Target: enable failpoint
@$(FAILPOINT_ENABLE)

failpoint-disable:
@# Target: disable failpoint
@$(FAILPOINT_DISABLE)

fmt:
@# Target: run the go formatter utility
@echo "gofmt (simplify)"
@gofmt -s -l -w $(FILES) 2>&1
@echo "goimports (if installed)"
$(shell goimports -w $(FILES) 2>/dev/null)

15 changes: 15 additions & 0 deletions components/client/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module github.com/tiup/components/client

go 1.16

require (
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/gizak/termui/v3 v3.1.0
github.com/mattn/go-sqlite3 v2.0.2+incompatible // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shirou/gopsutil v3.21.4+incompatible
github.com/spf13/cobra v1.1.3
github.com/tklauser/go-sysconf v0.3.4 // indirect
github.com/xo/usql v0.9.1
)
Loading

0 comments on commit 940fc07

Please sign in to comment.