Skip to content

Commit

Permalink
test(e2e benchmark): adds network latency (#3494)
Browse files Browse the repository at this point in the history
Closes #3317
  • Loading branch information
staheri14 authored May 17, 2024
1 parent 33f818b commit c5b0b94
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/e2e/benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ func (b *BenchmarkTest) SetupNodes() error {
b.manifest.CelestiaAppVersion, b.manifest.SelfDelegation,
b.manifest.UpgradeHeight, b.manifest.ValidatorResource))

// enable latency if specified in the manifest
if b.manifest.EnableLatency {
for _, node := range b.Nodes() {
if err := node.Instance.EnableBitTwister(); err != nil {
return fmt.Errorf("failed to enable bit twister: %v", err)
}
}
}
// obtain the GRPC endpoints of the validators
gRPCEndpoints, err := b.RemoteGRPCEndpoints()
testnet.NoError("failed to get validators GRPC endpoints", err)
Expand All @@ -49,7 +57,6 @@ func (b *BenchmarkTest) SetupNodes() error {
b.manifest.TxClientsResource, gRPCEndpoints)
testnet.NoError("failed to create tx clients", err)

// set up the testnet
log.Println("Setting up testnet")
testnet.NoError("failed to setup testnet", b.Setup(
testnet.WithPerPeerBandwidth(b.manifest.PerPeerBandwidth),
Expand All @@ -68,6 +75,19 @@ func (b *BenchmarkTest) Run() error {
return fmt.Errorf("failed to start testnet: %v", err)
}

// add latency if specified in the manifest
if b.manifest.EnableLatency {
for _, node := range b.Nodes() {
if err = node.ForwardBitTwisterPort(); err != nil {
return fmt.Errorf("failed to forward bit twister port: %v", err)
}
if err = node.Instance.SetLatencyAndJitter(b.manifest.LatencyParams.
Latency, b.manifest.LatencyParams.Jitter); err != nil {
return fmt.Errorf("failed to set latency and jitter: %v", err)
}
}
}

// once the testnet is up, start tx clients
log.Println("Starting tx clients")
err = b.StartTxClients()
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/benchmark/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)

type LatencyParams struct {
// Latency in milliseconds
Latency int64
// Jitter in milliseconds
Jitter int64
}

// Manifest defines the parameters for a testnet.
type Manifest struct {
ChainID string
Expand All @@ -30,6 +37,10 @@ type Manifest struct {
ValidatorResource testnet.Resources
// Resource requirements for a tx client
TxClientsResource testnet.Resources
// EnableLatency enables network latency for the validators
EnableLatency bool
// LatencyParams defines the network latency parameters
LatencyParams LatencyParams

// tx client settings
// Number of blobs per sequence
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/benchmark/throughput.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func E2EThroughput() error {
SelfDelegation: 10000000,
CelestiaAppVersion: latestVersion,
TxClientVersion: testnet.TxsimVersion,
EnableLatency: true,
LatencyParams: LatencyParams{100, 10}, // in milliseconds
BlobsPerSeq: 1,
BlobSequences: 1,
BlobSizes: "10000-10000",
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/testnet/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,17 @@ func (n *Node) forwardPorts() error {
return nil
}

func (n *Node) ForwardBitTwisterPort() error {
fwdBtPort, err := n.Instance.PortForwardTCP(n.Instance.BitTwister.Port())
if err != nil {
return err
}
n.Instance.BitTwister.SetPort(fwdBtPort)
n.Instance.BitTwister.SetNewClientByIPAddr("http://localhost")
log.Info().Str("address", fmt.Sprintf("http://localhost:%d", fwdBtPort)).Msg("BitTwister is listening")
return nil
}

func DockerImageName(version string) string {
return fmt.Sprintf("%s:%s", dockerSrcURL, version)
}
Expand Down

0 comments on commit c5b0b94

Please sign in to comment.