diff --git a/Makefile b/Makefile index 2d90f39b5..2144cdbf4 100644 --- a/Makefile +++ b/Makefile @@ -3,18 +3,20 @@ THIS_FILE := $(lastword $(MAKEFILE_LIST)) TEST?=$$(go list ./... | grep -v /vendor/ | grep -v /integ) -TEST_TIMEOUT?=30m -EXTENDED_TEST_TIMEOUT=45m +TEST_TIMEOUT?=45m +EXTENDED_TEST_TIMEOUT=60m +INTEG_TEST_TIMEOUT=120m VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr EXTERNAL_TOOLS=\ github.com/elazarl/go-bindata-assetfs/... \ github.com/hashicorp/go-bindata/... \ github.com/mitchellh/gox \ github.com/kardianos/govendor \ - github.com/client9/misspell/cmd/misspell + github.com/client9/misspell/cmd/misspell \ + github.com/golangci/golangci-lint/cmd/golangci-lint GOFMT_FILES?=$$(find . -name '*.go' | grep -v pb.go | grep -v vendor) -GO_VERSION_MIN=1.11 +GO_VERSION_MIN=1.12.4 CGO_ENABLED?=0 ifneq ($(FDB_ENABLED), ) CGO_ENABLED=1 @@ -97,6 +99,18 @@ vet: echo "and fix them if necessary before submitting the code for reviewal."; \ fi +# lint runs vet plus a number of other checkers, it is more comprehensive, but louder +lint: + @go list -f '{{.Dir}}' ./... | grep -v /vendor/ \ + | xargs golangci-lint run; if [ $$? -eq 1 ]; then \ + echo ""; \ + echo "Lint found suspicious constructs. Please check the reported constructs"; \ + echo "and fix them if necessary before submitting the code for reviewal."; \ + fi +# for ci jobs, runs lint against the changed packages in the commit +ci-lint: + @golangci-lint run --deadline 10m --new-from-rev=HEAD~ + # prep runs `go generate` to build the dynamically generated # source files. prep: fmtcheck @@ -117,7 +131,7 @@ ci-verify: bootstrap: @for tool in $(EXTERNAL_TOOLS) ; do \ echo "Installing/Updating $$tool" ; \ - go get -u $$tool; \ + GO111MODULE=off go get -u $$tool; \ done # Note: if you have plugins in GOPATH you can update all of them via something like: diff --git a/helper/testhelpers/testhelpers.go b/helper/testhelpers/testhelpers.go index 2f63614f1..c11728fc8 100644 --- a/helper/testhelpers/testhelpers.go +++ b/helper/testhelpers/testhelpers.go @@ -657,6 +657,26 @@ func WaitForMatchingMerkleRoots(t testing.T, endpoint string, primary, secondary t.Fatalf("roots did not become equal") } +func WaitForMatchingMerkleRootsCore(t testing.T, pri, sec *vault.TestClusterCore, dr bool) { + rootFunc := vault.PerformanceMerkleRoot + if dr { + rootFunc = vault.DRMerkleRoot + } + + t.Helper() + for i := 0; i < 30; i++ { + secRoot := rootFunc(pri.Core) + priRoot := rootFunc(pri.Core) + + if reflect.DeepEqual(priRoot, secRoot) { + return + } + time.Sleep(time.Second) + } + + t.Fatalf("roots did not become equal") +} + func WaitForWAL(t testing.T, c *vault.TestClusterCore, wal uint64) { timeout := time.Now().Add(3 * time.Second) for { diff --git a/vault/core.go b/vault/core.go index cc5295edf..7f8cf76e7 100644 --- a/vault/core.go +++ b/vault/core.go @@ -93,13 +93,16 @@ var ( manualStepDownSleepPeriod = 10 * time.Second // Functions only in the Enterprise version - enterprisePostUnseal = enterprisePostUnsealImpl - enterprisePreSeal = enterprisePreSealImpl - startReplication = startReplicationImpl - stopReplication = stopReplicationImpl - LastWAL = lastWALImpl - LastRemoteWAL = lastRemoteWALImpl - WaitUntilWALShipped = waitUntilWALShippedImpl + enterprisePostUnseal = enterprisePostUnsealImpl + enterprisePreSeal = enterprisePreSealImpl + startReplication = startReplicationImpl + stopReplication = stopReplicationImpl + LastWAL = lastWALImpl + LastPerformanceWAL = lastPerformanceWALImpl + PerformanceMerkleRoot = merkleRootImpl + DRMerkleRoot = merkleRootImpl + LastRemoteWAL = lastRemoteWALImpl + WaitUntilWALShipped = waitUntilWALShippedImpl ) // NonFatalError is an error that can be returned during NewCore that should be @@ -1832,10 +1835,18 @@ func waitUntilWALShippedImpl(ctx context.Context, c *Core, index uint64) bool { return true } +func merkleRootImpl(c *Core) string { + return "" +} + func lastWALImpl(c *Core) uint64 { return 0 } +func lastPerformanceWALImpl(c *Core) uint64 { + return 0 +} + func lastRemoteWALImpl(c *Core) uint64 { return 0 }