mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-31 17:12:05 +00:00
Compare commits
1 Commits
wb/simul-q
...
e2e-avoid-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b87431cef7 |
@@ -417,16 +417,6 @@ func (t Testnet) ArchiveNodes() []*Node {
|
|||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
// RandomNode returns a random non-seed node.
|
|
||||||
func (t Testnet) RandomNode() *Node {
|
|
||||||
for {
|
|
||||||
node := t.Nodes[rand.Intn(len(t.Nodes))]
|
|
||||||
if node.Mode != ModeSeed {
|
|
||||||
return node
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// IPv6 returns true if the testnet is an IPv6 network.
|
// IPv6 returns true if the testnet is an IPv6 network.
|
||||||
func (t Testnet) IPv6() bool {
|
func (t Testnet) IPv6() bool {
|
||||||
return t.IP.IP.To4() == nil
|
return t.IP.IP.To4() == nil
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"container/ring"
|
||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"errors"
|
"errors"
|
||||||
@@ -95,32 +96,56 @@ func loadGenerate(ctx context.Context, chTx chan<- types.Tx, multiplier int, siz
|
|||||||
func loadProcess(ctx context.Context, testnet *e2e.Testnet, chTx <-chan types.Tx, chSuccess chan<- types.Tx) {
|
func loadProcess(ctx context.Context, testnet *e2e.Testnet, chTx <-chan types.Tx, chSuccess chan<- types.Tx) {
|
||||||
// Each worker gets its own client to each node, which allows for some
|
// Each worker gets its own client to each node, which allows for some
|
||||||
// concurrency while still bounding it.
|
// concurrency while still bounding it.
|
||||||
clients := map[string]*rpchttp.HTTP{}
|
|
||||||
|
|
||||||
var err error
|
clients := make([]*rpchttp.HTTP, 0, len(testnet.Nodes))
|
||||||
for tx := range chTx {
|
|
||||||
node := testnet.RandomNode()
|
|
||||||
|
|
||||||
client, ok := clients[node.Name]
|
for idx := range testnet.Nodes {
|
||||||
if !ok {
|
if testnet.Nodes[idx].Mode == e2e.ModeSeed {
|
||||||
client, err = node.Client()
|
continue
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// check that the node is up
|
|
||||||
_, err = client.Health(ctx)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
clients[node.Name] = client
|
|
||||||
}
|
}
|
||||||
|
client, err := testnet.Nodes[idx].Client()
|
||||||
if _, err = client.BroadcastTxSync(ctx, tx); err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
chSuccess <- tx
|
clients = append(clients, client)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(clients) == 0 {
|
||||||
|
panic("no clients to process load")
|
||||||
|
}
|
||||||
|
|
||||||
|
clientRing := ring.New(len(clients))
|
||||||
|
for idx := range clients {
|
||||||
|
clientRing.Value = clients[idx]
|
||||||
|
clientRing = clientRing.Next()
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
case tx := <-chTx:
|
||||||
|
clientRing = clientRing.Next()
|
||||||
|
client := clientRing.Value.(*rpchttp.HTTP)
|
||||||
|
|
||||||
|
if _, err := client.Health(ctx); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = client.BroadcastTxSync(ctx, tx); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case chSuccess <- tx:
|
||||||
|
continue
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user