From 2569c3dd8f2cb9703114e7044baf0718df4dd680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Matczuk?= Date: Fri, 17 Apr 2020 11:36:05 +0200 Subject: [PATCH] makefile: moved running Scylla to makefile target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Modernised Makefile - Scylla and go bench run on separate CPUs Signed-off-by: MichaƂ Matczuk --- .travis.yml | 4 +--- Makefile | 39 +++++++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 44d72fb..84a004e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,7 @@ env: - SCYLLA_VERSION=latest before_install: - - docker pull scylladb/scylla:${SCYLLA_VERSION} - - docker run --rm --name scylla -p 9042:9042 --cpus=0 -d scylladb/scylla:${SCYLLA_VERSION} - - until docker exec scylla cqlsh -e "DESCRIBE SCHEMA"; do sleep 2; done + - make run-scylla install: - make get-deps get-tools diff --git a/Makefile b/Makefile index 02c3a55..8f213d0 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,20 @@ all: check test -ifndef GOBIN -export GOBIN := $(GOPATH)/bin +ifndef SCYLLA_VERSION +SCYLLA_VERSION := latest endif -define dl_tgz - @curl -sSq -L $(2) | tar zxf - --strip 1 -C $(GOBIN) --wildcards '*/$(1)' -endef +ifndef SCYLLA_CPU +SCYLLA_CPU := 0 +endif + +ifndef GOTEST_CPU +GOTEST_CPU := 1 +endif + +ifndef GOBIN +GOBIN := $(GOPATH)/bin +endif .PHONY: fmt fmt: @@ -16,7 +24,7 @@ fmt: check: @$(GOBIN)/golangci-lint run ./... -GOTEST := go test -count=1 -cover -race -tags all +GOTEST := go test -cpu $(GOTEST_CPU) -count=1 -cover -race -tags all .PHONY: test test: @@ -27,11 +35,26 @@ test: .PHONY: bench bench: - @go test -tags all -run=XXX -bench=. -benchmem ./... + @go test -cpu $(GOTEST_CPU) -tags all -run=XXX -bench=. -benchmem ./... + +.PHONY: run-scylla +run-scylla: + @echo "==> Running test instance of Scylla $(SCYLLA_VERSION)" + @docker pull scylladb/scylla:$(SCYLLA_VERSION) + @docker run --name scylla -p 9042:9042 --cpuset-cpus=$(SCYLLA_CPU) --memory 1G --rm -d scylladb/scylla:$(SCYLLA_VERSION) + @until docker exec scylla cqlsh -e "DESCRIBE SCHEMA"; do sleep 2; done + +.PHONY: stop-scylla +stop-scylla: + @docker stop scylla .PHONY: get-deps get-deps: - go get -t ./... + @go mod download + +define dl_tgz + @curl -sSq -L $(2) | tar zxf - --strip 1 -C $(GOBIN) --wildcards '*/$(1)' +endef .PHONY: get-tools get-tools: