mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
cmd/workload: add archive flag
This commit is contained in:
parent
2aa44e071a
commit
ec82bf357c
4 changed files with 78 additions and 52 deletions
|
|
@ -45,11 +45,11 @@ func newFilterTestSuite(cfg testConfig) *filterTestSuite {
|
|||
return s
|
||||
}
|
||||
|
||||
func (s *filterTestSuite) allTests() []utesting.Test {
|
||||
return []utesting.Test{
|
||||
{Name: "Filter/ShortRange", Fn: s.filterShortRange},
|
||||
{Name: "Filter/LongRange", Fn: s.filterLongRange, Slow: true},
|
||||
{Name: "Filter/FullRange", Fn: s.filterFullRange, Slow: true},
|
||||
func (s *filterTestSuite) allTests() []workloadTest {
|
||||
return []workloadTest{
|
||||
newWorkLoadTest("Filter/ShortRange", s.filterShortRange),
|
||||
newSlowWorkloadTest("Filter/LongRange", s.filterLongRange),
|
||||
newSlowWorkloadTest("Filter/FullRange", s.filterFullRange),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,40 +64,16 @@ func (s *historyTestSuite) loadTests() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *historyTestSuite) allTests() []utesting.Test {
|
||||
return []utesting.Test{
|
||||
{
|
||||
Name: "History/getBlockByHash",
|
||||
Fn: s.testGetBlockByHash,
|
||||
},
|
||||
{
|
||||
Name: "History/getBlockByNumber",
|
||||
Fn: s.testGetBlockByNumber,
|
||||
},
|
||||
{
|
||||
Name: "History/getBlockReceiptsByHash",
|
||||
Fn: s.testGetBlockReceiptsByHash,
|
||||
},
|
||||
{
|
||||
Name: "History/getBlockReceiptsByNumber",
|
||||
Fn: s.testGetBlockReceiptsByNumber,
|
||||
},
|
||||
{
|
||||
Name: "History/getBlockTransactionCountByHash",
|
||||
Fn: s.testGetBlockTransactionCountByHash,
|
||||
},
|
||||
{
|
||||
Name: "History/getBlockTransactionCountByNumber",
|
||||
Fn: s.testGetBlockTransactionCountByNumber,
|
||||
},
|
||||
{
|
||||
Name: "History/getTransactionByBlockHashAndIndex",
|
||||
Fn: s.testGetTransactionByBlockHashAndIndex,
|
||||
},
|
||||
{
|
||||
Name: "History/getTransactionByBlockNumberAndIndex",
|
||||
Fn: s.testGetTransactionByBlockNumberAndIndex,
|
||||
},
|
||||
func (s *historyTestSuite) allTests() []workloadTest {
|
||||
return []workloadTest{
|
||||
newWorkLoadTest("History/getBlockByHash", s.testGetBlockByHash),
|
||||
newWorkLoadTest("History/getBlockByNumber", s.testGetBlockByNumber),
|
||||
newWorkLoadTest("History/getBlockReceiptsByHash", s.testGetBlockReceiptsByHash),
|
||||
newWorkLoadTest("History/getBlockReceiptsByNumber", s.testGetBlockReceiptsByNumber),
|
||||
newWorkLoadTest("History/getBlockTransactionCountByHash", s.testGetBlockTransactionCountByHash),
|
||||
newWorkLoadTest("History/getBlockTransactionCountByNumber", s.testGetBlockTransactionCountByNumber),
|
||||
newWorkLoadTest("History/getTransactionByBlockHashAndIndex", s.testGetTransactionByBlockHashAndIndex),
|
||||
newWorkLoadTest("History/getTransactionByBlockNumberAndIndex", s.testGetTransactionByBlockNumberAndIndex),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import (
|
|||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"slices"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/history"
|
||||
"github.com/ethereum/go-ethereum/internal/flags"
|
||||
|
|
@ -45,6 +44,7 @@ var (
|
|||
testPatternFlag,
|
||||
testTAPFlag,
|
||||
testSlowFlag,
|
||||
testArchiveFlag,
|
||||
testSepoliaFlag,
|
||||
testMainnetFlag,
|
||||
filterQueryFileFlag,
|
||||
|
|
@ -69,6 +69,12 @@ var (
|
|||
Value: false,
|
||||
Category: flags.TestingCategory,
|
||||
}
|
||||
testArchiveFlag = &cli.BoolFlag{
|
||||
Name: "archive",
|
||||
Usage: "Enable archive tests",
|
||||
Value: false,
|
||||
Category: flags.TestingCategory,
|
||||
}
|
||||
testSepoliaFlag = &cli.BoolFlag{
|
||||
Name: "sepolia",
|
||||
Usage: "Use test cases for sepolia network",
|
||||
|
|
@ -145,6 +151,48 @@ func testConfigFromCLI(ctx *cli.Context) (cfg testConfig) {
|
|||
return cfg
|
||||
}
|
||||
|
||||
// workloadTest represents a single test in the workload. It's a wrapper
|
||||
// of utesting.Test by adding a few additional attributes.
|
||||
type workloadTest struct {
|
||||
utesting.Test
|
||||
|
||||
archive bool // Flag whether the archive node (full state history) is required for this test
|
||||
}
|
||||
|
||||
func newWorkLoadTest(name string, fn func(t *utesting.T)) workloadTest {
|
||||
return workloadTest{
|
||||
Test: utesting.Test{
|
||||
Name: name,
|
||||
Fn: fn,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newSlowWorkloadTest(name string, fn func(t *utesting.T)) workloadTest {
|
||||
t := newWorkLoadTest(name, fn)
|
||||
t.Slow = true
|
||||
return t
|
||||
}
|
||||
|
||||
func newArchiveWorkloadTest(name string, fn func(t *utesting.T)) workloadTest {
|
||||
t := newWorkLoadTest(name, fn)
|
||||
t.archive = true
|
||||
return t
|
||||
}
|
||||
|
||||
func filterTests(tests []workloadTest, pattern string, filterFn func(t workloadTest) bool) []utesting.Test {
|
||||
var utests []utesting.Test
|
||||
for _, t := range tests {
|
||||
if filterFn(t) {
|
||||
utests = append(utests, t.Test)
|
||||
}
|
||||
}
|
||||
if pattern == "" {
|
||||
return utests
|
||||
}
|
||||
return utesting.MatchTests(utests, pattern)
|
||||
}
|
||||
|
||||
func runTestCmd(ctx *cli.Context) error {
|
||||
cfg := testConfigFromCLI(ctx)
|
||||
filterSuite := newFilterTestSuite(cfg)
|
||||
|
|
@ -155,14 +203,16 @@ func runTestCmd(ctx *cli.Context) error {
|
|||
tests := filterSuite.allTests()
|
||||
tests = append(tests, historySuite.allTests()...)
|
||||
tests = append(tests, traceSuite.allTests()...)
|
||||
if ctx.IsSet(testPatternFlag.Name) {
|
||||
tests = utesting.MatchTests(tests, ctx.String(testPatternFlag.Name))
|
||||
}
|
||||
if !ctx.Bool(testSlowFlag.Name) {
|
||||
tests = slices.DeleteFunc(tests, func(test utesting.Test) bool {
|
||||
return test.Slow
|
||||
})
|
||||
}
|
||||
|
||||
utests := filterTests(tests, ctx.String(testPatternFlag.Name), func(t workloadTest) bool {
|
||||
if t.Slow && !ctx.Bool(testSlowFlag.Name) {
|
||||
return false
|
||||
}
|
||||
if t.archive && !ctx.Bool(testArchiveFlag.Name) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
// Disable logging unless explicitly enabled.
|
||||
if !ctx.IsSet("verbosity") && !ctx.IsSet("vmodule") {
|
||||
|
|
@ -174,7 +224,7 @@ func runTestCmd(ctx *cli.Context) error {
|
|||
if ctx.Bool(testTAPFlag.Name) {
|
||||
run = utesting.RunTAP
|
||||
}
|
||||
results := run(tests, os.Stdout)
|
||||
results := run(utests, os.Stdout)
|
||||
if utesting.CountFailures(results) > 0 {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,9 +72,9 @@ func (s *traceTestSuite) loadTests() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *traceTestSuite) allTests() []utesting.Test {
|
||||
return []utesting.Test{
|
||||
{Name: "Trace/Transaction", Fn: s.traceTransaction},
|
||||
func (s *traceTestSuite) allTests() []workloadTest {
|
||||
return []workloadTest{
|
||||
newArchiveWorkloadTest("Trace/Transaction", s.traceTransaction),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue