From 3caa8c4a2565f609511eafc95939abd0b941527e Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Mon, 11 Nov 2019 10:46:57 -0300 Subject: [PATCH] PMM-2605 Removed go 1.9.x from .travis.yml Also updated Makefile to run all the tests --- .gitignore | 1 + .travis.yml | 1 - src/go/.env | 26 --------------- src/go/Makefile | 33 +++++++++++-------- src/go/docker-compose.yml | 28 ++++++++++++++++ src/go/lib/versioncheck/version_check_test.go | 2 +- src/go/pt-pg-summary/internal/tu/tu.go | 8 ++--- src/go/runtests.sh | 4 ++- 8 files changed, 57 insertions(+), 46 deletions(-) delete mode 100644 src/go/.env diff --git a/.gitignore b/.gitignore index 289341bd..e47fb33e 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ src/go/pt-mongodb-summary/vendor/ vendor/ *.bak src/go/*.bak +src/go/.env config/deb/control.bak config/rpm/percona-toolkit.spec.bak config/sphinx-build/percona-theme/* diff --git a/.travis.yml b/.travis.yml index a40f8047..c54b30d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: go go: - - 1.9.x - 1.10.x - 1.12.x diff --git a/src/go/.env b/src/go/.env deleted file mode 100644 index 45581fc2..00000000 --- a/src/go/.env +++ /dev/null @@ -1,26 +0,0 @@ -GOCACHE= -GOLANG_DOCKERHUB_TAG=1.10-stretch -TEST_MONGODB_ADMIN_USERNAME=admin -TEST_MONGODB_ADMIN_PASSWORD=admin123456 -TEST_MONGODB_USERNAME=test -TEST_MONGODB_PASSWORD=123456 -TEST_MONGODB_S1_RS=rs1 -TEST_MONGODB_STANDALONE_PORT=27017 -TEST_MONGODB_S1_PRIMARY_PORT=17001 -TEST_MONGODB_S1_SECONDARY1_PORT=17002 -TEST_MONGODB_S1_SECONDARY2_PORT=17003 -TEST_MONGODB_S2_RS=rs2 -TEST_MONGODB_S2_PRIMARY_PORT=17004 -TEST_MONGODB_S2_SECONDARY1_PORT=17005 -TEST_MONGODB_S2_SECONDARY2_PORT=17006 -TEST_MONGODB_S3_RS=rs3 -TEST_MONGODB_S3_PRIMARY_PORT=17021 -TEST_MONGODB_S3_SECONDARY1_PORT=17022 -TEST_MONGODB_S3_SECONDARY2_PORT=17023 -TEST_MONGODB_CONFIGSVR_RS=csReplSet -TEST_MONGODB_CONFIGSVR1_PORT=17007 -TEST_MONGODB_CONFIGSVR2_PORT=17008 -TEST_MONGODB_CONFIGSVR3_PORT=17009 -TEST_MONGODB_MONGOS_PORT=17000 -TEST_PSMDB_VERSION=3.6 -TEST_MONGODB_FLAVOR=percona/percona-server-mongodb diff --git a/src/go/Makefile b/src/go/Makefile index aced27e6..b5231f2f 100644 --- a/src/go/Makefile +++ b/src/go/Makefile @@ -1,10 +1,16 @@ +help: ## Display this help message. + @echo "Please use \`make \` where is one of:" + @grep '^[a-zA-Z]' $(MAKEFILE_LIST) | \ + awk -F ':.*?## ' 'NF==2 {printf " %-26s%s\n", $$1, $$2}' + GO := go -pkgs = $(shell find . -type d -name "pt-*" -exec basename {} \;) +pkgs = $(shell find . -type d -name "pt-*" -exec basename {} \;) VERSION=$(shell git describe --abbrev=0 --tags) BUILD=$(shell date +%FT%T%z) GOVERSION=$(shell go version | cut --delimiter=" " -f3) COMMIT=$(shell git rev-list -1 HEAD) GOUTILSDIR ?= $(GOPATH)/bin +FILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*") PREFIX=$(shell pwd) TOP_DIR=$(shell git rev-parse --show-toplevel) @@ -91,7 +97,7 @@ endef env: @echo $(TEST_ENV) | tr ' ' '\n' >.env -test-cluster: env +env-up: env ## Start MongoDB docker containers cluster TEST_PSMDB_VERSION=$(TEST_PSMDB_VERSION) \ docker-compose up \ --detach \ @@ -101,40 +107,41 @@ test-cluster: env init docker/test/init-cluster-wait.sh -test-cluster-clean: env +env-down: env ## Clean-up MongoDB docker containers cluster docker-compose down -v + rm .env -linux-amd64: +linux-amd64: ## Build Mongo tools for linux-amd64 @echo "Building linux/amd64 binaries in ${BIN_DIR}" @cd ${TOP_DIR} && dep ensure @$(foreach pkg,$(pkgs),rm -f ${BIN_DIR}/$(pkg) 2> /dev/null;) @$(foreach pkg,$(pkgs),GOOS=linux GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/$(pkg) ./$(pkg);) -linux-386: +linux-386: ## Build Mongo tools for linux-386 @echo "Building linux/386 binaries in ${BIN_DIR}" @cd ${TOP_DIR} && dep ensure @$(foreach pkg,$(pkgs),rm -f ${BIN_DIR}/$(pkg) 2> /dev/null;) @$(foreach pkg,$(pkgs),GOOS=linux GOARCH=386 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/$(pkg) ./$(pkg);) -darwin-amd64: +darwin-amd64: ## Build Mongo tools for darwin-amd64 (MacOS) @echo "Building darwin/amd64 binaries in ${BIN_DIR}" @cd ${TOP_DIR} && dep ensure @$(foreach pkg,$(pkgs),rm -f ${BIN_DIR}/$(pkg) 2> /dev/null;) @$(foreach pkg,$(pkgs),GOOS=darwin GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${BIN_DIR}/$(pkg) ./$(pkg);) -style: +style: ## Check code style @echo ">> checking code style" @! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' -test: +test: ## Run tests @echo ">> running tests" @./runtests.sh -format: - @echo ">> formatting code" - @$(GO) fmt $(pkgs) +format: ## Format source code. + gofmt -w -s $(FILES) + goimports -local github.com/percona/pmm-managed -l -w $(FILES) -vet: +vet: ## Run vet on Go code @echo ">> vetting code" - @$(GO) vet $(pkgs) + @$(foreach pkg,$(pkgs), cd $(TOP_DIR)/src/go/$(pkg); go vet ./... ;) diff --git a/src/go/docker-compose.yml b/src/go/docker-compose.yml index 166127cd..528eb543 100644 --- a/src/go/docker-compose.yml +++ b/src/go/docker-compose.yml @@ -143,6 +143,30 @@ services: - configsvr1 # - configsvr2 # - configsvr3 + postgres9: + image: ${MYSQL_IMAGE:-postgres:9.6} + ports: + - ${POSTGRE_HOST:-127.0.0.1}:${POSTGRE_96_PORT:-6432}:5432 + environment: + - POSTGRES_PASSWORD=root + postgres10: + image: ${POSTGRE_IMAGE:-postgres:10.7} + ports: + - ${POSTGRE_HOST:-127.0.0.1}:${POSTGRE_10_PORT:-6433}:5432 + environment: + - POSTGRES_PASSWORD=root + postgres11: + image: ${POSTGRE_IMAGE:-postgres:11} + ports: + - ${POSTGRE_HOST:-127.0.0.1}:${POSTGRE_11_PORT:-6434}:5432 + environment: + - POSTGRES_PASSWORD=root + postgres12: + image: ${POSTGRE_IMAGE:-postgres:12} + ports: + - ${POSTGRE_HOST:-127.0.0.1}:${POSTGRE_12_PORT:-6435}:5432 + environment: + - POSTGRES_PASSWORD=root init: network_mode: host image: ${TEST_MONGODB_FLAVOR}:${TEST_PSMDB_VERSION} @@ -166,6 +190,10 @@ services: - s3-mongo2 - s3-mongo3 - standalone + - postgres9 + - postgres10 + - postgres11 + - postgres12 test: build: dockerfile: docker/test/Dockerfile diff --git a/src/go/lib/versioncheck/version_check_test.go b/src/go/lib/versioncheck/version_check_test.go index 6540fbcc..e4f0da13 100644 --- a/src/go/lib/versioncheck/version_check_test.go +++ b/src/go/lib/versioncheck/version_check_test.go @@ -18,7 +18,7 @@ func TestCheckUpdates(t *testing.T) { m := strings.Split(string(body), ";") advices := []Advice{ - Advice{ + { Hash: m[0], ToolName: m[1], Advice: "There is a new version", diff --git a/src/go/pt-pg-summary/internal/tu/tu.go b/src/go/pt-pg-summary/internal/tu/tu.go index 700cf303..ebdf67a0 100644 --- a/src/go/pt-pg-summary/internal/tu/tu.go +++ b/src/go/pt-pg-summary/internal/tu/tu.go @@ -23,10 +23,10 @@ const ( ipv6PG11Port = "6432" ipv6PG12Port = "6432" - pg9Container = "pt-pg-summary_postgres9_1" - pg10Container = "pt-pg-summary_postgres10_1" - pg11Container = "pt-pg-summary_postgres11_1" - pg12Container = "pt-pg-summary_postgres12_1" + pg9Container = "go_postgres9_1" + pg10Container = "go_postgres10_1" + pg11Container = "go_postgres11_1" + pg12Container = "go_postgres12_1" ) var ( diff --git a/src/go/runtests.sh b/src/go/runtests.sh index 22b1faec..94623262 100755 --- a/src/go/runtests.sh +++ b/src/go/runtests.sh @@ -4,7 +4,9 @@ export BASEDIR=$(git rev-parse --show-toplevel) export CHECK_SESSIONS=0 cd $BASEDIR -for dir in $(ls -d pt-*) +source ${BASEDIR}/src/go/setenv.sh + +for dir in $(ls -d ./src/go/pt-*) do echo "Running tests at $BASEDIR/$dir" cd $BASEDIR/$dir