Merge PR #2124: Simple integration tests for {base,demo}coind

This commit is contained in:
Christopher Goes 2018-08-23 13:56:32 +02:00 committed by GitHub
commit f8f97f7bd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 112 additions and 2 deletions

View File

@ -63,7 +63,7 @@ jobs:
export PATH="$GOBIN:$PATH"
make test_lint
test_cli:
integration_tests:
<<: *defaults
parallelism: 1
steps:
@ -80,6 +80,7 @@ jobs:
command: |
export PATH="$GOBIN:$PATH"
make test_cli
make test_examples
test_sim_modules:
<<: *defaults
@ -220,7 +221,7 @@ workflows:
- lint:
requires:
- setup_dependencies
- test_cli:
- integration_tests:
requires:
- setup_dependencies
- test_sim_modules:

View File

@ -132,6 +132,10 @@ test: test_unit
test_cli:
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test` -tags=cli_test
test_examples:
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/examples/basecoin/cli_test` -tags=cli_test
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/examples/democoin/cli_test` -tags=cli_test
test_unit:
@go test $(PACKAGES_NOSIMULATION)

View File

@ -57,6 +57,7 @@ IMPROVEMENTS
* SDK
* [tools] Make get_vendor_deps deletes `.vendor-new` directories, in case scratch files are present.
* [cli] \#1632 Add integration tests to ensure `basecoind init && basecoind` start sequences run successfully for both `democoin` and `basecoin` examples.
* Tendermint

View File

@ -0,0 +1,52 @@
package clitest
import (
"encoding/json"
"fmt"
"os"
"testing"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/tests"
"github.com/stretchr/testify/require"
)
var (
basecoindHome = ""
)
func init() {
basecoindHome = getTestingHomeDir()
}
func TestInitStartSequence(t *testing.T) {
os.RemoveAll(basecoindHome)
servAddr, port, err := server.FreeTCPAddr()
require.NoError(t, err)
executeInit(t)
executeStart(t, servAddr, port)
}
func executeInit(t *testing.T) {
var (
chainID string
initRes map[string]json.RawMessage
)
out := tests.ExecuteT(t, fmt.Sprintf("basecoind --home=%s init", basecoindHome), "")
err := json.Unmarshal([]byte(out), &initRes)
require.NoError(t, err)
err = json.Unmarshal(initRes["chain_id"], &chainID)
require.NoError(t, err)
}
func executeStart(t *testing.T, servAddr, port string) {
proc := tests.GoExecuteTWithStdout(t, fmt.Sprintf("basecoind start --home=%s --rpc.laddr=%v", basecoindHome, servAddr))
defer proc.Stop(false)
tests.WaitForTMStart(port)
}
func getTestingHomeDir() string {
tmpDir := os.TempDir()
basecoindHome := fmt.Sprintf("%s%s.test_basecoind", tmpDir, string(os.PathSeparator))
return basecoindHome
}

View File

@ -0,0 +1,52 @@
package clitest
import (
"encoding/json"
"fmt"
"os"
"testing"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/tests"
"github.com/stretchr/testify/require"
)
var (
democoindHome = ""
)
func init() {
democoindHome = getTestingHomeDir()
}
func TestInitStartSequence(t *testing.T) {
os.RemoveAll(democoindHome)
servAddr, port, err := server.FreeTCPAddr()
require.NoError(t, err)
executeInit(t)
executeStart(t, servAddr, port)
}
func executeInit(t *testing.T) {
var (
chainID string
initRes map[string]json.RawMessage
)
out := tests.ExecuteT(t, fmt.Sprintf("democoind --home=%s init", democoindHome), "")
err := json.Unmarshal([]byte(out), &initRes)
require.NoError(t, err)
err = json.Unmarshal(initRes["chain_id"], &chainID)
require.NoError(t, err)
}
func executeStart(t *testing.T, servAddr, port string) {
proc := tests.GoExecuteTWithStdout(t, fmt.Sprintf("democoind start --home=%s --rpc.laddr=%v", democoindHome, servAddr))
defer proc.Stop(false)
tests.WaitForTMStart(port)
}
func getTestingHomeDir() string {
tmpDir := os.TempDir()
democoindHome := fmt.Sprintf("%s%s.test_democoind", tmpDir, string(os.PathSeparator))
return democoindHome
}