Skip to content
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

test(e2e benchmark): refactors E2EThroughput #3395

Merged
merged 34 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
35cacc5
defines config options
staheri14 Apr 26, 2024
b1d6861
adds configOpts parameter to the Init func
staheri14 Apr 26, 2024
eb5d379
extends Setup parameter with config options
staheri14 Apr 26, 2024
f4c81f7
passes options through setup method
staheri14 Apr 26, 2024
c4e0b3b
allows passing genesis modifiers and consensus parameters in the test…
staheri14 Apr 26, 2024
ed1fddf
adds manifest struct
staheri14 Apr 26, 2024
cb63664
defines BenchTest
staheri14 Apr 26, 2024
05ecc53
make consensus params effective
staheri14 Apr 26, 2024
80c26e9
fixes getConsensusParams
staheri14 Apr 26, 2024
9af78d7
fixxes set consensus parameters by calling it after tesnet initiation
staheri14 Apr 26, 2024
94f8ef0
makes txsim image creation faster
staheri14 Apr 26, 2024
b4ae352
fixes changes to the order of AddFolder and Commit
staheri14 Apr 26, 2024
bd9fe31
obtains parameters from manifest
staheri14 Apr 26, 2024
8fd5d1f
reads txClient pars from manifest
staheri14 Apr 26, 2024
425b98f
fixes stale comments
staheri14 Apr 26, 2024
dd96cdc
removes private methods
staheri14 Apr 26, 2024
a944670
fixes linter issues
staheri14 Apr 26, 2024
4e26505
gets the remainder of the test parameters from the manifest
staheri14 Apr 26, 2024
25f4026
some reordering and refactoring
staheri14 Apr 26, 2024
2a978b8
Merge remote-tracking branch 'origin/main' into sanaz/manifest-first-…
staheri14 Apr 26, 2024
fe832f3
refactors the code
staheri14 Apr 26, 2024
e1a6e2d
resolves linter issues and returns error from benchTest methods
staheri14 Apr 26, 2024
c1e7d86
removes early return
staheri14 Apr 26, 2024
976ddca
Merge remote-tracking branch 'origin/main' into sanaz/refactor-E2EThr…
staheri14 Apr 29, 2024
4ed25aa
defines a separate go file for the BenchTest type and methods
staheri14 Apr 30, 2024
c2c7dfa
moves manifest to the benchmark package
staheri14 Apr 30, 2024
b2ac5f3
refactors the code to rename bench to benchmark
staheri14 May 17, 2024
193efd9
replaces txsim with txclient
staheri14 May 17, 2024
fac0034
Merge remote-tracking branch 'origin/main' into sanaz/refactor-E2EThr…
staheri14 May 17, 2024
db224b8
removes a redundant word
staheri14 May 17, 2024
e94ae4d
adds godoc for the BenchmarkTest methods
staheri14 May 17, 2024
a45e048
deletes old manifest file under the testnet package
staheri14 May 17, 2024
15b200c
fixes chain ID
staheri14 May 17, 2024
62a8781
addresses comments
staheri14 May 17, 2024
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
82 changes: 82 additions & 0 deletions test/e2e/benchmark/benchmark.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package main

import (
"fmt"
"log"
"time"

"github.com/celestiaorg/celestia-app/v2/test/e2e/testnet"
)

type BenchmarkTest struct {
*testnet.Testnet
manifest *Manifest
}

func NewBenchmarkTest(name string, manifest *Manifest) (*BenchmarkTest, error) {
// create a new testnet
testNet, err := testnet.New(name, seed,
testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID,
manifest.GetGenesisModifiers()...)
if err != nil {
return nil, err
}

testNet.SetConsensusParams(manifest.GetConsensusParams())
return &BenchmarkTest{Testnet: testNet, manifest: manifest}, nil
}

// SetupNodes creates genesis nodes and tx clients based on the manifest.
// There will be manifest.Validators validators and manifest.TxClients tx clients.
// Each tx client connects to one validator. If TxClients are fewer than Validators, some validators will not have a tx client.
func (b *BenchmarkTest) SetupNodes() error {
testnet.NoError("failed to create genesis nodes",
b.CreateGenesisNodes(b.manifest.Validators,
b.manifest.CelestiaAppVersion, b.manifest.SelfDelegation,
b.manifest.UpgradeHeight, b.manifest.ValidatorResource))

// obtain the GRPC endpoints of the validators
gRPCEndpoints, err := b.RemoteGRPCEndpoints()
testnet.NoError("failed to get validators GRPC endpoints", err)
log.Println("validators GRPC endpoints", gRPCEndpoints)

// create tx clients and point them to the validators
log.Println("Creating tx clients")

err = b.CreateTxClients(b.manifest.TxClientVersion,
b.manifest.BlobSequences,
b.manifest.BlobSizes,
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),
testnet.WithTimeoutPropose(b.manifest.TimeoutPropose),
testnet.WithTimeoutCommit(b.manifest.TimeoutCommit),
testnet.WithPrometheus(b.manifest.Prometheus),
))
return nil
}

