E3: compose every setting as the word the one settings reader takes
A module's settings reached its own process only as files its manifest named, and its tools bundles not at all. The node-engine now composes each setting the module declares as MESH_CONFIG_<KEY>, its value as text, into each of its processes' environments and its slice of the tool runner's MESH_TOOL_ENV alike, and the tool runner's own into its process; the runner's drain-bound is a Go duration like every time setting. Builds: design 47 H2 §781; H-A-350 DMC-13, H-A-370, H-A-377
This commit is contained in:
@@ -125,7 +125,11 @@ func TestTheMachineRunsOneRuntimeLoadingEveryDeliveredBundle(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
r := mcat.Resolution{Node: "anchor", Account: "ops", Modules: []mcat.Manifest{nftables, showcase, theRuntime(t)}}
|
||||
// Design 47 H2 §781, H-A-370: a module's settings reach its slice of the runtime's words, and the runtime's own its process.
|
||||
showcase.Settings = map[string]mcat.SettingDeclaration{"greeting": {Kind: mcat.KindPreference, Default: "hello", Why: "polite"}}
|
||||
runner := theRuntime(t)
|
||||
runner.Settings = map[string]mcat.SettingDeclaration{DrainBoundSetting: {Kind: mcat.KindPreference, Default: "30s", Why: "a call's length"}}
|
||||
r := mcat.Resolution{Node: "anchor", Account: "ops", Modules: []mcat.Manifest{nftables, showcase, runner}}
|
||||
out, err := Declaration(r, with)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -146,6 +150,9 @@ func TestTheMachineRunsOneRuntimeLoadingEveryDeliveredBundle(t *testing.T) {
|
||||
"showcase="+mcat.BundleRoot+"/showcase/code/tools/index.js" {
|
||||
t.Errorf("the runtime is told to serve %q: every loaded file, by module, and nothing a bundle runs", env[mcat.RuntimeToolModules])
|
||||
}
|
||||
if env["MESH_CONFIG_DRAIN_BOUND"] != "30s" || env[mcat.RuntimeToolEnv] != `{"showcase":{"MESH_CONFIG_GREETING":"hello"}}` {
|
||||
t.Errorf("the settings reach the runtime as %q and its served modules as %s", env["MESH_CONFIG_DRAIN_BOUND"], env[mcat.RuntimeToolEnv])
|
||||
}
|
||||
if env[mcat.RuntimeBrokerFile] != "/var/lib/mesh/"+"node-tools"+"/broker" {
|
||||
t.Errorf("the runtime reads its credential at %q, not where the module's own secret is placed", env[mcat.RuntimeBrokerFile])
|
||||
}
|
||||
@@ -168,16 +175,17 @@ func TestTheMachineRunsOneRuntimeLoadingEveryDeliveredBundle(t *testing.T) {
|
||||
if names[len(names)-1] != "node-tools"+"."+RuntimeProcessID() {
|
||||
t.Errorf("the runtime's process is not last: %v", names)
|
||||
}
|
||||
// Design 47 H2 §813 (12), H-A-358: the runtime's process carries the module's drain bound, 30 s where no layer sets it,
|
||||
// the value a layer sets, and a value that is no number of seconds is refused by name.
|
||||
if process["drain-bound"] != DefaultDrainBound {
|
||||
// Design 47 H2 §813 (12), H-A-358, H-A-377: the runtime's process carries the module's drain bound in whole seconds, 30
|
||||
// where no layer sets it, the Go duration a layer sets (part of a second a whole one), and a value that is no duration
|
||||
// above zero is refused by name.
|
||||
if process["drain-bound"] != 30 {
|
||||
t.Errorf("the runtime's process drains for %v, not the default 30 s", process["drain-bound"])
|
||||
}
|
||||
for _, row := range []struct {
|
||||
value any
|
||||
want int
|
||||
words string
|
||||
}{{float64(45), 45, ""}, {"60", 60, ""}, {"soon", 0, "whole number of seconds"}, {float64(0), 0, "above zero"}} {
|
||||
}{{"45s", 45, ""}, {"1500ms", 2, ""}, {"60", 0, "Go duration"}, {float64(45), 0, "Go duration"}, {"0s", 0, "above zero"}} {
|
||||
set := with
|
||||
set.Settings = mcat.SettingsBy{"node-tools": {{From: "mesh", Values: map[string]any{DrainBoundSetting: row.value}}}}
|
||||
out, err := Declaration(r, set)
|
||||
|
||||
Reference in New Issue
Block a user