H2 owner-pass-with-units-stopped: the module's units and processes stop before the owner pass and start after it

Builds: design 47 H2 H-A-579 (1), H-A-602 (the pass back), H-A-641 (hq 6b8373ce), H-A-701 (hq 95cf2052)
This commit is contained in:
2026-11-25 17:09:52 +01:00
parent 204cd51e4b
commit 9c40b4a3fb
5 changed files with 179 additions and 5 deletions
+10 -4
View File
@@ -15,12 +15,17 @@ func TestStopModuleStopsAModulesUnitsAndContainersAndRemovesNothing(t *testing.T
"app.service": {active: "active", enabled: "enabled"},
"app.timer": {active: "active", enabled: "enabled"},
"other.service": {active: "active", enabled: "enabled"},
// A module's processes stop with it (H-A-641), but the tool runner's own never does.
"app-worker.service": {active: "active", enabled: "enabled"},
"app-rt.service": {active: "active", enabled: "enabled"},
})
state := store.State{}
for _, r := range []store.Applied{
{ID: "app.run", Type: "service", Target: "app.service"},
{ID: "app.tick", Type: "service", Target: "app.timer"},
{ID: "app.c", Type: "container", Target: "app-box"},
{ID: "app.worker", Type: "process", Target: "app-worker"},
{ID: "app.runtime", Type: "process", Target: "app-rt"},
{ID: "other.run", Type: "service", Target: "other.service"},
{ID: "other.c", Type: "container", Target: "other-box"},
} {
@@ -30,16 +35,17 @@ func TestStopModuleStopsAModulesUnitsAndContainersAndRemovesNothing(t *testing.T
if err != nil {
t.Fatal(err)
}
if want := []string{"app.timer", "app.service", "app-box"}; !reflect.DeepEqual(got, want) {
if want := []string{"app.timer", "app.service", "app-worker.service", "app-box"}; !reflect.DeepEqual(got, want) {
t.Fatalf("stopped %v, want %v, the timer first", got, want)
}
if m.units["app.service"].active != "inactive" || m.units["app.timer"].active != "inactive" || m.units["other.service"].active != "active" {
if m.units["app.service"].active != "inactive" || m.units["app.timer"].active != "inactive" || m.units["other.service"].active != "active" ||
m.units["app-worker.service"].active != "inactive" || m.units["app-rt.service"].active != "active" {
t.Fatalf("units are %+v", m.units)
}
if !m.did("docker stop app-box") || m.did("docker stop other-box") || m.did("docker rm") {
t.Fatalf("the machine was asked %v", m.asked)
}
if len(state.Resources) != 5 {
t.Fatalf("a record was removed: %d left", len(state.Resources))
if len(state.Resources) != 7 {
t.Fatalf("a record was removed: %d left of 7", len(state.Resources))
}
}