forked from erigontech/erigon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
70 lines (59 loc) · 2.17 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"flag"
"github.com/nebojsa94/erigon/erigon-lib/metrics"
"github.com/nebojsa94/erigon/cl/cltypes"
"github.com/nebojsa94/erigon/cl/phase1/forkchoice"
"github.com/nebojsa94/erigon/turbo/debug"
"github.com/nebojsa94/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)
}
}
}