carlos / platform Public

Merge remote-tracking branch 'origin/main' into ha-successor-fixture-registry

claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev ea3441a7bd7bfceb93c4e5a12ff30afadf5363c4 parent e889523parent 2afc9d6
3 files changed, +51 −7
  • dbforward_e2e_test.go +30 −1
  • internal/edge/demo_api_integration_test.go +15 −5
  • internal/host/hadepartures_scan_test.go +6 −1

CI passed — run details

diff --git a/dbforward_e2e_test.go b/dbforward_e2e_test.go
index 211a8442a..31a8b6db2 100644
--- a/dbforward_e2e_test.go
+++ b/dbforward_e2e_test.go
@@ -392,6 +392,22 @@ type dbfTap struct {
addr string
mu sync.Mutex
down []time.Time
+ // events says how each tapped connection ended, and when, so a
+ // failure can tell which side closed first (#897: the CLI's read was
+ // admitted and then "client gone" a millisecond later, on CI only).
+ events []string
+}
+
+func (tp *dbfTap) event(f string, args ...any) {
+ tp.mu.Lock()
+ defer tp.mu.Unlock()
+ tp.events = append(tp.events, time.Now().Format("15:04:05.000000 ")+fmt.Sprintf(f, args...))
+}
+
+func (tp *dbfTap) trace() string {
+ tp.mu.Lock()
+ defer tp.mu.Unlock()
+ return strings.Join(tp.events, "\n")
}
func newDBFTap(t *testing.T, target string, connect bool) *dbfTap {
@@ -430,25 +446,33 @@ func (tp *dbfTap) serve(c net.Conn, target string, connect bool) {
}
up, err := net.Dial("tcp", target)
if err != nil {
+ tp.event("%s: dial upstream: %v", c.RemoteAddr(), err)
return
}
defer up.Close()
+ id := c.RemoteAddr().String() + "->" + up.LocalAddr().String()
+ tp.event("%s: open", id)
go func() {
- io.Copy(up, in)
+ n, err := io.Copy(up, in)
+ tp.event("%s: client side ended after %d bytes up: %v", id, n, err)
up.(*net.TCPConn).CloseWrite()
}()
buf := make([]byte, 32<<10)
+ var total int
for {
n, err := up.Read(buf)
if n > 0 {
+ total += n
tp.mu.Lock()
tp.down = append(tp.down, time.Now())
tp.mu.Unlock()
if _, werr := c.Write(buf[:n]); werr != nil {
+ tp.event("%s: write to client after %d bytes down: %v", id, total, werr)
return
}
}
if err != nil {
+ tp.event("%s: upstream side ended after %d bytes down: %v", id, total, err)
return
}
}
@@ -505,6 +529,11 @@ func checkProgressAtTheCLI(t *testing.T, e *dbfE2E, tap *dbfTap, atLeast time.Du
err = cmd.Wait()
end := time.Now()
if err != nil || out.String() != "n\n3\n" {
+ // One t.Logf per line: the CI gate's summary keeps only lines
+ // carrying the test file's prefix.
+ for _, line := range strings.Split(tap.trace(), "\n") {
+ t.Logf("tap: %s", line)
+ }
t.Fatalf("%q %v\n%s", out.String(), err, strings.Join(stderr, "\n"))
}
if reading.IsZero() || reading.Sub(start) > time.Second {
diff --git a/internal/edge/demo_api_integration_test.go b/internal/edge/demo_api_integration_test.go
index 68cac3fdd..b36551e0a 100644
--- a/internal/edge/demo_api_integration_test.go
+++ b/internal/edge/demo_api_integration_test.go
@@ -369,13 +369,23 @@ func TestDemoAPIAliasStreaming(t *testing.T) {
defer cancel()
req, _ := http.NewRequestWithContext(ctx, "POST", origin+"/api/demo/apps", pr)
req.Header.Set("X-Carlos-Client", "cancel")
- done := make(chan error, 1)
+ // A cancelled upload never succeeds. Do returns the
+ // cancellation, or the edge's refusal of the broken upload
+ // when that response reached the client first: Transport
+ // may return a response already in flight instead (#897).
+ type answer struct {
+ status int
+ err error
+ }
+ done := make(chan answer, 1)
go func() {
resp, err := client.Do(req)
+ a := answer{err: err}
if resp != nil {
+ a.status = resp.StatusCode
resp.Body.Close()
}
- done <- err
+ done <- a
}()
if _, err := pw.Write([]byte("x")); err != nil {
t.Fatal(err)
@@ -388,9 +398,9 @@ func TestDemoAPIAliasStreaming(t *testing.T) {
cancel()
pw.CloseWithError(context.Canceled)
select {
- case err := <-done:
- if err == nil {
- t.Fatal("cancel succeeded")
+ case a := <-done:
+ if a.err == nil && a.status != http.StatusServiceUnavailable {
+ t.Fatalf("cancel succeeded: %d", a.status)
}
case <-time.After(3 * time.Second):
t.Fatal("client ignored cancellation")
diff --git a/internal/host/hadepartures_scan_test.go b/internal/host/hadepartures_scan_test.go
index a9a003f83..27c4d03d7 100644
--- a/internal/host/hadepartures_scan_test.go
+++ b/internal/host/hadepartures_scan_test.go
@@ -79,7 +79,12 @@ func (l *scanLog) dumpOnFailure(t *testing.T) {
}
l.mu.Lock()
defer l.mu.Unlock()
- t.Logf("controller log (%d lines):\n%s", len(l.lines), strings.Join(l.lines, "\n"))
+ // One t.Logf per line: the CI gate's summary keeps only lines
+ // carrying the test file's prefix.
+ t.Logf("controller log (%d lines):", len(l.lines))
+ for _, line := range l.lines {
+ t.Logf(" %s", line)
+ }
})
}