Skip to content

Commit

Permalink
chore(e2e benchmark test): allows selection of only one test (#3618)
Browse files Browse the repository at this point in the history
Closes #3617

Before this PR, you could run:
```
 go run ./test/e2e/benchmark
test-e2e-benchmark2024/06/24 13:02:13 No particular test specified. Running all tests.
test-e2e-benchmark2024/06/24 13:02:13 go run ./test/e2e/benchmark <test_name> to run a specific test
test-e2e-benchmark2024/06/24 13:02:13 Valid tests are: TwoNodeSimple
```
and it would start running all the benchmark tests. However, after this
PR, it will require user to specify the test name:
```
go run ./test/e2e/benchmark                       
test-e2e-benchmark2024/06/24 13:26:24 No test is specified.
test-e2e-benchmark2024/06/24 13:26:24 Usage: go run ./test/e2e/benchmark <test_name>
test-e2e-benchmark2024/06/24 13:26:24 Valid tests are: TwoNodeSimple

```
  • Loading branch information
staheri14 authored Jun 25, 2024
1 parent c53add4 commit 9c025ad
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions test/e2e/benchmark/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,28 @@ func main() {
}

// 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")
if len(os.Args) < 2 {
logger.Println("No test is specified.")
logger.Println("Usage: go run ./test/e2e/benchmark <test_name>")
logger.Printf("Valid tests are: %s\n\n", getTestNames(tests))
// if no specific test is passed, run all tests
for _, test := range tests {
return

}
found := false
testName := os.Args[1]
for _, test := range tests {
if test.Name == testName {
found = true
runTest(logger, test)
break
}
}
if !found {
logger.Printf("Invalid test name: %s\n", testName)
logger.Printf("Valid tests are: %s\n", getTestNames(tests))
logger.Println("Usage: go run ./test/e2e/benchmark <test_name>")

}
}

type TestFunc func(*log.Logger) error
Expand Down

0 comments on commit 9c025ad

Please sign in to comment.