Merge PR #1491: client/lcd: fix tests

* client/lcd: fix tests
* circle: drop test_unit. store artifacts in test_cover
* hack fix in TestUnrevoke
This commit is contained in:
Ethan Buchman 2018-06-30 19:32:52 -04:00 committed by Christopher Goes
parent 3654579ea7
commit feb3acdbe9
4 changed files with 27 additions and 44 deletions

View File

@ -8,6 +8,7 @@ defaults: &defaults
GOBIN: /tmp/workspace/bin
jobs:
setup_dependencies:
<<: *defaults
steps:
@ -67,21 +68,6 @@ jobs:
command: |
export PATH="$GOBIN:$PATH"
make test_lint
test_unit:
<<: *defaults
parallelism: 1
steps:
- attach_workspace:
at: /tmp/workspace
- restore_cache:
key: v1-pkg-cache
- restore_cache:
key: v1-tree-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Test unit
command: |
export PATH="$GOBIN:$PATH"
make test_unit
test_cli:
<<: *defaults
@ -109,6 +95,7 @@ jobs:
key: v1-pkg-cache
- restore_cache:
key: v1-tree-{{ .Environment.CIRCLE_SHA1 }}
- run: mkdir -p /tmp/logs
- run:
name: Run tests
command: |
@ -117,12 +104,14 @@ jobs:
for pkg in $(go list github.com/cosmos/cosmos-sdk/... | grep -v /vendor/ | grep -v github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test | circleci tests split --split-by=timings); do
id=$(basename "$pkg")
go test -timeout 8m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic "$pkg"
GOCACHE=off go test -v -timeout 8m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"
done
- persist_to_workspace:
root: /tmp/workspace
paths:
- "profiles/*"
- store_artifacts:
path: /tmp/logs
upload_coverage:
<<: *defaults
@ -156,9 +145,6 @@ workflows:
- test_cli:
requires:
- setup_dependencies
- test_unit:
requires:
- setup_dependencies
- test_cover:
requires:
- setup_dependencies

View File

@ -528,6 +528,9 @@ func TestUnrevoke(t *testing.T) {
cleanup, pks, port := InitializeTestLCD(t, 1, []sdk.Address{addr})
defer cleanup()
// XXX: any less than this and it fails
tests.WaitForHeight(3, port)
signingInfo := getSigningInfo(t, port, pks[0].Address())
tests.WaitForHeight(4, port)
require.Equal(t, true, signingInfo.IndexOffset > 0)

View File

@ -95,7 +95,7 @@ func CreateAddr(t *testing.T, name, password string, kb crkeys.Keybase) (addr sd
func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.Address) (cleanup func(), validatorsPKs []crypto.PubKey, port string) {
config := GetConfig()
config.Consensus.TimeoutCommit = 1000
config.Consensus.TimeoutCommit = 100
config.Consensus.SkipTimeoutCommit = false
config.TxIndex.IndexAllTags = true

View File

@ -82,17 +82,10 @@ func StatusOK(statusCode int) bool {
}
func waitForHeight(height int64, url string) {
var res *http.Response
var err error
for {
// get url, try a few times
var res *http.Response
var err error
for i := 0; i < 5; i++ {
res, err = http.Get(url)
if err == nil && StatusOK(res.StatusCode) {
break
}
time.Sleep(time.Millisecond * 200)
}
res, err = http.Get(url)
if err != nil {
panic(err)
}
@ -125,30 +118,31 @@ func waitForHeight(height int64, url string) {
// wait for tendermint to start
func WaitForStart(port string) {
var err error
for i := 0; i < 5; i++ {
time.Sleep(time.Second)
url := fmt.Sprintf("http://localhost:%v/blocks/latest", port)
url := fmt.Sprintf("http://localhost:%v/blocks/latest", port)
// ping the status endpoint a few times a second
// for a few seconds until we get a good response.
// otherwise something probably went wrong
for i := 0; i < 50; i++ {
time.Sleep(time.Millisecond * 100)
// get url, try a few times
var res *http.Response
res, err = http.Get(url)
if err == nil || res == nil {
if err != nil || res == nil {
continue
}
err = res.Body.Close()
if err != nil {
panic(err)
}
// waiting for server to start ...
if res.StatusCode != http.StatusOK {
err = res.Body.Close()
if err != nil {
panic(err)
}
if res.StatusCode == http.StatusOK {
// good!
return
}
}
if err != nil {
panic(err)
}
// still haven't started up?! panic!
panic(err)
}
// TODO: these functions just print to Stdout.