console: each tenant's forwarded read gets its own rows, a gate witness for the prefix mutation (plan 2, Task 14)
The plan's witness for 'the agent opens a prefix from anything but the record' was TestDBForwardMinio alone, which runs only in CI's MinIO step; plan 1's parity test reads one host and stayed green under it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+31
−0
internal/console/apidbforward_test.go+31 −0
diff --git a/internal/console/apidbforward_test.go b/internal/console/apidbforward_test.go| index 96048bf23..71a7eb8af 100644 |
| --- a/internal/console/apidbforward_test.go |
| +++ b/internal/console/apidbforward_test.go |
| @@ -16,6 +16,7 @@ import ( |
| "net" |
| "net/http" |
| "net/http/httptest" |
| + "path/filepath" |
| "slices" |
| "strings" |
| "sync" |
| @@ -666,6 +667,36 @@ func TestDBReadStreamsAQueryEndToEnd(t *testing.T) { |
| } |
| } |
| +// T1's second tenant, locally (spec §11.4: the host or prefix taken from |
| +// anywhere but the record): two instances in uk, each with its own replica |
| +// at the prefix the box derives for it, served in turn by one box. Each read |
| +// gets its own rows. Mutation: the agent opens the first host it ever |
| +// checked (red: the second read gets the first instance's rows). |
| +// TestDBForwardMinio makes the same check against real S3 with per-region |
| +// credentials, in CI's MinIO step. |
| +func TestDBReadEachTenantGetsItsOwnRows(t *testing.T) { |
| + fx := newDBFFixture(t, true) |
| + const other = "other.example.com" |
| + putShopRecord(t, fx.consoleFixture, provision.Record{Host: other, Region: "uk", CreatedAt: time.Date(2026, 9, 1, 0, 0, 0, 0, time.UTC)}) |
| + root := t.TempDir() |
| + dbdoortest.Replicate(t, filepath.Join(root, "instances", dbfHost), 3) |
| + dbdoortest.Replicate(t, filepath.Join(root, "instances", other), 1) |
| + box := dbreadstest.Start(t, dbreadstest.Options{Store: fx.rel, Region: "uk", Box: "uk-1", Pub: fx.pub, HibernatePrefix: "instances", |
| + OpenReplica: func(_ context.Context, prefix string) (dbdoor.ReplicaReader, error) { |
| + return lsfile.NewReplicaClient(filepath.Join(root, prefix)), nil |
| + }}) |
| + runBox(t, box) |
| + for _, c := range []struct{ host, want string }{{dbfHost, "n\n30\n"}, {other, "n\n10\n"}} { |
| + body, key := queryBody(t, "SELECT count(*) AS n FROM t") |
| + res := fx.openRead(t, c.host, fx.member, body) |
| + lines := readLines(t, res.Body) |
| + res.Body.Close() |
| + if rows, _ := openAnswer(t, key, lines); string(rows) != c.want { |
| + t.Fatalf("%s: %q, want %q", c.host, rows, c.want) |
| + } |
| + } |
| +} |
| + |
| // No box: wait lines while the console waits, then ended not-picked after |
| // the pickup window, a cancel, and the slot free again. |
| func TestDBReadEndsNotPickedAndCancels(t *testing.T) { |