mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 10:32:19 +00:00
8ea0096d56
This is a non functional change which consolidates the various packages under metrics into the top level package now that the dead code is removed. It is a precursor to the removal of Victoria metrics after which all erigon metrics code will be contained in this single package.
71 lines
2.2 KiB
Go
71 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
|
|
"github.com/ledgerwatch/erigon/metrics"
|
|
"github.com/ledgerwatch/erigon/turbo/debug"
|
|
|
|
"github.com/ledgerwatch/erigon/cl/cltypes"
|
|
"github.com/ledgerwatch/erigon/cl/phase1/forkchoice"
|
|
"github.com/ledgerwatch/erigon/cmd/caplin-regression/regression"
|
|
"github.com/ledgerwatch/log/v3"
|
|
"golang.org/x/exp/slices"
|
|
|
|
_ "net/http/pprof" //nolint:gosec
|
|
)
|
|
|
|
var nameTestsMap = map[string]func(*forkchoice.ForkChoiceStore, *cltypes.SignedBeaconBlock) error{
|
|
"TestRegressionWithValidation": regression.TestRegressionWithValidation,
|
|
"TestRegressionWithoutValidation": regression.TestRegressionWithoutValidation,
|
|
"TestRegressionBadBlocks": regression.TestRegressionBadBlocks,
|
|
}
|
|
|
|
var excludeTests = []string{"TestRegressionBadBlocks"}
|
|
|
|
func main() {
|
|
log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler))
|
|
test := flag.String("test", "TestRegressionWithValidation", "select test to run. can be TestRegressionWithValidation, TestRegressionWithoutValidation and TestRegressionBadBlocks")
|
|
step := flag.Int("step", 32, "how often to log performance")
|
|
pprof := flag.Bool("pprof", true, "turn on profiling")
|
|
loop := flag.Bool("loop", true, "loop the test in an infinite loop")
|
|
testsDir := flag.String("testsDir", "cmd/caplin-regression/caplin-tests", "directory to the tests")
|
|
|
|
all := flag.Bool("all", true, "loop trhough all the test")
|
|
|
|
flag.Parse()
|
|
if _, ok := nameTestsMap[*test]; !ok {
|
|
log.Error("Could not start regression tests", "err", "test not found")
|
|
return
|
|
}
|
|
r, err := regression.NewRegressionTester(
|
|
*testsDir,
|
|
)
|
|
if *pprof {
|
|
// Server for pprof
|
|
debug.StartPProf("localhost:6060", metrics.Setup("localhost:6060", log.Root()))
|
|
}
|
|
|
|
if err != nil {
|
|
log.Error("Could not start regression tests", "err", err)
|
|
return
|
|
}
|
|
|
|
for val := true; val; val = *loop {
|
|
if *all {
|
|
for name, t := range nameTestsMap {
|
|
if slices.Contains(excludeTests, name) {
|
|
continue
|
|
}
|
|
if err := r.Run(name, t, *step); err != nil {
|
|
log.Error("Could not do regression tests", "err", err)
|
|
}
|
|
}
|
|
continue
|
|
}
|
|
if err := r.Run(*test, nameTestsMap[*test], *step); err != nil {
|
|
log.Error("Could not do regression tests", "err", err)
|
|
}
|
|
}
|
|
}
|