Keep the builder's history as its own log that readers declare and follow, the memberships as the grants part's state, and refuse a module's own stream, so every module's data is in the bus's predefined forms and readable by its tools (issue 1955, ADR 0571 clauses 1, 4, 5, 7)
This commit is contained in:
@@ -274,6 +274,44 @@ func TestStateWatchOnAGrantedBucket(t *testing.T) {
|
||||
t.Fatalf("narrowed watch got %+v for a key it did not name", c)
|
||||
case <-time.After(500 * time.Millisecond):
|
||||
}
|
||||
|
||||
// ADR 0571 clause 1: another module's log, read on the process's own credential with exactly the read grants: the
|
||||
// newest per key, every entry from a time, and a watch from the newest that then hears an appended entry.
|
||||
if _, err := adminJetStream.CreateStream(ctx, jetstream.StreamConfig{Name: "LOG_mesh-delivery-builder_build-log",
|
||||
Subjects: []string{"mesh.log.mesh-delivery-builder.build-log.>"}, AllowDirect: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, k := range []string{"letta", "gitea", "letta"} {
|
||||
if _, err := adminJetStream.Publish(ctx, "mesh.log.mesh-delivery-builder.build-log."+k, []byte(`{"module":"`+k+`"}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
}
|
||||
builds := conn.ReadLog("mesh-delivery-builder", "build-log")
|
||||
newest, err := builds.Newest("")
|
||||
if err != nil || len(newest) != 2 || newest[0].Key != "gitea" || newest[1].Sequence != 3 {
|
||||
t.Fatalf("the newest per key are %+v: %v", newest, err)
|
||||
}
|
||||
since, err := builds.Since(newest[0].At, "letta")
|
||||
if err != nil || len(since) != 1 || since[0].Sequence != 3 {
|
||||
t.Fatalf("letta since gitea's build is %+v: %v", since, err)
|
||||
}
|
||||
heard := make(chan stdio.LogEntry, 4)
|
||||
if err := builds.Watch("letta", stdio.LogFromNewest, func(e stdio.LogEntry) error { heard <- e; return nil }); err != nil || len(heard) != 1 {
|
||||
t.Fatalf("a watch from the newest handed %d at its start: %v", len(heard), err)
|
||||
}
|
||||
<-heard
|
||||
if _, err := adminJetStream.Publish(ctx, "mesh.log.mesh-delivery-builder.build-log.letta", []byte(`{}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
select {
|
||||
case e := <-heard:
|
||||
if e.Sequence != 4 || e.Key != "letta" {
|
||||
t.Fatalf("the watch heard %+v", e)
|
||||
}
|
||||
case <-time.After(10 * time.Second):
|
||||
t.Fatal("the watch did not hear the appended entry")
|
||||
}
|
||||
}
|
||||
|
||||
// 1840/AC8: given an account not granted a bucket, when it watches it, then the refusal names the bucket.
|
||||
|
||||
Reference in New Issue
Block a user