I7 failed-record, I8 pin-drop-record: steps of TestIndexerWhole hold the failed record of an unfinished module, of a kept mover at a cancelled end, its drop by record, and its freeing when the module leaves the registrations
Builds: design 47 H2 H-A-566, H-A-572 (2) (3), H-A-595, H-A-608 (AC-I7a, AC-I7b, AC-I7c, AC-I8; review round 1)
This commit is contained in:
@@ -412,22 +412,23 @@ func absent(v []byte) bool { return v == nil }
|
||||
func TestIndexerWhole(t *testing.T) {
|
||||
const (
|
||||
c10, c11, c12, c13 = "1010101010101010101010101010101010101010", "1111111111111111111111111111111111111111", "1212121212121212121212121212121212121212", "1313131313131313131313131313131313131313"
|
||||
c15, c16 = "1515151515151515151515151515151515151515", "1616161616161616161616161616161616161616"
|
||||
unread = "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef"
|
||||
)
|
||||
var forge *forgeCommits
|
||||
var heard *takeIns
|
||||
var pins, held, takeinsKV, regs, runs, status jetstream.KeyValue
|
||||
var pins, held, takeinsKV, regs, runs, status, heardKV jetstream.KeyValue
|
||||
js, ctx, candidates, _, restart := startIndexerRun(t, func(context.Context, buildLog) {}, func(ctx context.Context, js jetstream.JetStream) {
|
||||
heard = hearTakeIns(t, js.Conn())
|
||||
forge = serveCommits(t, js.Conn())
|
||||
for commit, tree := range map[string]string{c10: "t10", c11: "t11", c12: "t12", c13: "t13"} {
|
||||
for commit, tree := range map[string]string{c10: "t10", c11: "t11", c12: "t12", c13: "t13", c15: "t15", c16: "t16"} {
|
||||
forge.put(commit, catalogueAt(t, tree))
|
||||
}
|
||||
var err error
|
||||
for _, b := range []struct {
|
||||
state string
|
||||
kv *jetstream.KeyValue
|
||||
}{{index.HeldState, &held}, {index.TakeInsState, &takeinsKV}, {index.RunsState, &runs}, {views.StatusState, &status}} {
|
||||
}{{index.HeldState, &held}, {index.TakeInsState, &takeinsKV}, {index.RunsState, &runs}, {views.StatusState, &status}, {index.HeardState, &heardKV}} {
|
||||
if *b.kv, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, b.state), History: 64}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -714,6 +715,69 @@ func TestIndexerWhole(t *testing.T) {
|
||||
t.Errorf("gamma.1 is not kept: %v", err)
|
||||
}
|
||||
|
||||
// Design 47 H2 H-A-566, H-A-572, H-A-595, H-A-608 (AC-I7a, AC-I7b, AC-I7c, AC-I8): a pipeline that ended failed with a module
|
||||
// unfinished pins the revision the module comes from and its base under the module's failed record; a cancelled end of a kept
|
||||
// mover pins its kept revision and that revision's base; the record dropped by hand leaves the pins' other records; a module
|
||||
// that leaves the registrations frees its record.
|
||||
failedRecord := index.FailedRecord("main", "avahi")
|
||||
lacks := func(record string) func([]byte) bool {
|
||||
return func(v []byte) bool {
|
||||
var p index.PinValue
|
||||
return v == nil || (json.Unmarshal(v, &p) == nil && !slices.Contains(p.Records, record))
|
||||
}
|
||||
}
|
||||
endedPipeline := func(pipeline string, revision int64, outcome string, movers []meshpipelinerunner.MoverEnded, unfinished ...string) {
|
||||
t.Helper()
|
||||
raw, _ := json.Marshal(meshpipelinerunner.PipelineEnded{V: 1, Pipeline: pipeline, Branch: "main", Source: revision, Revision: revision,
|
||||
Outcome: outcome, Movers: movers, Unfinished: unfinished})
|
||||
if _, err := js.Publish(ctx, meshpipelinerunner.SubjectPipelineEnded("main", strconv.FormatInt(revision, 10)), raw); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
sayMoved(t, ctx, js, "main", 15, c15, false)
|
||||
take15 := heard.next(t, "main", 15)
|
||||
r15, p15 := take15.Revision, fmt.Sprintf("main.%d", take15.Revision)
|
||||
r14 := r15 - 1
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r15), pinned("pipeline."+p15))
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r14), pinned("pipeline."+p15))
|
||||
endedPipeline(p15, r15, meshpipelinerunner.PipelineEndedOutcomeFailed, nil, "avahi") // AC-I7a: avahi unfinished
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r15), pinned(failedRecord))
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r14), pinned(failedRecord)) // its base
|
||||
sayMoved(t, ctx, js, "main", 16, c16, false)
|
||||
take16 := heard.next(t, "main", 16)
|
||||
r16, p16 := take16.Revision, fmt.Sprintf("main.%d", take16.Revision)
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r15), pinned(failedRecord, "pipeline."+p16)) // main.16's base
|
||||
// AC-I8: indexer_pin_drop with record drops that one record from every pin; the pin holding another record keeps it.
|
||||
pinTools := index.PinsTools(kvStore{pins}, objects, askVia(t, ctx, takeinsKV), time.Now, func(string, string) error { return nil })
|
||||
if _, err := toolNamed(t, pinTools, index.PinDropTool).Run(map[string]any{"record": failedRecord, "why": "the failed mover passed on its own"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r15), pinned("pipeline."+p16))
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r14), lacks(failedRecord))
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r16), pinned("pipeline."+p16))
|
||||
// AC-I7b: a pipeline of main.15 that keeps avahi at main.16 ended cancelled pins main.16 and its base main.15 under the
|
||||
// record, the mover's own entry being where it is kept.
|
||||
again := p15 + ".again"
|
||||
startedAgain, _ := json.Marshal(meshpipelinerunner.PipelineStarted{V: 1, Pipeline: again, Branch: "main", Source: 15, Revision: r15, Kept: []int64{r16}})
|
||||
if _, err := js.Publish(ctx, meshpipelinerunner.SubjectPipelineStarted("main", strconv.FormatInt(r15, 10)), startedAgain); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r16), pinned("pipeline."+p16, "pipeline."+again))
|
||||
endedPipeline(again, r15, meshpipelinerunner.PipelineEndedOutcomeCancelled, []meshpipelinerunner.MoverEnded{{Module: "avahi", Fingerprint: take16.Entries[0].Fingerprint,
|
||||
Steps: []meshpipelinerunner.StepResult{{Step: meshpipelinerunner.StepResultStepUnit, Status: meshpipelinerunner.StepResultStatusRequired, Outcome: meshpipelinerunner.StepResultOutcomeCancelled}}}})
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r16), pinned("pipeline."+p16, failedRecord))
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r15), pinned("pipeline."+p16, failedRecord))
|
||||
// AC-I7c: avahi leaves main's registrations: the record is freed from every pin.
|
||||
reg, _ = json.Marshal(meshcatalog.Registration{V: 1, Module: "avahi", Origin: "novox/mesh-catalog", Path: "modules/avahi", Branches: []string{"beta", "gamma"}})
|
||||
if _, err := regs.Put(ctx, index.RegistrationKey("avahi"), reg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := js.Publish(ctx, meshcatalog.SubjectRegistrationChanged, []byte(`{"module":"avahi"}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r16), lacks(failedRecord))
|
||||
untilKey(t, ctx, pins, index.PinKey("main", r15), lacks(failedRecord))
|
||||
|
||||
// Design 47 H2 §815: a source-only registration, kept under source.<owner>.<name>, watches its branch as any registration
|
||||
// does, and a move of that branch by its repository, which holds no manifest, is taken in with no movers.
|
||||
const hqCommit = "4444444444444444444444444444444444444444"
|
||||
|
||||
Reference in New Issue
Block a user