mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
cmd/stress: prefix logs with start date/time
Currently, stress logs are named "/tmp/go-stress-" plus a random number. This makes it really annoying to tease apart failures from different stress runs. This CL changes the default prefix to "/tmp/go-stress-<ISO 8601 date/time>-<random number>" where the date/time part is when the stress command started. This naming clusters logs by stress invocation, making it easy to tease apart invocations, even if there are multiple stresses running concurrently or they are run back-to-back. This also provides a flag to override this prefix. Change-Id: I043e5ee7168ba6db4e2355e39b147071edbc6864 Reviewed-on: https://go-review.googlesource.com/c/150047 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
36a8f0a386
commit
b4e97c0ed8
@ -20,6 +20,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -32,6 +33,7 @@ var (
|
|||||||
flagKill = flag.Bool("kill", true, "kill timed out processes if true, otherwise just print pid (to attach with gdb)")
|
flagKill = flag.Bool("kill", true, "kill timed out processes if true, otherwise just print pid (to attach with gdb)")
|
||||||
flagFailure = flag.String("failure", "", "fail only if output matches `regexp`")
|
flagFailure = flag.String("failure", "", "fail only if output matches `regexp`")
|
||||||
flagIgnore = flag.String("ignore", "", "ignore failure if output matches `regexp`")
|
flagIgnore = flag.String("ignore", "", "ignore failure if output matches `regexp`")
|
||||||
|
flagOutput = flag.String("o", defaultPrefix(), "output failure logs to `path` plus a unique suffix")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -47,6 +49,11 @@ Usage:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func defaultPrefix() string {
|
||||||
|
date := time.Now().Format("go-stress-20060102T150405-")
|
||||||
|
return filepath.Join(os.TempDir(), date)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *flagP <= 0 || *flagTimeout <= 0 || len(flag.Args()) == 0 {
|
if *flagP <= 0 || *flagTimeout <= 0 || len(flag.Args()) == 0 {
|
||||||
@ -115,7 +122,8 @@ func main() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fails++
|
fails++
|
||||||
f, err := ioutil.TempFile("", "go-stress")
|
dir, path := filepath.Split(*flagOutput)
|
||||||
|
f, err := ioutil.TempFile(dir, path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("failed to create temp file: %v\n", err)
|
fmt.Printf("failed to create temp file: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user