8000 feat(e2e): Log number of sent txs (success and failed) by hvanz · Pull Request #2328 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(e2e): Log number of sent txs (success and failed) #2328

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

Merged
merged 5 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/2328-e2e-log-sent-txs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[e2e]` Log the number of transactions that were sent successfully or failed.
([\#2328](https://github.com/cometbft/cometbft/pull/2328))
35 changes: 24 additions & 11 deletions test/e2e/runner/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func Load(ctx context.Context, testnet *e2e.Testnet) error {
initialTimeout := 1 * time.Minute
stallTimeout := 30 * time.Second
chSuccess := make(chan struct{})
chFailed := make(chan struct{})
ctx, cancel := context.WithCancel(ctx)
defer cancel()

Expand All @@ -40,31 +41,41 @@ func Load(ctx context.Context, testnet *e2e.Testnet) error {
}

for w := 0; w < testnet.LoadTxConnections; w++ {
go loadProcess(ctx, txCh, chSuccess, n)
go loadProcess(ctx, txCh, chSuccess, chFailed, n)
}
}

// Monitor successful transactions, and abort on stalls.
success := 0
// Monitor successful and failed transactions, and abort on stalls.
success, failed := 0, 0
timeout := initialTimeout
for {
rate := log.NewLazySprintf("%.1f", float64(success)/time.Since(started).Seconds())

select {
case <-chSuccess:
success++
if testnet.LoadMaxTxs > 0 && success >= testnet.LoadMaxTxs {
logger.Info("load", "msg", log.NewLazySprintf("Ending transaction load after reaching %v txs (%.1f tx/s)...",
success, float64(success)/time.Since(started).Seconds()))
return nil
}
timeout = stallTimeout
case <-chFailed:
failed++
case <-time.After(timeout):
return fmt.Errorf("unable to submit transactions for %v", timeout)
case <-ctx.Done():
if success == 0 {
return errors.New("failed to submit any transactions")
}
logger.Info("load", "msg", log.NewLazySprintf("Ending transaction load after %v txs (%.1f tx/s)...",
success, float64(success)/time.Since(started).Seconds()))
logger.Info("load", "msg", log.NewLazySprintf("Ending transaction load after %v txs (%v tx/s)...", success, rate))
return nil
}

// Log every ~1 second the number of sent transactions.
total := success + failed
if total%testnet.LoadTxBatchSize == 0 {
logger.Debug("load", "success", success, "failed", failed, "success/total", log.NewLazySprintf("%.1f", success/total), "tx/s", rate)
}

// Check if reached max number of allowed transactions to send.
if testnet.LoadMaxTxs > 0 && success >= testnet.LoadMaxTxs {
logger.Info("load", "msg", log.NewLazySprintf("Ending transaction load after reaching %v txs (%v tx/s)...", success, rate))
return nil
}
}
Expand Down Expand Up @@ -135,7 +146,7 @@ func createTxBatch(ctx context.Context, txCh chan<- types.Tx, testnet *e2e.Testn

// loadProcess processes transactions by sending transactions received on the txCh
// to the client.
func loadProcess(ctx context.Context, txCh <-chan types.Tx, chSuccess chan<- struct{}, n *e2e.Node) {
func loadProcess(ctx context.Context, txCh <-chan types.Tx, chSuccess chan<- struct{}, chFailed chan<- struct{}, n *e2e.Node) {
var client *rpchttp.HTTP
var err error
s := struct{}{}
Expand All @@ -148,6 +159,8 @@ func loadProcess(ctx context.Context, txCh <-chan types.Tx, chSuccess chan<- str
}
}
if _, err = client.BroadcastTxSync(ctx, tx); err != nil {
logger.Error("failed to send transaction", "err", err)
chFailed <- s
continue
}
chSuccess <- s
Expand Down
0