Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2071,29 +2071,13 @@ func (c *clusterImpl) Install(
return errors.Wrap(roachprod.Install(ctx, l, c.MakeNodes(nodes), software), "cluster.Install")
}

var reOnlyAlphanumeric = regexp.MustCompile(`[^a-zA-Z0-9]+`)

// cmdLogFileName comes up with a log file to use for the given argument string.
func cmdLogFileName(t time.Time, nodes option.NodeListOption, args ...string) string {
// Make sure we treat {"./cockroach start"} like {"./cockroach", "start"}.
args = strings.Split(strings.Join(args, " "), " ")
prefix := []string{reOnlyAlphanumeric.ReplaceAllString(args[0], "")}
for _, arg := range args[1:] {
if s := reOnlyAlphanumeric.ReplaceAllString(arg, ""); s != arg {
break
}
prefix = append(prefix, arg)
}
s := strings.Join(prefix, "_")
const maxLen = 70
if len(s) > maxLen {
s = s[:maxLen]
}
logFile := fmt.Sprintf(
"run_%s_n%s_%s",
t.Format(`150405.000000000`),
nodes.String()[1:],
s,
install.GenFilenameFromArgs(20, args...),
)
return logFile
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func TestClusterMachineType(t *testing.T) {
func TestCmdLogFileName(t *testing.T) {
ts := time.Date(2000, 1, 1, 15, 4, 12, 0, time.Local)

const exp = `run_150412.000000000_n1,3-4,9_cockroach_bla`
const exp = `run_150412.000000000_n1,3-4,9_cockroach-bla-foo-ba`
nodes := option.NodeListOption{1, 3, 4, 9}
assert.Equal(t,
exp,
Expand Down
9 changes: 4 additions & 5 deletions pkg/cmd/roachtest/test_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,14 @@ func (t *testImpl) addFailure(format string, args ...interface{}) {
formatFailure(&b, reportFailure)
msg := b.String()

t.L().Printf("test failure #%d: %s", len(t.mu.failures), msg)
failureNum := len(t.mu.failures)
failureLog := fmt.Sprintf("failure_%d", failureNum)
t.L().Printf("test failure #%d: full stack retained in %s.log: %s", failureNum, failureLog, msg)
// Also dump the verbose error (incl. all stack traces) to a log file, in case
// we need it. The stacks are sometimes helpful, but we don't want them in the
// main log as they are highly verbose.
{
cl, err := t.L().ChildLogger(
fmt.Sprintf("failure_%d", len(t.mu.failures)),
logger.QuietStderr, logger.QuietStdout,
)
cl, err := t.L().ChildLogger(failureLog, logger.QuietStderr, logger.QuietStdout)
if err == nil {
// We don't actually log through this logger since it adds an unrelated
// file:line caller (namely ours). The error already has stack traces
Expand Down
Loading