-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored test interface to enable parallelization
- Loading branch information
1 parent
3fcbf42
commit 146dd9f
Showing
15 changed files
with
292 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ replace github.com/smartcontractkit/chainlink/deployment => ../../deployment | |
// creating potential merge conflicts. | ||
require ( | ||
github.com/smartcontractkit/chainlink/deployment v0.0.0-20241206210521-125d98cdaf66 | ||
github.com/smartcontractkit/chainlink/v2 v2.0.0-20241206210521-125d98cdaf66 | ||
github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241106193309-5560cd76211a | ||
) | ||
|
||
require ( | ||
|
@@ -33,9 +33,7 @@ require ( | |
github.com/prometheus/client_golang v1.20.5 | ||
github.com/shopspring/decimal v1.4.0 | ||
github.com/smartcontractkit/chainlink-automation v0.8.1 | ||
github.com/smartcontractkit/chainlink-common v0.3.1-0.20241206162350-10f03fd2126b | ||
github.com/smartcontractkit/chainlink/deployment v0.0.0-00010101000000-000000000000 | ||
github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241106193309-5560cd76211a | ||
github.com/smartcontractkit/chainlink-common v0.4.1-0.20241217143242-5bd6eb484177 | ||
Check failure on line 36 in core/scripts/go.mod GitHub Actions / Validate go.mod dependencies
|
||
github.com/smartcontractkit/libocr v0.0.0-20241007185508-adbe57025f12 | ||
github.com/spf13/cobra v1.8.1 | ||
github.com/spf13/viper v1.19.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package evm_test | ||
|
||
import ( | ||
"bytes" | ||
"os/exec" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestRunChainComponentsMultipleTimes(t *testing.T) { | ||
// Configuration for the test run | ||
testName := "TestChainComponents" | ||
numRuns := 1000 | ||
failCount := 0 | ||
totalTime := time.Duration(0) | ||
|
||
for i := 1; i <= numRuns; i++ { | ||
t.Logf("Running %s: iteration %d/%d...\n", testName, i, numRuns) | ||
|
||
// Clear the Go test cache | ||
cleanCmd := exec.Command("go", "clean", "-testcache") | ||
cleanErr := cleanCmd.Run() | ||
if cleanErr != nil { | ||
t.Fatalf("Failed to clear test cache: %v", cleanErr) | ||
} | ||
|
||
// Start the timer | ||
start := time.Now() | ||
|
||
// Run the test via `go test` | ||
cmd := exec.Command("go", "test", "-run", testName, "./...") | ||
var out bytes.Buffer | ||
var stderr bytes.Buffer | ||
cmd.Stdout = &out | ||
cmd.Stderr = &stderr | ||
|
||
err := cmd.Run() | ||
|
||
// Record the elapsed time | ||
elapsed := time.Since(start) | ||
totalTime += elapsed | ||
|
||
if err != nil { | ||
failCount++ | ||
t.Errorf("Iteration %d failed with error: %s\n", i, err) | ||
t.Logf("Test output:\n%s\n", out.String()) | ||
t.Logf("Test error output:\n%s\n", stderr.String()) | ||
} else { | ||
t.Logf("Iteration %d passed.\n", i) | ||
} | ||
|
||
t.Logf("Test duration: %s\n", elapsed) | ||
} | ||
|
||
// Calculate the average test time | ||
averageTime := totalTime / time.Duration(numRuns) | ||
|
||
// Print results | ||
t.Logf("\nResults for %s:\n", testName) | ||
t.Logf("Total runs: %d\n", numRuns) | ||
t.Logf("Failures: %d\n", failCount) | ||
t.Logf("Pass rate: %.2f%%\n", float64(numRuns-failCount)/float64(numRuns)*100) | ||
t.Logf("Total time: %s\n", totalTime) | ||
t.Logf("Average test time: %s\n", averageTime) | ||
|
||
// Optional: Fail the entire test if there were any failures | ||
if failCount > 0 { | ||
t.Fatalf("Test failed %d/%d times.\n", failCount, numRuns) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.