// Run runs the benchmark test for the specified duration in the manifest.
func (b *BenchmarkTest) Run() error {
log.Println("Starting testnet")
err := b.Start()
if err != nil {
return fmt.Errorf("failed to start testnet: %v", err)
}

// once the testnet is up, start tx clients
log.Println("Starting tx clients")
err = b.StartTxClients()
if err != nil {
return fmt.Errorf("failed to start tx clients: %v", err)
}

// wait some time for the tx clients to submit transactions
time.Sleep(b.manifest.TestDuration)

return nil
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package testnet
package main

import (
"time"

"github.com/celestiaorg/celestia-app/v2/app"
"github.com/celestiaorg/celestia-app/v2/app/encoding"
"github.com/celestiaorg/celestia-app/v2/test/e2e/testnet"
"github.com/celestiaorg/celestia-app/v2/test/util/genesis"
blobtypes "github.com/celestiaorg/celestia-app/v2/x/blob/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
Expand All @@ -26,9 +27,9 @@ type Manifest struct {
// TxClientVersion a specific version of the txsim container image within celestiaorg repository on GitHub's Container Registry, i.e., https://github.com/celestiaorg/celestia-app/pkgs/container/txsim
TxClientVersion string
// Resource requirements for a validator node
ValidatorResource Resources
ValidatorResource testnet.Resources
// Resource requirements for a tx client
TxClientsResource Resources
TxClientsResource testnet.Resources

// tx client settings
// Number of blobs per sequence
Expand Down
54 changes: 11 additions & 43 deletions test/e2e/benchmark/throughput.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func E2EThroughput() error {

log.Println("=== RUN E2EThroughput", "version:", latestVersion)

manifest := testnet.Manifest{
manifest := Manifest{
ChainID: "test-e2e-throughput",
Validators: 2,
ValidatorResource: testnet.DefaultResources,
Expand All @@ -50,56 +50,23 @@ func E2EThroughput() error {
TestDuration: 30 * time.Second,
TxClients: 2,
}
// create a new testnet
testNet, err := testnet.New("E2EThroughput", seed,
testnet.GetGrafanaInfoFromEnvVar(), manifest.ChainID,
manifest.GetGenesisModifiers()...)
testnet.NoError("failed to create testnet", err)

testNet.SetConsensusParams(manifest.GetConsensusParams())
benchTest, err := NewBenchmarkTest("E2EThroughput", &manifest)
testnet.NoError("failed to create benchmark test", err)

defer func() {
log.Print("Cleaning up testnet")
testNet.Cleanup()
benchTest.Cleanup()
}()

testnet.NoError("failed to create genesis nodes",
testNet.CreateGenesisNodes(manifest.Validators,
manifest.CelestiaAppVersion, manifest.SelfDelegation,
manifest.UpgradeHeight, manifest.ValidatorResource))

// obtain the GRPC endpoints of the validators
gRPCEndpoints, err := testNet.RemoteGRPCEndpoints()
testnet.NoError("failed to get validators GRPC endpoints", err)
log.Println("validators GRPC endpoints", gRPCEndpoints)

// create tx clients and point them to the validators
log.Println("Creating tx clients")

err = testNet.CreateTxClients(manifest.TxClientVersion, manifest.BlobSequences,
manifest.BlobSizes,
manifest.TxClientsResource, gRPCEndpoints[:manifest.TxClients])
testnet.NoError("failed to create tx clients", err)
testnet.NoError("failed to setup nodes", benchTest.SetupNodes())

// start the testnet
log.Println("Setting up testnet")
testnet.NoError("failed to setup testnet", testNet.Setup(
testnet.WithPerPeerBandwidth(manifest.PerPeerBandwidth),
testnet.WithTimeoutPropose(manifest.TimeoutPropose),
testnet.WithTimeoutCommit(manifest.TimeoutCommit),
testnet.WithPrometheus(manifest.Prometheus),
))
log.Println("Starting testnet")
testnet.NoError("failed to start testnet", testNet.Start())

// once the testnet is up, start the tx clients
log.Println("Starting tx clients")
testnet.NoError("failed to start tx clients", testNet.StartTxClients())

// wait some time for the tx clients to submit transactions
time.Sleep(manifest.TestDuration)
testnet.NoError("failed to run the benchmark test", benchTest.Run())

// post test data collection and validation
log.Println("Reading blockchain")
blockchain, err := testnode.ReadBlockchain(context.Background(), testNet.Node(0).AddressRPC())
blockchain, err := testnode.ReadBlockchain(context.Background(),
benchTest.Node(0).AddressRPC())
Comment on lines +68 to +69
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of context.Background() in ReadBlockchain might not be ideal for all scenarios. Consider passing a context that can be controlled externally.

- blockchain, err := testnode.ReadBlockchain(context.Background(),
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ blockchain, err := testnode.ReadBlockchain(ctx,

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
blockchain, err := testnode.ReadBlockchain(context.Background(),
benchTest.Node(0).AddressRPC())
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
blockchain, err := testnode.ReadBlockchain(ctx,
benchTest.Node(0).AddressRPC())

testnet.NoError("failed to read blockchain", err)

totalTxs := 0
Expand All @@ -112,6 +79,7 @@ func E2EThroughput() error {
if totalTxs < 10 {
return fmt.Errorf("expected at least 10 transactions, got %d", totalTxs)
}

log.Println("--- PASS ✅: E2EThroughput")
return nil
}
Loading