diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go index 0b84820d0e..c52db0cb6a 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -555,6 +555,7 @@ func (h *plannedHandoffHarness) start(t *testing.T, name, binary string, args .. } _ = log.Close() if t.Failed() { + keepFullLog(t, d) data, _ := os.ReadFile(d.log) if len(data) > 16000 { data = data[len(data)-16000:] @@ -571,6 +572,28 @@ func (h *plannedHandoffHarness) start(t *testing.T, name, binary string, args .. return d } +// keepFullLog copies a failed test's daemon log, whole, into +// $SWBLOCK_TEST_LOG_DIR when that is set (a gate run collects it): the +// test's own output keeps only the log's tail, and a bring-up decision is +// at its head. +func keepFullLog(t *testing.T, d *daemon) { + dir := os.Getenv("SWBLOCK_TEST_LOG_DIR") + if dir == "" { + return + } + data, err := os.ReadFile(d.log) + if err == nil { + err = os.MkdirAll(dir, 0o755) + } + if err == nil { + name := strings.NewReplacer("/", "_", " ", "_").Replace(t.Name()) + "-" + d.name + ".log" + err = os.WriteFile(filepath.Join(dir, name), data, 0o644) + } + if err != nil { + t.Logf("%s: full log not kept: %v", d.name, err) + } +} + // wait waits up to timeout for the child to exit by itself and returns its // exit error (nil: status 0). func (d *daemon) wait(timeout time.Duration) error { diff --git a/seaweed-block/testops/scenarios/layout-realcluster-integration-gate.yaml b/seaweed-block/testops/scenarios/layout-realcluster-integration-gate.yaml index aabb735fc0..f90df901c2 100644 --- a/seaweed-block/testops/scenarios/layout-realcluster-integration-gate.yaml +++ b/seaweed-block/testops/scenarios/layout-realcluster-integration-gate.yaml @@ -194,7 +194,8 @@ phases: *) echo "unknown entry: $t" >&2; exit 2 ;; esac log="$d/evidence/$t.log" - (cd "$d/source/$pkg" && env $extra "$d/bin/$bin" -test.run "^$name\$" -test.v -test.count 1 -test.timeout "$to") > "$log" 2>&1 + # A failed test keeps its daemons' whole logs here (collected). + (cd "$d/source/$pkg" && env $extra SWBLOCK_TEST_LOG_DIR="$d/evidence/$t-daemons" "$d/bin/$bin" -test.run "^$name\$" -test.v -test.count 1 -test.timeout "$to") > "$log" 2>&1 rc=$? if [ "$rc" -eq 0 ] && grep -qE "^--- PASS: $name \(" "$log"; then echo "PASS $t $name" >> "$d/evidence/verdicts.txt"