add profiling for e2e tests
This commit is contained in:
parent
b08431b73a
commit
95fe4a0937
2 changed files with 18 additions and 2 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -6,3 +6,6 @@ e2e_report.html
|
||||||
bin
|
bin
|
||||||
out
|
out
|
||||||
d2
|
d2
|
||||||
|
|
||||||
|
# https://github.com/golang/go/blob/8b67cf0bc6ad657fddcbaaa10729d0086f08f9a9/src/cmd/go/internal/test/test.go#L415-L416
|
||||||
|
e2etests.test
|
||||||
|
|
@ -36,9 +36,13 @@ func main() {
|
||||||
vFlag := false
|
vFlag := false
|
||||||
testCaseFlag := ""
|
testCaseFlag := ""
|
||||||
testSetFlag := ""
|
testSetFlag := ""
|
||||||
|
cpuProfileFlag := false
|
||||||
|
memProfileFlag := false
|
||||||
flag.BoolVar(&deltaFlag, "delta", false, "Generate the report only for cases that changed.")
|
flag.BoolVar(&deltaFlag, "delta", false, "Generate the report only for cases that changed.")
|
||||||
flag.StringVar(&testSetFlag, "test-set", "", "Only run set of tests matching this string. e.g. regressions")
|
flag.StringVar(&testSetFlag, "test-set", "", "Only run set of tests matching this string. e.g. regressions")
|
||||||
flag.StringVar(&testCaseFlag, "test-case", "", "Only run tests matching this string. e.g. all_shapes")
|
flag.StringVar(&testCaseFlag, "test-case", "", "Only run tests matching this string. e.g. all_shapes")
|
||||||
|
flag.BoolVar(&cpuProfileFlag, "cpuprofile", false, "Profile test cpu usage. `go tool pprof out/cpu.prof`")
|
||||||
|
flag.BoolVar(&memProfileFlag, "memprofile", false, "Profile test memory usage. `go tool pprof out/mem.prof`")
|
||||||
skipTests := flag.Bool("skip-tests", false, "Skip running tests first")
|
skipTests := flag.Bool("skip-tests", false, "Skip running tests first")
|
||||||
flag.BoolVar(&vFlag, "v", false, "verbose")
|
flag.BoolVar(&vFlag, "v", false, "verbose")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
@ -47,7 +51,16 @@ func main() {
|
||||||
if vFlag {
|
if vFlag {
|
||||||
vString = "-v"
|
vString = "-v"
|
||||||
}
|
}
|
||||||
testMatchString := fmt.Sprintf("TestE2E/%s/%s", testSetFlag, testCaseFlag)
|
testMatchString := fmt.Sprintf("-run=TestE2E/%s/%s", testSetFlag, testCaseFlag)
|
||||||
|
|
||||||
|
cpuProfileStr := ""
|
||||||
|
if cpuProfileFlag {
|
||||||
|
cpuProfileStr = `-cpuprofile=out/cpu.prof`
|
||||||
|
}
|
||||||
|
memProfileStr := ""
|
||||||
|
if memProfileFlag {
|
||||||
|
memProfileStr = `-memprofile=out/mem.prof`
|
||||||
|
}
|
||||||
|
|
||||||
testDir := os.Getenv("TEST_DIR")
|
testDir := os.Getenv("TEST_DIR")
|
||||||
if testDir == "" {
|
if testDir == "" {
|
||||||
|
|
@ -58,7 +71,7 @@ func main() {
|
||||||
ctx := log.Stderr(context.Background())
|
ctx := log.Stderr(context.Background())
|
||||||
ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
|
ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
cmd := exec.CommandContext(ctx, "go", "test", testDir, "-run", testMatchString, vString)
|
cmd := exec.CommandContext(ctx, "go", "test", testDir, testMatchString, cpuProfileStr, memProfileStr, vString)
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = os.Environ()
|
||||||
cmd.Env = append(cmd.Env, "FORCE_COLOR=1")
|
cmd.Env = append(cmd.Env, "FORCE_COLOR=1")
|
||||||
cmd.Env = append(cmd.Env, "DEBUG=1")
|
cmd.Env = append(cmd.Env, "DEBUG=1")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue