diff --git a/cmd/mesh-host/nodeagent_integration_test.go b/cmd/mesh-host/nodeagent_integration_test.go index 9ec999b9..6f4e0350 100644 --- a/cmd/mesh-host/nodeagent_integration_test.go +++ b/cmd/mesh-host/nodeagent_integration_test.go @@ -936,7 +936,8 @@ func mustComposedKey(t *testing.T, module, fp string) string { // of it (issue 774): what the bus server's container met is read from it, never from a real runtime. type recordingRuntime struct { mu sync.Mutex - containers map[string]string // name: the spec label it was made with + containers map[string]string // name: the spec label it was made with + envs map[string][]string // name: the env it was made with (--env), as `{{json .Config.Env}}` answers it asked []string } @@ -956,6 +957,10 @@ func (r *recordingRuntime) run(_ context.Context, name string, args ...string) ( if !ok { return "", errors.New("no such container") } + if strings.Contains(strings.Join(args, " "), ".Config.Env") { + raw, _ := json.Marshal(r.envs[args[len(args)-1]]) + return string(raw) + "\n", nil + } return "true\t" + spec + "\n", nil } case "image": @@ -968,18 +973,25 @@ func (r *recordingRuntime) run(_ context.Context, name string, args ...string) ( if spec, ok := r.containers[args[1]]; ok { delete(r.containers, args[1]) r.containers[args[2]] = spec + r.envs[args[2]] = r.envs[args[1]] + delete(r.envs, args[1]) } case "run", "create": var made, spec string + var env []string for i, a := range args { if a == "--name" && i+1 < len(args) { made = args[i+1] } + if a == "--env" && i+1 < len(args) { + env = append(env, args[i+1]) + } if a == "--label" && i+1 < len(args) && strings.HasPrefix(args[i+1], "mesh-host.spec=") { spec = strings.TrimPrefix(args[i+1], "mesh-host.spec=") } } r.containers[made] = spec + r.envs[made] = env return "made\n", nil } return "", nil @@ -1011,7 +1023,7 @@ func (r *recordingRuntime) moved(container string) []string { // backup seat to back it up, as for every module that keeps data, and applies only once the backup says it is done. func TestNatsTheBusServerIsTakenOverAndReplacedOnlyWhenItsBuildChangesIt(t *testing.T) { b := newItBed(t) - runtime := &recordingRuntime{containers: map[string]string{}} + runtime := &recordingRuntime{containers: map[string]string{}, envs: map[string][]string{}} b.opts.runner = runtime.run const server = "mesh-broker-it" conf := filepath.Join(b.dir, "nats.conf") @@ -1025,8 +1037,9 @@ func TestNatsTheBusServerIsTakenOverAndReplacedOnlyWhenItsBuildChangesIt(t *test folded, err := declaration.Parse([]byte(`{"declaration":1,"resources":[` + `{"id":"nats.server-conf","type":"file","path":"` + conf + `","mode":"0644","content":"listen: old\n"},` + `{"id":"nats.server","type":"container","name":"` + server + `","image":"` + image + `",` + - // As the node-engine starts every container since the fingerprint handover (47/G W13.1): the fingerprint of the - // want it applies, here the first want's, so that want changes the server's spec in nothing. + // As the node-engine started every container from the fingerprint handover (47/G W13.1) to H2: the fingerprint of the + // want it applies, here the first want's. A container is handed none since H2, so the first want, which composes + // the server with none, finds its label differing by that value alone and moves nothing (H-A-710 (2)). `"env":{"MESH_FINGERPRINT":"` + fpIt("e") + `"}}]}`)) if err != nil { t.Fatal(err)