Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Network Testing Framework #6489

Merged
merged 39 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c9d5b34
Init commit
alexanderbez Jun 23, 2020
1e651e8
Remove script
alexanderbez Jun 23, 2020
9d8494f
Merge branch 'master' into bez/in-process-test-framework
alexanderbez Jun 23, 2020
cd2ec2d
Fix IBC codec bug
alexanderbez Jun 23, 2020
ecfa3c8
go mod tidy + codec fixes attempt
alexanderbez Jun 23, 2020
c7e9b60
Change base dir to use chain-id
alexanderbez Jun 23, 2020
f5deb8d
Add trap signal call
alexanderbez Jun 23, 2020
7f51e12
Add godoc
alexanderbez Jun 23, 2020
b7c2cca
Merge branch 'master' into bez/in-process-test-framework
alexanderbez Jun 23, 2020
ec88212
Updates
alexanderbez Jun 23, 2020
4f43424
Tweaks
alexanderbez Jun 23, 2020
e8f5176
Fix fn name
alexanderbez Jun 23, 2020
433b67e
Cleanup
alexanderbez Jun 23, 2020
f7758f7
Only allow 1st val to serve rpc/api
alexanderbez Jun 24, 2020
4bc56bd
use pkg lock
alexanderbez Jun 24, 2020
d430884
Merge branch 'master' into bez/in-process-test-framework
alexanderbez Jun 24, 2020
c389c81
lint++
alexanderbez Jun 24, 2020
a6f8fe3
lint++
alexanderbez Jun 24, 2020
9442a8b
Remove use of errgroup
alexanderbez Jun 24, 2020
0aff4e4
ci: remove -race flag from tests
alexanderbez Jun 24, 2020
69603bc
Merge branch 'master' into bez/in-process-test-framework
alexanderbez Jun 24, 2020
6d1719f
Add doc
alexanderbez Jun 25, 2020
c53831d
Merge branch 'master' into bez/in-process-test-framework
alexanderbez Jun 25, 2020
ff14f0d
Merge branch 'master' into bez/in-process-test-framework
fedekunze Jun 25, 2020
93454e5
cl++
alexanderbez Jun 25, 2020
52aa585
Add section to godoc
alexanderbez Jun 25, 2020
f889a0b
testutil: address comments
alexanderbez Jun 25, 2020
cdc9db6
Update testutil/doc.go
alexanderbez Jun 25, 2020
8aa5c71
Update testutil/doc.go
alexanderbez Jun 25, 2020
426505e
Update testutil/doc.go
alexanderbez Jun 25, 2020
c6a208a
testutil: make app confiruable
alexanderbez Jun 26, 2020
05fd4a7
testutil: update go doc
alexanderbez Jun 26, 2020
38aac75
Merge branch 'bez/in-process-test-framework' of github.com:cosmos/cos…
alexanderbez Jun 26, 2020
195447e
testutil: revise app con
alexanderbez Jun 26, 2020
939b6c3
testutil: update go doc
alexanderbez Jun 26, 2020
9c77941
Fixes
alexanderbez Jun 26, 2020
89a447d
Merge branch 'master' into bez/in-process-test-framework
alexanderbez Jun 26, 2020
df0b1b6
Merge branch 'master' into bez/in-process-test-framework
mergify[bot] Jun 26, 2020
ddb342b
Merge branch 'master' into bez/in-process-test-framework
mergify[bot] Jun 26, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,27 +213,3 @@ jobs:
run: |
make test-integration
if: "env.GIT_DIFF != ''"

liveness-test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v1
id: git_diff
with:
SUFFIX_FILTER: |
.go
.mod
.sum
- name: build image
run: |
make build-docker-local-simapp
- name: start localnet
run: |
make clean build-sim-linux localnet-start
if: "env.GIT_DIFF != ''"
- name: test liveness
run: |
./contrib/localnet_liveness.sh 100 5 50 localhost
if: "env.GIT_DIFF != ''"
55 changes: 0 additions & 55 deletions contrib/localnet_liveness.sh

This file was deleted.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ require (
github.com/tendermint/iavl v0.13.4-0.20200622140716-a41a83e2415f
github.com/tendermint/tendermint v0.33.5
github.com/tendermint/tm-db v0.5.1
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
google.golang.org/grpc v1.29.1
gopkg.in/yaml.v2 v2.3.0
)
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
12 changes: 8 additions & 4 deletions server/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"net"
"net/http"
"os"
"strings"
"time"

Expand Down Expand Up @@ -33,11 +32,11 @@ type Server struct {
listener net.Listener
}

func New(clientCtx client.Context) *Server {
func New(clientCtx client.Context, logger log.Logger) *Server {
return &Server{
Router: mux.NewRouter(),
ClientCtx: clientCtx,
logger: log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "api-server"),
logger: logger,
}
}

Expand All @@ -60,13 +59,18 @@ func (s *Server) Start(cfg config.Config) error {
s.registerMetrics()
}

addr := cfg.API.Address
if !strings.Contains(addr, "tcp://") {
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
addr = "tcp://" + addr
}

tmCfg := tmrpcserver.DefaultConfig()
tmCfg.MaxOpenConnections = int(cfg.API.MaxOpenConnections)
tmCfg.ReadTimeout = time.Duration(cfg.API.RPCReadTimeout) * time.Second
tmCfg.WriteTimeout = time.Duration(cfg.API.RPCWriteTimeout) * time.Second
tmCfg.MaxBodyBytes = int64(cfg.API.RPCMaxBodyBytes)

listener, err := tmrpcserver.Listen(cfg.API.Address, tmCfg)
listener, err := tmrpcserver.Listen(addr, tmCfg)
if err != nil {
return err
}
Expand Down
20 changes: 16 additions & 4 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"runtime/pprof"
"time"

"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -199,8 +200,9 @@ func startInProcess(ctx *Context, cdc codec.JSONMarshaler, appCreator AppCreator
return err
}

config := config.GetConfig()
var apiSrv *api.Server

config := config.GetConfig()
if config.API.Enable {
genDoc, err := genDocProvider()
if err != nil {
Expand All @@ -210,18 +212,28 @@ func startInProcess(ctx *Context, cdc codec.JSONMarshaler, appCreator AppCreator
// TODO: Since this is running in process, do we need to provide a verifier
// and set TrustNode=false? If so, we need to add additional logic that
// waits for a block to be committed first before starting the API server.
ctx := client.Context{}.
clientCtx := client.Context{}.
WithHomeDir(home).
WithChainID(genDoc.ChainID).
WithJSONMarshaler(cdc).
WithClient(local.New(tmNode)).
WithTrustNode(true)

apiSrv = api.New(ctx)
apiSrv = api.New(clientCtx, ctx.Logger.With("module", "api-server"))
app.RegisterAPIRoutes(apiSrv)

if err := apiSrv.Start(config); err != nil {
errCh := make(chan error)

go func() {
if err := apiSrv.Start(config); err != nil {
errCh <- err
}
}()

select {
case err := <-errCh:
return err
case <-time.After(5 * time.Second): // assume server started successfully
Comment on lines -223 to +236
Copy link
Contributor Author

@alexanderbez alexanderbez Jun 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not realize Tendermint HTTP client actually blocks -- this fixes that so we can properly cleanup below.

}
}

Expand Down
Loading