41 lines
1.8 KiB
Go
41 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
// Issue 1638 (novox/hq ADR 0480 clause 7), taken in with mesh-sdk's container `groups`: the controller sends a container's
|
|
// groups only to a node-engine that reports the capability container-groups, and holds the module on any other, naming it.
|
|
|
|
const n8nWithAGroup = `{"module":"n8n","version":"1",
|
|
"config":{"media-gid":{"type":"number","minimum":1,"required":true,"description":"the group that owns the media library"}},
|
|
"resources":[{"id":"server","type":"container","name":"n8n",
|
|
"image":"n8nio/n8n@sha256:4846eb2f4b874ab04cde7fc1e249d2ddaec66e9aea64439beb2972cfea88e3c0",
|
|
"groups":["${config:media-gid}"]}]}`
|
|
|
|
// 1638/AC1: a node that reports the capability gets the module; one that does not has it held, the capability named.
|
|
func TestAModuleWithGroupsIsHeldOnANodeThatDoesNotReportTheCapability(t *testing.T) {
|
|
m, err := catalogue.ParseManifest([]byte(n8nWithAGroup))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
shelf := catalogue.Shelf{"n8n": m}
|
|
reads := catalogue.Node{Name: "ace", Capabilities: map[string]bool{"container-runtime": true, "container-groups": true}}
|
|
old := catalogue.Node{Name: "g14", Capabilities: map[string]bool{"container-runtime": true}}
|
|
|
|
got, err := catalogue.Resolve(shelf, []string{"n8n"}, reads, catalogue.World{})
|
|
if err != nil || len(got.Unhostable) != 0 || len(got.Modules) != 1 {
|
|
t.Fatalf("a node that reads groups: %v, held %+v", err, got.Unhostable)
|
|
}
|
|
|
|
got, err = catalogue.Resolve(shelf, []string{"n8n"}, old, catalogue.World{})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(got.Modules) != 0 || len(got.Unhostable) != 1 {
|
|
t.Fatalf("n8n was sent to a node that does not report container-groups: hosted %d, held %+v", len(got.Modules), got.Unhostable)
|
|
}
|
|
}
|