Prepare regression testings for kube (#7697)

This commit is contained in:
Giulio rebuffo 2023-06-09 14:38:28 +02:00 committed by GitHub
parent 06af87dad7
commit 614769f7ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 42 deletions

View File

@ -75,7 +75,7 @@ COPY --from=builder /app/build/bin/state /usr/local/bin/state
COPY --from=builder /app/build/bin/txpool /usr/local/bin/txpool
COPY --from=builder /app/build/bin/verkle /usr/local/bin/verkle
COPY --from=builder /app/build/bin/caplin-phase1 /usr/local/bin/caplin-phase1
COPY --from=builder /app/build/bin/caplin-regression /usr/local/bin/caplin-regression
EXPOSE 8545 \

View File

@ -3,12 +3,14 @@ package main
import (
"flag"
"net/http"
_ "net/http/pprof" //nolint:gosec
"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{
@ -17,11 +19,16 @@ var nameTestsMap = map[string]func(*forkchoice.ForkChoiceStore, *cltypes.SignedB
"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", 1, "how often to log performance")
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")
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")
@ -46,7 +53,20 @@ func main() {
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)
}
}
}

View File

@ -34,7 +34,6 @@ func NewRegressionTester(testDirectory string) (*RegressionTester, error) {
}
func (r *RegressionTester) Run(name string, fn func(*forkchoice.ForkChoiceStore, *cltypes.SignedBeaconBlock) error, step int) error {
for true {
state, err := r.readStartingState()
if err != nil {
return err
@ -71,7 +70,7 @@ func (r *RegressionTester) Run(name string, fn func(*forkchoice.ForkChoiceStore,
dbg.ReadMemStats(&m)
sum := time.Since(begin)
log.Info("Finished/Restarting test", "name", name, "averageBlockTime", sum/time.Duration(len(r.blockList)), "sys", common.ByteCount(m.Sys))
}
return nil
}