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:
parent
3654579ea7
commit
feb3acdbe9
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -82,17 +82,10 @@ func StatusOK(statusCode int) bool {
|
|||
}
|
||||
|
||||
func waitForHeight(height int64, url string) {
|
||||
for {
|
||||
// get url, try a few times
|
||||
var res *http.Response
|
||||
var err error
|
||||
for i := 0; i < 5; i++ {
|
||||
for {
|
||||
res, err = http.Get(url)
|
||||
if err == nil && StatusOK(res.StatusCode) {
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Millisecond * 200)
|
||||
}
|
||||
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)
|
||||
|
||||
// get url, try a few times
|
||||
// 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)
|
||||
|
||||
var res *http.Response
|
||||
res, err = http.Get(url)
|
||||
if err == nil || res == nil {
|
||||
if err != nil || res == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// still haven't started up?! panic!
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: these functions just print to Stdout.
|
||||
|
|
Loading…
Reference in New Issue