3e7fcce0b1
build / build (push) Successful in 1m11s
新增迁移50与每5分钟/手动持久同步,API只读本地;同步失败保留、权限阻断、租约与质量失效原子激活。 保留全量稳定分页/固定列,已存质量批量读取,元数据不反复解压长答案;详情安全Markdown与原文。 已运行整仓 make verify、源与副本隔离PG -race、真实只读源及隔离浏览器。 实际同步2525条;固定窗口640条本地中位1.46秒,对照直接源33.10秒。 停worker、缺源凭据、重启API后仍可查询;未更新8088,未修改生产原问答。
54 lines
1.9 KiB
Go
54 lines
1.9 KiB
Go
package dobotaiops
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestMirrorSourceManifestDetectsUpdatesWithoutVolatileTimes(t *testing.T) {
|
|
p := fixturePool(t)
|
|
c := buildReadOnlyClient(t, qaRecordsFixture(t, p))
|
|
ctx := context.Background()
|
|
a, e := c.ReadMirrorManifest(ctx, "default")
|
|
if e != nil || len(a.Keys) != 4 || a.AsOf.IsZero() {
|
|
t.Fatal("full fixed-channel manifest is missing", e, len(a.Keys))
|
|
}
|
|
b, e := c.ReadMirrorManifest(ctx, "default")
|
|
if e != nil || len(b.Keys) != len(a.Keys) {
|
|
t.Fatal(e)
|
|
}
|
|
old := map[string]string{}
|
|
for i, k := range a.Keys {
|
|
old[k.ID] = k.Fingerprint
|
|
if k != b.Keys[i] {
|
|
t.Fatal("source clock alone changed the content fingerprint")
|
|
}
|
|
}
|
|
rows, e := c.ReadMirrorRecords(ctx, "default", []string{"turn-3"})
|
|
if e != nil || len(rows) != 1 || rows[0].Key.Fingerprint != old["turn-3"] {
|
|
t.Fatal("bounded safe payload fetch failed", e)
|
|
}
|
|
before, e := DecodeMirrorPayload(string(rows[0].Payload))
|
|
if e != nil || before.Feedback.Up != 1 || before.Identity.StaffID == "" {
|
|
t.Fatal("safe payload lost required fields", e)
|
|
}
|
|
execFixture(t, p, `UPDATE answer_feedback SET value='down' WHERE id='fb1'`)
|
|
after, e := c.ReadMirrorRecords(ctx, "default", []string{"turn-3"})
|
|
if e != nil || after[0].Key.Fingerprint == old["turn-3"] {
|
|
t.Fatal("feedback update on old question was missed", e)
|
|
}
|
|
rec, _ := DecodeMirrorPayload(string(after[0].Payload))
|
|
if rec.QualityInputHash != before.QualityInputHash {
|
|
t.Fatal("feedback invalidated unrelated human quality input")
|
|
}
|
|
execFixture(t, p, `UPDATE turns SET answer='changed answer' WHERE id='turn-3'`)
|
|
after, e = c.ReadMirrorRecords(ctx, "default", []string{"turn-3"})
|
|
rec, _ = DecodeMirrorPayload(string(after[0].Payload))
|
|
if e != nil || rec.QualityInputHash == before.QualityInputHash {
|
|
t.Fatal("answer change was missed")
|
|
}
|
|
if _, e = c.ReadMirrorRecords(ctx, "default", make([]string, 101)); e == nil {
|
|
t.Fatal("unbounded payload fetch allowed")
|
|
}
|
|
}
|