Skip to content

Commit

Permalink
Merge pull request #842 from pingcap/sprint9
Browse files Browse the repository at this point in the history
Sprint9
  • Loading branch information
haiboumich authored Jun 13, 2022
2 parents de96fe4 + 62bf9a7 commit 737bb16
Show file tree
Hide file tree
Showing 439 changed files with 20,213 additions and 4,303 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/tiem.iml
/tiunimanager.iml
.DS_Store
golangci-lint-report.xml
results.xml
Expand Down
89 changes: 44 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

TIEM_BINARY_DIR = ${CURDIR}/bin
TIUPCMD_BINARY = ${TIEM_BINARY_DIR}/tiupcmd
BRCMD_BINARY = ${TIEM_BINARY_DIR}/brcmd
OPENAPI_SERVER_BINARY = ${TIEM_BINARY_DIR}/openapi-server
CLUSTER_SERVER_BINARY = ${TIEM_BINARY_DIR}/cluster-server
FILE_SERVER_BINARY = ${TIEM_BINARY_DIR}/file-server
TIEM_INSTALL_PREFIX = ${PREFIX}/tiem
TIUNIMANAGER_BINARY_DIR = ${CURDIR}/bin
TIUPCMD_BINARY = ${TIUNIMANAGER_BINARY_DIR}/tiupcmd
BRCMD_BINARY = ${TIUNIMANAGER_BINARY_DIR}/brcmd
OPENAPI_SERVER_BINARY = ${TIUNIMANAGER_BINARY_DIR}/openapi-server
CLUSTER_SERVER_BINARY = ${TIUNIMANAGER_BINARY_DIR}/cluster-server
FILE_SERVER_BINARY = ${TIUNIMANAGER_BINARY_DIR}/file-server
TIUNIMANAGER_INSTALL_PREFIX = ${PREFIX}/tiunimanager
PROTOC_GEN_MICRO = github.com/asim/go-micro/cmd/protoc-gen-micro/[email protected]
PROTOC_GEN_GO = google.golang.org/protobuf/cmd/[email protected]
PROTOBUF_VERSION = 3.14.0
Expand Down Expand Up @@ -55,13 +55,13 @@ proto:

# 1. build binary
build:
@echo "build TiEM server start."
@echo "build TiUniManager server start."
make build_openapi_server
make build_cluster_server
make build_file_server
@echo "build TiEM all server successfully."
@echo "build TiUniManager all server successfully."

