Skip to content

Commit

Permalink
Merge PR #1291: Delete unused tests
Browse files Browse the repository at this point in the history
* Tweak retry logic on waitForHeight
* Add HTTP retry logic to LCD tests
* Simplify waitForHeight changes
* Update changelog
* Add 'make test_cli_retry', 'make test_unit_retry'
* Run test_cli_retry in CI
* Delete unused tests
  • Loading branch information
ValarDragon authored and cwgoes committed Jun 19, 2018
1 parent 0a26aa0 commit 0292a3b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 323 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
name: Test cli
command: |
export PATH="$GOBIN:$PATH"
make test_cli
make test_cli_retry
test_cover:
<<: *defaults
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ BREAKING CHANGES

FIXES
* \#1259 - fix bug where certain tests that could have a nil pointer in defer
* Retry on HTTP request failure in CLI tests, add option to retry tests in Makefile

## 0.19.0

Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,15 @@ test: test_unit
test_cli:
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test`

test_cli_retry:
for i in 1 2 3; do make test_cli && break || sleep 2; done

test_unit:
@go test $(PACKAGES_NOCLITEST)

test_unit_retry:
for i in 1 2 3; do make test_unit && break || sleep 2; done

test_race:
@go test -race $(PACKAGES_NOCLITEST)

Expand Down
321 changes: 0 additions & 321 deletions tests/tests.go

This file was deleted.

13 changes: 12 additions & 1 deletion tests/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,25 @@ func WaitForHeight(height int64, port string) {
waitForHeight(height, url)
}

// Whether or not an HTTP status code was "successful"
func StatusOK(statusCode int) bool {
switch statusCode {
case http.StatusOK:
case http.StatusCreated:
case http.StatusNoContent:
return true
}
return false
}

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++ {
res, err = http.Get(url)
if err == nil {
if err == nil && StatusOK(res.StatusCode) {
break
}
time.Sleep(time.Millisecond * 200)
Expand Down

0 comments on commit 0292a3b

Please sign in to comment.