Node-engine: a running module without an entry resolves as the newest build its want names
Builds: design 47 G §421, lead answers A-405 and A-407
This commit is contained in:
@@ -259,3 +259,55 @@ func (c *Composer) holdEntry(t *testing.T, module, fp, body string) {
|
||||
}
|
||||
c.keptEnt[fp] = keptEntry{entry: half[fp]}
|
||||
}
|
||||
|
||||
// A-405, A-407: a module the node runs whose wanted build has no entry stands, for resolution alone, as the build its want says
|
||||
// is being built, at the want's fingerprint, so its want stays held; one not running here, or whose want names no newer build the
|
||||
// half holds, stands as its name alone.
|
||||
func TestRunningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) {
|
||||
old := meshcatalogclient.SourcePrefix2 + strings.Repeat("1", 64)
|
||||
newest := meshcatalogclient.SourcePrefix2 + strings.Repeat("2", 64)
|
||||
body := `{"module":"postgres","version":"2"}`
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
runs bool
|
||||
newest string
|
||||
holds bool
|
||||
laid bool
|
||||
wantFp string
|
||||
}{
|
||||
{"runs, newest entry held", true, newest, true, true, old},
|
||||
{"not running here", false, newest, true, false, old},
|
||||
{"names no newer build", true, "", false, false, old},
|
||||
{"newest entry not held", true, newest, false, false, old},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
env := newFakeBus().env()
|
||||
env.Node = "n1"
|
||||
c := New(env)
|
||||
c.mu.Lock()
|
||||
c.wants["postgres"] = meshwants.WantsByWantNodeModuleValue{Fp: old, Newest: tc.newest}
|
||||
c.assignments["n1"] = meshmoduleassigner.Assignments{Node: "n1", Modules: []meshmoduleassigner.PlacedModule{{Module: "postgres"}}}
|
||||
if tc.runs {
|
||||
c.heard = map[string]map[string]heardRun{"n1": {"postgres": {fingerprint: old}}}
|
||||
}
|
||||
c.mu.Unlock()
|
||||
if tc.holds {
|
||||
c.holdEntry(t, "postgres", newest, body)
|
||||
}
|
||||
if got := c.wantedBuilds()[newest]; tc.newest != "" && got {
|
||||
t.Errorf("the newest build is named by a want, want only asked")
|
||||
}
|
||||
c.layModules()
|
||||
c.mu.Lock()
|
||||
m, ok := c.modules["postgres"]
|
||||
raw := c.manifests[m.Manifest]
|
||||
c.mu.Unlock()
|
||||
if !ok || m.Fp2 != tc.wantFp {
|
||||
t.Fatalf("modules[postgres] = %+v (%v), want fingerprint %s", m, ok, tc.wantFp)
|
||||
}
|
||||
if got := strings.Contains(string(raw), `"version":"2"`); got != tc.laid {
|
||||
t.Errorf("manifest of the newest build laid = %v, want %v (%s)", got, tc.laid, raw)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user