Skip to content

Commit 97f4385

Browse files
author
Ibrahim Jarif
committed
Run all tests on CI (#1189)
This could possibly be a bug in `go test` command golang/go#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 golang/go#36527 (comment) 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 5870b7b)
1 parent 5a48ef2 commit 97f4385

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

db_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"log"
2727
"math"
2828
"math/rand"
29-
"net/http"
3029
"os"
3130
"path/filepath"
3231
"runtime"
@@ -1957,12 +1956,7 @@ func TestVerifyChecksum(t *testing.T) {
19571956
}
19581957

19591958
func TestMain(m *testing.M) {
1960-
// call flag.Parse() here if TestMain uses flags
1961-
go func() {
1962-
if err := http.ListenAndServe("localhost:8080", nil); err != nil {
1963-
panic("Unable to open http port at 8080")
1964-
}
1965-
}()
1959+
flag.Parse()
19661960
os.Exit(m.Run())
19671961
}
19681962

test.sh

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,43 @@ set -e
44

55
go version
66

7+
packages=$(go list ./... | grep github.com/dgraph-io/badger/v2/)
8+
9+
if [[ ! -z "$TEAMCITY_VERSION" ]]; then
10+
export GOFLAGS="-json"
11+
fi
12+
713
# Ensure that we can compile the binary.
814
pushd badger
915
go build -v .
1016
popd
1117

1218
# Run the memory intensive tests first.
13-
go test -v --manual=true -run='TestBigKeyValuePairs$'
14-
go test -v --manual=true -run='TestPushValueLogLimit'
19+
go test -v -run='TestBigKeyValuePairs$' --manual=true
20+
go test -v -run='TestPushValueLogLimit' --manual=true
1521

1622
# Run the special Truncate test.
1723
rm -rf p
18-
go test -v --manual=true -run='TestTruncateVlogNoClose$' .
24+
go test -v -run='TestTruncateVlogNoClose$' --manual=true
1925
truncate --size=4096 p/000000.vlog
20-
go test -v --manual=true -run='TestTruncateVlogNoClose2$' .
21-
go test -v --manual=true -run='TestTruncateVlogNoClose3$' .
26+
go test -v -run='TestTruncateVlogNoClose2$' --manual=true
27+
go test -v -run='TestTruncateVlogNoClose3$' --manual=true
2228
rm -rf p
2329

2430
# Then the normal tests.
31+
echo
32+
echo "==> Starting test for table, skl and y package"
33+
go test -v -race github.com/dgraph-io/badger/v2/skl
34+
# Run test for all package except the top level package. The top level package support the
35+
# `vlog_mmap` flag which rest of the packages don't support.
36+
go test -v -race $packages
37+
2538
echo
2639
echo "==> Starting tests with value log mmapped..."
27-
sleep 5
28-
go test -v --vlog_mmap=true -race ./...
40+
# Run top level package tests with mmap flag.
41+
go test -v -race github.com/dgraph-io/badger/v2 --vlog_mmap=true
2942

3043
echo
3144
echo "==> Starting tests with value log not mmapped..."
32-
sleep 5
33-
go test -v --vlog_mmap=false -race ./...
45+
go test -v -race github.com/dgraph-io/badger/v2 --vlog_mmap=false
46+

0 commit comments

Comments
 (0)