aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2023-11-21 16:51:57 +0000
committerGopher Robot <gobot@golang.org>2023-11-21 23:10:51 +0000
commitff722e607cc131903181fe9d686d4d91ade15a2d (patch)
treebc692189a0f4e81b542fcacfcde7292cae0c84af /src/internal
parente6b76bfc4675eae8d1e4c7e8dc28897339b13824 (diff)
downloadgo-ff722e607cc131903181fe9d686d4d91ade15a2d.tar.xz
internal/trace/v2: dump text trace on failure only if it fits in the log
Currently we dump text traces to the build log on failure unconditionally, but this may cause the old infrastructure's builds' logs to get truncated. Avoid that by setting a threshold on the maximum size of the text trace we're willing to dump. We don't need this workaround on the new infrastructure -- logs don't get truncated there. Change-Id: I0f50f50bb4b90f87250b673fbe56f48235325610 Reviewed-on: https://go-review.googlesource.com/c/go/+/544216 Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/trace/v2/trace_test.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/internal/trace/v2/trace_test.go b/src/internal/trace/v2/trace_test.go
index b2d7781991..3300c00fe8 100644
--- a/src/internal/trace/v2/trace_test.go
+++ b/src/internal/trace/v2/trace_test.go
@@ -526,6 +526,7 @@ func testTraceProg(t *testing.T, progName string, extra func(t *testing.T, trace
// Check if we're on a builder.
onBuilder := testenv.Builder() != ""
+ onOldBuilder := !strings.Contains(testenv.Builder(), "gotip") && !strings.Contains(testenv.Builder(), "go1")
testPath := filepath.Join("./testdata/testprog", progName)
testName := progName
@@ -567,7 +568,18 @@ func testTraceProg(t *testing.T, progName string, extra func(t *testing.T, trace
// data is critical for debugging and this is the only way
// we can currently make sure it's retained.
t.Log("found bad trace; dumping to test log...")
- t.Log(dumpTraceToText(t, tb))
+ s := dumpTraceToText(t, tb)
+ if onOldBuilder && len(s) > 1<<20+512<<10 {
+ // The old build infrastructure truncates logs at ~2 MiB.
+ // Let's assume we're the only failure and give ourselves
+ // up to 1.5 MiB to dump the trace.
+ //
+ // TODO(mknyszek): Remove this when we've migrated off of
+ // the old infrastructure.
+ t.Logf("text trace too large to dump (%d bytes)", len(s))
+ } else {
+ t.Log(s)
+ }
} else if t.Failed() || *dumpTraces {
// We asked to dump the trace or failed. Write the trace to a file.
t.Logf("wrote trace to file: %s", dumpTraceToFile(t, testName, stress, tb))