Read the foundation's ports from each node's settings, wherever a port is used (hq ADR 0100)
This commit is contained in:
@@ -236,3 +236,24 @@ func TestUnassigningReleasesTheModulesPorts(t *testing.T) {
|
||||
t.Fatalf("port 25 is still held in the name of a module that was unassigned: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// novox/hq ADR 0100: a port a node was given for a module is the node's, and the mesh never hands
|
||||
// it to another.
|
||||
func TestAGivenPortIsNeverAssigned(t *testing.T) {
|
||||
inv, node := aNodeWithModules(t, "postgres", "web")
|
||||
ctx := t.Context()
|
||||
if err := inv.SetSettings(ctx, node, "postgres",
|
||||
map[string]any{catalogue.PortsSetting: map[string]any{"5432": 20000}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, err := inv.PortFor(ctx, node, "web", 8080, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got.Machine == 20000 {
|
||||
t.Fatal("a port given to postgres was assigned to web")
|
||||
}
|
||||
if _, err := inv.PortFor(ctx, node, "web", 20000, true); !errors.Is(err, ErrPortTaken) {
|
||||
t.Fatalf("a fixed port given to another module was handed over: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user