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

feat: enables selection and execution of specific e2e benchmark tests #3595

Merged
merged 8 commits into from
Jun 20, 2024
61 changes: 61 additions & 0 deletions test/e2e/benchmark/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package main

import (
"log"
"os"
"strings"
)

func main() {
logger := log.New(os.Stdout, "test-e2e-benchmark", log.LstdFlags)

tests := []Test{
{"TwoNodeSimple", TwoNodeSimple},
}

// check the test name passed as an argument and run it
specificTestFound := false
for _, arg := range os.Args[1:] {
for _, test := range tests {
if test.Name == arg {
runTest(logger, test)
specificTestFound = true
break
}
}
}

if !specificTestFound {
logger.Println("No particular test specified. Running all tests.")
logger.Println("go run ./test/e2e/benchmark <test_name> to run a specific test")
logger.Printf("Valid tests are: %s\n\n", getTestNames(tests))
// if no specific test is passed, run all tests
for _, test := range tests {
runTest(logger, test)
}
}
}
staheri14 marked this conversation as resolved.
Show resolved Hide resolved

type TestFunc func(*log.Logger) error

type Test struct {
Name string
Func TestFunc
}

func runTest(logger *log.Logger, test Test) {
logger.Printf("=== RUN %s", test.Name)
err := test.Func(logger)
if err != nil {
logger.Fatalf("--- ERROR %s: %v", test.Name, err)
}
logger.Printf("--- ✅ PASS: %s \n\n", test.Name)
}
staheri14 marked this conversation as resolved.
Show resolved Hide resolved

func getTestNames(tests []Test) string {
testNames := make([]string, 0, len(tests))
for _, test := range tests {
testNames = append(testNames, test.Name)
}
return strings.Join(testNames, ", ")
}
13 changes: 3 additions & 10 deletions test/e2e/benchmark/throughput.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,14 @@ const (
seed = 42
)

func main() {
if err := E2EThroughput(); err != nil {
log.Fatalf("--- ERROR Throughput test: %v", err.Error())
}
}

func E2EThroughput() error {
func TwoNodeSimple(logger *log.Logger) error {
latestVersion, err := testnet.GetLatestVersion()
testnet.NoError("failed to get latest version", err)

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

manifest := Manifest{
ChainID: "test-e2e-throughput",
ChainID: "test-e2e-two-node-simple",
Validators: 2,
ValidatorResource: testnet.DefaultResources,
TxClientsResource: testnet.DefaultResources,
Expand Down Expand Up @@ -106,6 +100,5 @@ func E2EThroughput() error {
return fmt.Errorf("expected at least 10 transactions, got %d", totalTxs)
}

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