Browse Source

e2e: tx load to use broadcast sync instead of commit (#6347)

pull/6265/head
Callum Waters 4 years ago
committed by GitHub
parent
commit
2b8aa65e4f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 15 deletions
  1. +13
    -7
      test/e2e/runner/load.go
  2. +9
    -8
      test/e2e/tests/app_test.go

+ 13
- 7
test/e2e/runner/load.go View File

@ -14,7 +14,7 @@ import (
)
// Load generates transactions against the network until the given context is
// canceled. A multiplier of great than one can be supplied if load needs to
// canceled. A multiplier of greater than one can be supplied if load needs to
// be generated beyond a minimum amount.
func Load(ctx context.Context, testnet *e2e.Testnet, multiplier int) error {
// Since transactions are executed across all nodes in the network, we need
@ -38,9 +38,9 @@ func Load(ctx context.Context, testnet *e2e.Testnet, multiplier int) error {
logger.Info(fmt.Sprintf("Starting transaction load (%v workers)...", concurrency))
started := time.Now()
go loadGenerate(ctx, chTx)
go loadGenerate(ctx, chTx, multiplier)
for w := 0; w < concurrency*multiplier; w++ {
for w := 0; w < concurrency; w++ {
go loadProcess(ctx, testnet, chTx, chSuccess)
}
@ -66,13 +66,13 @@ func Load(ctx context.Context, testnet *e2e.Testnet, multiplier int) error {
}
// loadGenerate generates jobs until the context is canceled
func loadGenerate(ctx context.Context, chTx chan<- types.Tx) {
func loadGenerate(ctx context.Context, chTx chan<- types.Tx, multiplier int) {
for i := 0; i < math.MaxInt64; i++ {
// We keep generating the same 1000 keys over and over, with different values.
// This gives a reasonable load without putting too much data in the app.
id := i % 1000
bz := make([]byte, 2048) // 4kb hex-encoded
bz := make([]byte, 1024) // 1kb hex-encoded
_, err := rand.Read(bz)
if err != nil {
panic(fmt.Sprintf("Failed to read random bytes: %v", err))
@ -81,7 +81,7 @@ func loadGenerate(ctx context.Context, chTx chan<- types.Tx) {
select {
case chTx <- tx:
time.Sleep(10 * time.Millisecond)
time.Sleep(time.Duration(100/multiplier) * time.Millisecond)
case <-ctx.Done():
close(chTx)
@ -107,10 +107,16 @@ func loadProcess(ctx context.Context, testnet *e2e.Testnet, chTx <-chan types.Tx
continue
}
// check that the node is up
_, err = client.Health(ctx)
if err != nil {
continue
}
clients[node.Name] = client
}
if _, err = client.BroadcastTxCommit(ctx, tx); err != nil {
if _, err = client.BroadcastTxSync(ctx, tx); err != nil {
continue
}


+ 9
- 8
test/e2e/tests/app_test.go View File

@ -1,6 +1,7 @@
package e2e_test
import (
"bytes"
"fmt"
"math/rand"
"testing"
@ -81,17 +82,17 @@ func TestApp_Tx(t *testing.T) {
value := fmt.Sprintf("%x", bz)
tx := types.Tx(fmt.Sprintf("%v=%v", key, value))
resp, err := client.BroadcastTxCommit(ctx, tx)
_, err = client.BroadcastTxSync(ctx, tx)
require.NoError(t, err)
// wait for the tx to be persisted in the tx indexer
time.Sleep(500 * time.Millisecond)
hash := tx.Hash()
txResp, err := client.Tx(ctx, hash, false)
require.NoError(t, err)
assert.Equal(t, txResp.Tx, tx)
assert.Equal(t, txResp.Height, resp.Height)
waitTime := 20 * time.Second
require.Eventuallyf(t, func() bool {
txResp, err := client.Tx(ctx, hash, false)
return err == nil && bytes.Equal(txResp.Tx, tx)
}, waitTime, time.Second,
"submitted tx wasn't committed after %v", waitTime,
)
// NOTE: we don't test abci query of the light client
if node.Mode == e2e.ModeLight {


Loading…
Cancel
Save