package host import ( "testing" "github.com/carlosframework/platform/internal/cgroup" "github.com/carlosframework/platform/internal/hostguard" ) // Final review round 1, merge item 8: internal/cgroup's retaining setup // leaves claim containment groups alone (it seeds and sweeps around them, // flag off included), and it knows them only by their name. The name's // format has one definition, in internal/cgroup, and every name this // package makes must read as one there, both as the containment's host name // and as its exec cgroup's directory name. A plain host never does. func TestClaimContainmentNamesAreRecognisedByTheCgroupPackage(t *testing.T) { for _, target := range []hostguard.FenceTarget{ {}, {Host: "a.example.com", Incarnation: "inc-1", Stamp: 3, Session: 9, Box: "box-1", Enrollment: "e", BootID: "boot", ControllerID: "ctl"}, {Host: "claim-x.local", Incarnation: "inc-2", Stamp: 1, Session: 1, Box: "box-2"}, } { name := claimContainmentName(target) if !cgroup.IsClaimContainment(name) { t.Fatalf("cgroup.IsClaimContainment(%q) = false for a claim containment name", name) } if !cgroup.IsClaimContainment(cgroup.ExecName(name)) { t.Fatalf("cgroup.IsClaimContainment(%q) = false for its exec cgroup", cgroup.ExecName(name)) } } for _, plain := range []string{"a.example.com", cgroup.ExecName("a.example.com"), "claim-a.example.com", "x.local"} { if cgroup.IsClaimContainment(plain) { t.Fatalf("cgroup.IsClaimContainment(%q) = true for a name that is not a claim containment's", plain) } } }