#Compile all TiEM microservices
#Compile all TiUniManager microservices
build_openapi_server:
@echo "build openapi-server start."
$(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o ${OPENAPI_SERVER_BINARY} micro-api/*.go
Expand Down Expand Up @@ -105,89 +105,89 @@ gotool:
#Get and compile the tools required in the project
build_revive: build_helper/go.mod
cd build_helper; \
$(GO) build -o ${TIEM_BINARY_DIR}/revive github.com/mgechev/revive
$(GO) build -o ${TIUNIMANAGER_BINARY_DIR}/revive github.com/mgechev/revive

build_goword: build_helper/go.mod
cd build_helper; \
$(GO) build -o ${TIEM_BINARY_DIR}/goword github.com/chzchzchz/goword
$(GO) build -o ${TIUNIMANAGER_BINARY_DIR}/goword github.com/chzchzchz/goword

build_unconvert: build_helper/go.mod
cd build_helper; \
$(GO) build -o ${TIEM_BINARY_DIR}/unconvert github.com/mdempsky/unconvert
$(GO) build -o ${TIUNIMANAGER_BINARY_DIR}/unconvert github.com/mdempsky/unconvert

build_failpoint_ctl: build_helper/go.mod
cd build_helper; \
$(GO) build -o ${TIEM_BINARY_DIR}/failpoint-ctl github.com/pingcap/failpoint/failpoint-ctl
$(GO) build -o ${TIUNIMANAGER_BINARY_DIR}/failpoint-ctl github.com/pingcap/failpoint/failpoint-ctl

build_errdoc_gen: build_helper/go.mod
cd build_helper; \
$(GO) build -o ${TIEM_BINARY_DIR}/errdoc-gen github.com/pingcap/errors/errdoc-gen
$(GO) build -o ${TIUNIMANAGER_BINARY_DIR}/errdoc-gen github.com/pingcap/errors/errdoc-gen

build_golangci_lint:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ${TIEM_BINARY_DIR} v1.41.1
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ${TIUNIMANAGER_BINARY_DIR} v1.41.1

build_vfsgendev: build_helper/go.mod
cd build_helper; \
$(GO) build -o ${TIEM_BINARY_DIR}/vfsgendev github.com/shurcooL/vfsgen/cmd/vfsgendev
$(GO) build -o ${TIUNIMANAGER_BINARY_DIR}/vfsgendev github.com/shurcooL/vfsgen/cmd/vfsgendev

build_megacheck: build_helper/go.mod
cd build_helper; \
$(GO) build -o ${TIEM_BINARY_DIR}/megacheck honnef.co/go/build_helper/cmd/megacheck
$(GO) build -o ${TIUNIMANAGER_BINARY_DIR}/megacheck honnef.co/go/build_helper/cmd/megacheck

check_fmt:
@echo "gofmt (simplify)"
#@gofmt -s -l -w $(FILES) 2>&1 | $(FAIL_ON_STDOUT)

check_goword:
@echo "goword check, files: ${FILES}"
#${TIEM_BINARY_DIR}/goword $(FILES) 2>&1 | $(FAIL_ON_STDOUT)
#${TIUNIMANAGER_BINARY_DIR}/goword $(FILES) 2>&1 | $(FAIL_ON_STDOUT)

check_static:
@echo "code static check, files: $($(PACKAGE_LIST))"
#${TIEM_BINARY_DIR}/golangci-lint run -v $$($(PACKAGE_DIRECTORIES))
#${TIUNIMANAGER_BINARY_DIR}/golangci-lint run -v $$($(PACKAGE_DIRECTORIES))

check_unconvert:
@echo "unconvert check, files: $($(PACKAGE_LIST))"
#@GO111MODULE=on ${TIEM_BINARY_DIR}/unconvert $(UNCONVERT_PACKAGES)
#@GO111MODULE=on ${TIUNIMANAGER_BINARY_DIR}/unconvert $(UNCONVERT_PACKAGES)

check_lint:
@echo "linting check"
#@${TIEM_BINARY_DIR}/revive -formatter friendly -config build_helper/revive.toml $(FILES_WITHOUT_BR)
#@${TIUNIMANAGER_BINARY_DIR}/revive -formatter friendly -config build_helper/revive.toml $(FILES_WITHOUT_BR)

check_vet:
@echo "vet check"
#$(GO) vet -all $(PACKAGES_WITHOUT_BR) 2>&1 | $(FAIL_ON_STDOUT)

install:
mkdir -p ${TIEM_INSTALL_PREFIX}
mkdir -p ${TIEM_INSTALL_PREFIX}/bin
mkdir -p ${TIEM_INSTALL_PREFIX}/etc
mkdir -p ${TIEM_INSTALL_PREFIX}/logs
mkdir -p ${TIEM_INSTALL_PREFIX}/scripts
mkdir -p ${TIEM_INSTALL_PREFIX}/docs
cp ${TIUPCMD_BINARY} ${TIEM_INSTALL_PREFIX}/bin
cp ${BRCMD_BINARY} ${TIEM_INSTALL_PREFIX}/bin
cp ${OPENAPI_SERVER_BINARY} ${TIEM_INSTALL_PREFIX}/bin
cp ${CLUSTER_SERVER_BINARY} ${TIEM_INSTALL_PREFIX}/bin
cp ${FILE_SERVER_BINARY} ${TIEM_INSTALL_PREFIX}/bin
mkdir -p ${TIUNIMANAGER_INSTALL_PREFIX}
mkdir -p ${TIUNIMANAGER_INSTALL_PREFIX}/bin
mkdir -p ${TIUNIMANAGER_INSTALL_PREFIX}/etc
mkdir -p ${TIUNIMANAGER_INSTALL_PREFIX}/logs
mkdir -p ${TIUNIMANAGER_INSTALL_PREFIX}/scripts
mkdir -p ${TIUNIMANAGER_INSTALL_PREFIX}/docs
cp ${TIUPCMD_BINARY} ${TIUNIMANAGER_INSTALL_PREFIX}/bin
cp ${BRCMD_BINARY} ${TIUNIMANAGER_INSTALL_PREFIX}/bin
cp ${OPENAPI_SERVER_BINARY} ${TIUNIMANAGER_INSTALL_PREFIX}/bin
cp ${CLUSTER_SERVER_BINARY} ${TIUNIMANAGER_INSTALL_PREFIX}/bin
cp ${FILE_SERVER_BINARY} ${TIUNIMANAGER_INSTALL_PREFIX}/bin

uninstall:
@echo "uninstall: remove all files in $(TIEM_INSTALL_PREFIX)"
@if [ -d ${TIEM_INSTALL_PREFIX} ] ; then rm ${TIEM_INSTALL_PREFIX} ; fi
@echo "uninstall: remove all files in $(TIUNIMANAGER_INSTALL_PREFIX)"
@if [ -d ${TIUNIMANAGER_INSTALL_PREFIX} ] ; then rm ${TIUNIMANAGER_INSTALL_PREFIX} ; fi

clean:
@if [ -f ${BRCMD_BINARY} ] ; then rm ${BRCMD_BINARY} ; fi
@if [ -f ${TIUPCMD_BINARY} ] ; then rm ${TIUPCMD_BINARY} ; fi
@if [ -f ${OPENAPI_SERVER_BINARY} ] ; then rm ${OPENAPI_SERVER_BINARY} ; fi
@if [ -f ${CLUSTER_SERVER_BINARY} ] ; then rm ${CLUSTER_SERVER_BINARY} ; fi
@if [ -f ${FILE_SERVER_BINARY} ] ; then rm ${FILE_SERVER_BINARY} ; fi
@if [ -f ${TIEM_BINARY_DIR}/revive ] ; then rm ${TIEM_BINARY_DIR}/revive ; fi
@if [ -f ${TIEM_BINARY_DIR}/goword ] ; then rm ${TIEM_BINARY_DIR}/goword ; fi
@if [ -f ${TIEM_BINARY_DIR}/unconvert ] ; then rm ${TIEM_BINARY_DIR}/unconvert ; fi
@if [ -f ${TIEM_BINARY_DIR}/failpoint-ctl ] ; then rm ${TIEM_BINARY_DIR}/failpoint-ctl; fi
@if [ -f ${TIEM_BINARY_DIR}/vfsgendev ] ; then rm ${TIEM_BINARY_DIR}/vfsgendev; fi
@if [ -f ${TIEM_BINARY_DIR}/golangci-lint ] ; then rm ${TIEM_BINARY_DIR}/golangci-lint; fi
@if [ -f ${TIEM_BINARY_DIR}/errdoc-gen ] ; then rm ${TIEM_BINARY_DIR}/errdoc-gen; fi
@if [ -f ${TIUNIMANAGER_BINARY_DIR}/revive ] ; then rm ${TIUNIMANAGER_BINARY_DIR}/revive ; fi
@if [ -f ${TIUNIMANAGER_BINARY_DIR}/goword ] ; then rm ${TIUNIMANAGER_BINARY_DIR}/goword ; fi
@if [ -f ${TIUNIMANAGER_BINARY_DIR}/unconvert ] ; then rm ${TIUNIMANAGER_BINARY_DIR}/unconvert ; fi
@if [ -f ${TIUNIMANAGER_BINARY_DIR}/failpoint-ctl ] ; then rm ${TIUNIMANAGER_BINARY_DIR}/failpoint-ctl; fi
@if [ -f ${TIUNIMANAGER_BINARY_DIR}/vfsgendev ] ; then rm ${TIUNIMANAGER_BINARY_DIR}/vfsgendev; fi
@if [ -f ${TIUNIMANAGER_BINARY_DIR}/golangci-lint ] ; then rm ${TIUNIMANAGER_BINARY_DIR}/golangci-lint; fi
@if [ -f ${TIUNIMANAGER_BINARY_DIR}/errdoc-gen ] ; then rm ${TIUNIMANAGER_BINARY_DIR}/errdoc-gen; fi
@if [ -d ${GENERATE_TARGET_DIR}/clusterservices ] ; then rm -rf ${GENERATE_TARGET_DIR}/clusterservices; fi
@if [ -d ${CURDIR}/test ] ; then rm -rf ${CURDIR}/test; fi

Expand Down Expand Up @@ -219,7 +219,7 @@ ci_test: add_test_file prepare proto build mock
GO111MODULE=off go get github.com/axw/gocov/gocov
GO111MODULE=off go get github.com/jstemmer/go-junit-report
GO111MODULE=off go get github.com/AlekSi/gocov-xml
go test -v ${PACKAGES} -coverprofile=cover.out |go-junit-report > test.xml
go test -v ${PACKAGES} -coverprofile=cover.out | sed 's/\x1b//g' | go-junit-report -out test.xml
gocov convert cover.out | gocov-xml > coverage.xml

test: prepare proto build mock
Expand Down Expand Up @@ -270,13 +270,12 @@ mock:
mockgen -destination ./test/mockmodels/mockconfig/mock_config_interface.go -package mockconfig -source ./models/platform/config/readerwriter.go
mockgen -destination ./test/mockmodels/mocksystem/mock_system_interface.go -package mocksystem -source ./models/platform/system/readerwriter.go
mockgen -destination ./test/mockmodels/mocksecondparty/mock_secondparty_interface.go -package mocksecondparty -source ./models/workflow/secondparty/readerwriter.go
mockgen -destination ./test/mockmodels/mocktiupconfig/mock_tiupconfig_interface.go -package mocktiupconfig -source ./models/tiup/readerwriter.go
mockgen -destination ./test/mockmodels/mockparametergroup/mock_parametergroup_interface.go -package mockparametergroup -source ./models/parametergroup/readerwriter.go
mockgen -destination ./test/mockmodels/mockclusterparameter/mock_clusterparameter_interface.go -package mockclusterparameter -source ./models/cluster/parameter/readerwriter.go
mockgen -destination ./test/mockmodels/mockclustermanagement/mock_cluster_management_interface.go -package mockclustermanagement -source ./models/cluster/management/readerwriter.go
mockgen -destination ./test/mockmodels/mockchangefeed/mock_change_feed_interface.go -package mockchangefeed -source ./models/cluster/changefeed/readerwriter.go
mockgen -destination ./test/mockmodels/mockaccount/mock_account.go -package mock_account -source ./models/user/account/readerwriter.go
mockgen -destination ./test/mockworkflow/mock_workflow.go -package mock_workflow_service -source ./workflow/workflow.go
mockgen -destination ./test/mockworkflow/mock_workflow.go -package mock_workflow_service -source ./workflow2/service.go
mockgen -destination ./test/mockbr/mock_br.go -package mock_br_service -source ./micro-cluster/cluster/backuprestore/service.go
mockgen -destination ./test/mockdeployment/mock_deployment.go -package mock_deployment -source ./deployment/deploymentInterface.go
mockgen -destination ./test/mockresource/mockinitiator/mock_initiator_interface.go -package mockinitiator -source ./micro-cluster/resourcemanager/resourcepool/hostinitiator/hostinitiator.go
Expand Down
22 changes: 11 additions & 11 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

PROJECT=tiem
PROJECT=tiunimanager
GOPATH ?= $(shell go env GOPATH)
P=8

Expand Down Expand Up @@ -53,11 +53,11 @@ GOBUILD := $(GO) build $(BUILD_FLAG) -tags codes
GOTEST := $(GO) test -p $(P)
OVERALLS := GO111MODULE=on overalls
STATICCHECK := GO111MODULE=on staticcheck
TIEM_EDITION ?= Enterprise
TIUNIMANAGER_EDITION ?= Enterprise

# Ensure TIEM_EDITION is set to Community or Enterprise before running build process.
ifneq "$(TIEM_EDITION)" "Enterprise"
$(error Please set the correct environment variable TIEM_EDITION before running `make`)
# Ensure TIUNIMANAGER_EDITION is set to Community or Enterprise before running build process.
ifneq "$(TIUNIMANAGER_EDITION)" "Enterprise"
$(error Please set the correct environment variable TIUNIMANAGER_EDITION before running `make`)
endif

# use 'make <target> PREFIX=/path/for/prefix' to overwrite the PREFIX value
Expand All @@ -68,7 +68,7 @@ endif
LINUX := "Linux"
MAC := "Darwin"

PACKAGE_LIST := go list ./...| grep -vE "docs|proto|common|message|micro-cluster/service|util|micro-cluster/registry|micro-cluster/platform/telemetry|library/framework|micro-api|file-server|test/mock|deprecated|util/scp|^github.com/pingcap-inc/tiem/micro-cluster$$|library/secondparty|micro-cluster/resourcemanager/management|models/resource/management|micro-cluster/cluster/switchover"
PACKAGE_LIST := go list ./...| grep -vE "docs|proto|common|message|micro-cluster/service|util|micro-cluster/registry|micro-cluster/platform/telemetry|library/framework|micro-api|workflow|file-server|test/mock|deprecated|util/scp|^github.com/pingcap/tiunimanager/micro-cluster$$|library/secondparty|micro-cluster/resourcemanager/management|models/resource/management|micro-cluster/cluster/switchover"
PACKAGES ?= $$($(PACKAGE_LIST))
LINT_PACKAGE_LIST := go list ./...| grep -vE "docs|proto|test"
LINT_PACKAGES ?= $$($(LINT_PACKAGE_LIST))
Expand All @@ -79,11 +79,11 @@ FILES := $$(find $$($(PACKAGE_DIRECTORIES)) -name "*.go")
FAILPOINT_ENABLE := $$(find $$PWD/ -type d | grep -vE "(\.git)" | xargs bin/failpoint-ctl enable)
FAILPOINT_DISABLE := $$(find $$PWD/ -type d | grep -vE "(\.git)" | xargs bin/failpoint-ctl disable)

LDFLAGS += -X "github.com/pingcap/tiem/library/fristparty/util/versioninfo.TiEMReleaseVersion=$(shell git describe --tags --dirty --always)"
LDFLAGS += -X "github.com/pingcap/tiem/library/firstparty/util/versioninfo.TiEMBuildTS=$(shell date -u '+%Y-%m-%d %H:%M:%S')"
LDFLAGS += -X "github.com/pingcap/tiem/library/firstparty/util/versioninfo.TiEMGitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "github.com/pingcap/tiem/library/firstparty/util/versioninfo.TiEMGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
LDFLAGS += -X "github.com/pingcap/tiem/library/firstparty/util/versioninfo.TiEMEdition=$(TIEM_EDITION)"
LDFLAGS += -X "github.com/pingcap/tiunimanager/library/fristparty/util/versioninfo.TiUniManagerReleaseVersion=$(shell git describe --tags --dirty --always)"
LDFLAGS += -X "github.com/pingcap/tiunimanager/library/firstparty/util/versioninfo.TiUniManagerBuildTS=$(shell date -u '+%Y-%m-%d %H:%M:%S')"
LDFLAGS += -X "github.com/pingcap/tiunimanager/library/firstparty/util/versioninfo.TiUniManagerGitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "github.com/pingcap/tiunimanager/library/firstparty/util/versioninfo.TiUniManagerGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
LDFLAGS += -X "github.com/pingcap/tiunimanager/library/firstparty/util/versioninfo.TiUniManagerEdition=$(TIUNIMANAGER_EDITION)"

#TODO TEST_LDFLAGS = -X "github.com/pingcap/tidb/config.checkBeforeDropLDFlag=1"
#TODO COVERAGE_SERVER_LDFLAGS = -X "github.com/pingcap/tidb/tidb-server.isCoverageServer=1"
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TiEM - TiDB Enterprise Manager
# TiUniManager

## Contents

Expand All @@ -7,14 +7,14 @@
- micro-cluster - Core service.
- docs - Documentation.

## Build and Run TiEM
## Build and Run TiUniManager

TiEM can be compiled and used on Linux, OSX, CentOS, It is as simple as:
TiUniManager can be compiled and used on Linux, OSX, CentOS, It is as simple as:
```
make
```

After building TiEM, it is good idea to test it using:
After building TiUniManager, it is good idea to test it using:
```
make test
```
Expand Down Expand Up @@ -58,7 +58,7 @@ For example:

```go
import(
"github.com/pingcap/tiem/addon/logger"
"github.com/pingcap/tiunimanager/addon/logger"
)
```

Expand All @@ -83,7 +83,7 @@ func CheckUser(ctx context.Context, name, passwd string) error {
```go
func init() {
var err error
dbFile := "tiem.sqlite.db"
dbFile := "tiunimanager.sqlite.db"
log := logger.WithContext(nil).WithField("dbFile", dbFile)
getLogger().Debug("init: sqlite.open")
db, err = gorm.Open(sqlite.Open(dbFile), &gorm.Config{})
Expand Down
29 changes: 0 additions & 29 deletions bin/cert/server.crt

This file was deleted.

27 changes: 0 additions & 27 deletions bin/cert/server.csr

This file was deleted.

Loading

0 comments on commit 737bb16

Please sign in to comment.