Hold the filter module to replacing the stock unit's flushing stop (hq ADR 0100)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package catalogue
|
package catalogue
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -34,12 +35,13 @@ func TestTheStoreAndTheBrokerSayWhatTheMeshGuards(t *testing.T) {
|
|||||||
|
|
||||||
func TestTheFilterModuleNeverFlushesTheRuleset(t *testing.T) {
|
func TestTheFilterModuleNeverFlushesTheRuleset(t *testing.T) {
|
||||||
m := catalogueManifest(t, "nftables")
|
m := catalogueManifest(t, "nftables")
|
||||||
var unit map[string]any
|
var unit, stock, load map[string]any
|
||||||
var load map[string]any
|
|
||||||
for _, r := range m.Resources {
|
for _, r := range m.Resources {
|
||||||
switch r["id"] {
|
switch r["id"] {
|
||||||
case "unit":
|
case "unit":
|
||||||
unit = r
|
unit = r
|
||||||
|
case "stock-unit-stop":
|
||||||
|
stock = r
|
||||||
case "load":
|
case "load":
|
||||||
load = r
|
load = r
|
||||||
}
|
}
|
||||||
@@ -60,7 +62,16 @@ func TestTheFilterModuleNeverFlushesTheRuleset(t *testing.T) {
|
|||||||
t.Fatalf("the unit does not load the computed rule set and delete only its own table:\n%s",
|
t.Fatalf("the unit does not load the computed rule set and delete only its own table:\n%s",
|
||||||
content)
|
content)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(load["restart-on"], []any{"filtering", "unit"}) {
|
// A node converged before the filter had its own unit still has the stock nftables.service
|
||||||
t.Fatalf("the filter is not reloaded when its rules or its unit change: %v", load["restart-on"])
|
// enabled, whose stop flushes the whole ruleset: a drop-in makes it delete only the mesh's
|
||||||
|
// table, and the load is restarted on it so the host reloads units and the drop-in is read.
|
||||||
|
if stock == nil || stock["path"] != "/etc/systemd/system/nftables.service.d/mesh.conf" ||
|
||||||
|
!strings.HasSuffix(fmt.Sprint(stock["content"]),
|
||||||
|
"[Service]\nExecStop=\nExecStop=nft delete table inet mesh\n") {
|
||||||
|
t.Fatalf("the stock unit's stop is not replaced with deleting the mesh's table: %v", stock)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(load["restart-on"], []any{"filtering", "unit", "stock-unit-stop"}) {
|
||||||
|
t.Fatalf("the filter is not reloaded when its rules, its unit or the stock unit's drop-in "+
|
||||||
|
"change: %v", load["restart-on"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user