Skip to content

Commit

Permalink
Prepare for v1.3.0 (#170)
Browse files Browse the repository at this point in the history
* Prepare for v1.3.0

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Improve integration testing reliability and network stabilization detection

Signed-off-by: Thane Thomson <connect@thanethomson.com>

Signed-off-by: Thane Thomson <connect@thanethomson.com>
  • Loading branch information
thanethomson committed Jan 20, 2023
1 parent cc4b2f0 commit d20f54e
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 11 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,14 @@
# Changelog

## v1.3.0

*Jan 19th, 2023*

* [\#168](https://github.com/informalsystems/tm-load-test/pull/168) - Remove
dependency on Tendermint Core, following
[tendermint/tendermint\#9972](https://github.com/tendermint/tendermint/issues/9972).
Also improves integration tests.

## v1.2.0

* [\#167](https://github.com/informalsystems/tm-load-test/pull/167) -
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Expand Up @@ -8,23 +8,26 @@ require (
github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.6.1
github.com/stretchr/testify v1.8.0
golang.org/x/crypto v0.5.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.0 // indirect
golang.org/x/sys v0.4.0 // indirect
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
6 changes: 2 additions & 4 deletions pkg/loadtest/cli.go
Expand Up @@ -12,7 +12,7 @@ import (
)

// CLIVersion must be manually updated as new versions are released.
const CLIVersion = "v1.0.0"
const CLIVersion = "v1.3.0"

// cliVersionCommitID must be set through linker settings. See
// https://stackoverflow.com/a/11355611/1156132 for details.
Expand All @@ -26,9 +26,7 @@ type CLIConfig struct {
DefaultClientFactory string
}

var (
flagVerbose bool
)
var flagVerbose bool

func buildCLI(cli *CLIConfig, logger logging.Logger) *cobra.Command {
cobra.OnInitialize(func() { initLogLevel(logger) })
Expand Down
2 changes: 1 addition & 1 deletion pkg/loadtest/integration_test.go
Expand Up @@ -106,7 +106,7 @@ func testCoordinatorWorkerHappyPath(t *testing.T) {
t.Fatal(err)
}

case <-time.After(time.Duration(cfg.Time*2) * time.Second):
case <-time.After(time.Duration(cfg.Time*10) * time.Second):
t.Fatal("Timed out waiting for test to complete")
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/loadtest/loadtest.go
Expand Up @@ -10,6 +10,8 @@ import (
func ExecuteStandalone(cfg Config) error {
logger := logging.NewLogrusLogger("loadtest")

logger.Debug("Attempting standalone load test against endpoints", "endpoints", cfg.Endpoints)

// if we need to wait for the network to stabilize first
if cfg.ExpectPeers > 0 {
peers, err := waitForNetworkPeers(
Expand All @@ -26,10 +28,12 @@ func ExecuteStandalone(cfg Config) error {
return err
}
cfg.Endpoints = peers
logger.Debug("Updated list of endpoints for test", "endpoints", cfg.Endpoints)
}

logger.Info("Connecting to remote endpoints")
tg := NewTransactorGroup()
tg.SetLogger(logger)
if err := tg.AddAll(&cfg); err != nil {
return err
}
Expand Down
98 changes: 98 additions & 0 deletions pkg/loadtest/rpc_test.go
@@ -0,0 +1,98 @@
package loadtest_test

import (
"encoding/json"
"testing"

"github.com/informalsystems/tm-load-test/pkg/loadtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestNetInfoDeserialization(t *testing.T) {
tc := `{
"id": 0,
"jsonrpc": "2.0",
"result": {
"listening": true,
"listeners": [
"Listener(@)"
],
"n_peers": "1",
"peers": [
{
"node_info": {
"protocol_version": {
"p2p": "7",
"block": "10",
"app": "0"
},
"id": "5576458aef205977e18fd50b274e9b5d9014525a",
"listen_addr": "tcp:0.0.0.0:26656",
"network": "cosmoshub-2",
"version": "0.32.1",
"channels": "4020212223303800",
"moniker": "moniker-node",
"other": {
"tx_index": "on",
"rpc_address": "tcp:0.0.0.0:26657"
}
},
"is_outbound": true,
"connection_status": {
"Duration": "168901057956119",
"SendMonitor": {
"Active": true,
"Start": "2019-07-31T14:31:28.66Z",
"Duration": "168901060000000",
"Idle": "168901040000000",
"Bytes": "5",
"Samples": "1",
"InstRate": "0",
"CurRate": "0",
"AvgRate": "0",
"PeakRate": "0",
"BytesRem": "0",
"TimeRem": "0",
"Progress": 0
},
"RecvMonitor": {
"Active": true,
"Start": "2019-07-31T14:31:28.66Z",
"Duration": "168901060000000",
"Idle": "168901040000000",
"Bytes": "5",
"Samples": "1",
"InstRate": "0",
"CurRate": "0",
"AvgRate": "0",
"PeakRate": "0",
"BytesRem": "0",
"TimeRem": "0",
"Progress": 0
},
"Channels": [
{
"ID": 48,
"SendQueueCapacity": "1",
"SendQueueSize": "0",
"Priority": "5",
"RecentlySent": "0"
}
]
},
"remote_ip": "95.179.155.35"
}
]
}
}`
res := &loadtest.RPCResponse{}
err := json.Unmarshal([]byte(tc), res)
require.NoError(t, err)

netInfo := &loadtest.NetInfo{}
err = json.Unmarshal(res.Result, netInfo)
require.NoError(t, err)
assert.Equal(t, 1, int(netInfo.NPeers))
assert.Len(t, netInfo.Peers, 1)
}
17 changes: 12 additions & 5 deletions pkg/loadtest/tm_network_info.go
Expand Up @@ -95,7 +95,7 @@ func waitForNetworkPeers(
if peerCount >= minDiscoveredPeers && peerConnectivity >= minPeerConnectivity {
logger.Info("All required peers connected", "count", peerCount, "minConnectivity", minPeerConnectivity)
// we're done here
return filterPeerMap(suppliedPeers, peers, selectionMethod, maxReturnedPeers), nil
return filterPeerMap(suppliedPeers, peers, selectionMethod, maxReturnedPeers, logger)
} else {
logger.Debug(
"Peers discovered so far",
Expand Down Expand Up @@ -191,12 +191,19 @@ func resolvePeerMap(peers map[string]*peerInfo) map[string]*peerInfo {
return result
}

func filterPeerMap(suppliedPeers, newPeers map[string]*peerInfo, selectionMethod string, maxCount int) []string {
func filterPeerMap(suppliedPeers, newPeers map[string]*peerInfo, selectionMethod string, maxCount int, logger logging.Logger) ([]string, error) {
logger.Debug(
"Filtering peer map",
"suppliedPeers", suppliedPeers,
"newPeers", newPeers,
"selectionMethod", selectionMethod,
"maxCount", maxCount,
)
result := make([]string, 0)
for peerAddr := range newPeers {
u, err := url.Parse(peerAddr)
if err != nil {
continue
return nil, err
}
addr := fmt.Sprintf("ws://%s:26657/websocket", u.Hostname())
switch selectionMethod {
Expand All @@ -214,11 +221,11 @@ func filterPeerMap(suppliedPeers, newPeers map[string]*peerInfo, selectionMethod
// otherwise, always add it
result = append(result, addr)
}
if len(result) >= maxCount {
if maxCount > 0 && len(result) >= maxCount {
break
}
}
return result
return result, nil
}

func getMinPeerConnectivity(peers map[string]*peerInfo) int {
Expand Down
10 changes: 10 additions & 0 deletions pkg/loadtest/transactor_group.go
Expand Up @@ -3,6 +3,8 @@ package loadtest
import (
"sync"
"time"

"github.com/informalsystems/tm-load-test/internal/logging"
)

// TransactorGroup allows us to encapsulate the management of a group of
Expand All @@ -21,6 +23,8 @@ type TransactorGroup struct {

stopProgressReporter chan struct{} // Close this to stop the progress reporter.
progressReporterStopped chan struct{} // Closed when the progress reporter goroutine has completely stopped.

logger logging.Logger
}

func NewTransactorGroup() *TransactorGroup {
Expand All @@ -31,9 +35,14 @@ func NewTransactorGroup() *TransactorGroup {
progressCallbackInterval: defaultProgressCallbackInterval,
stopProgressReporter: make(chan struct{}, 1),
progressReporterStopped: make(chan struct{}, 1),
logger: logging.NewNoopLogger(),
}
}

func (g *TransactorGroup) SetLogger(logger logging.Logger) {
g.logger = logger
}

// Add will instantiate a new Transactor with the given parameters. If
// instantiation fails it'll automatically shut down and close all other
// transactors, returning the error.
Expand All @@ -46,6 +55,7 @@ func (g *TransactorGroup) Add(remoteAddr string, config *Config) error {
id := len(g.transactors)
t.SetProgressCallback(id, g.getProgressCallbackInterval()/2, g.trackTransactorProgress)
g.transactors = append(g.transactors, t)
g.logger.Debug("Added transactor", "remoteAddr", remoteAddr)
return nil
}

Expand Down

0 comments on commit d20f54e

Please sign in to comment.