From c1d6ffa12a0eb0b2b0f4f49c52b0f9535fc5af9f Mon Sep 17 00:00:00 2001 From: Ibrahim Jarif Date: Wed, 15 Jan 2020 15:10:34 +0530 Subject: [PATCH] Run all tests on CI (#1189) This could possibly be a bug in `go test` command https://github.com/golang/go/issues/36527 . The `go test` command would skip tests in sub-packages if the top-level package has a `custom flag` defined and the sub-packages don't define it. Issue https://github.com/golang/go/issues/36527#issue-548887632 has an example of this. This PR also removes the code from the test that would unnecessary start a web server. I see two problems here 1. An unnecessary web server running. 2. We cannot run multiple tests are the same time since the second run of the test would try to start a web server and crash saying `port already in use`. (cherry picked from commit 5870b7b1975e031549f8a3d4309335f6b03f0fa4) --- db_test.go | 8 +------- test.sh | 31 ++++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/db_test.go b/db_test.go index f6185e44c..56c95de98 100644 --- a/db_test.go +++ b/db_test.go @@ -26,7 +26,6 @@ import ( "log" "math" "math/rand" - "net/http" "os" "path/filepath" "runtime" @@ -1957,12 +1956,7 @@ func TestVerifyChecksum(t *testing.T) { } func TestMain(m *testing.M) { - // call flag.Parse() here if TestMain uses flags - go func() { - if err := http.ListenAndServe("localhost:8080", nil); err != nil { - panic("Unable to open http port at 8080") - } - }() + flag.Parse() os.Exit(m.Run()) } diff --git a/test.sh b/test.sh index 90d21889c..b4e40601a 100755 --- a/test.sh +++ b/test.sh @@ -4,30 +4,43 @@ set -e go version +packages=$(go list ./... | grep github.com/dgraph-io/badger/v2/) + +if [[ ! -z "$TEAMCITY_VERSION" ]]; then + export GOFLAGS="-json" +fi + # Ensure that we can compile the binary. pushd badger go build -v . popd # Run the memory intensive tests first. -go test -v --manual=true -run='TestBigKeyValuePairs$' -go test -v --manual=true -run='TestPushValueLogLimit' +go test -v -run='TestBigKeyValuePairs$' --manual=true +go test -v -run='TestPushValueLogLimit' --manual=true # Run the special Truncate test. rm -rf p -go test -v --manual=true -run='TestTruncateVlogNoClose$' . +go test -v -run='TestTruncateVlogNoClose$' --manual=true truncate --size=4096 p/000000.vlog -go test -v --manual=true -run='TestTruncateVlogNoClose2$' . -go test -v --manual=true -run='TestTruncateVlogNoClose3$' . +go test -v -run='TestTruncateVlogNoClose2$' --manual=true +go test -v -run='TestTruncateVlogNoClose3$' --manual=true rm -rf p # Then the normal tests. +echo +echo "==> Starting test for table, skl and y package" +go test -v -race github.com/dgraph-io/badger/v2/skl +# Run test for all package except the top level package. The top level package support the +# `vlog_mmap` flag which rest of the packages don't support. +go test -v -race $packages + echo echo "==> Starting tests with value log mmapped..." -sleep 5 -go test -v --vlog_mmap=true -race ./... +# Run top level package tests with mmap flag. +go test -v -race github.com/dgraph-io/badger/v2 --vlog_mmap=true echo echo "==> Starting tests with value log not mmapped..." -sleep 5 -go test -v --vlog_mmap=false -race ./... +go test -v -race github.com/dgraph-io/badger/v2 --vlog_mmap=false +