上一次窗口写下的 StopRequested 只是历史,写入者被人工拉起来后必须再停一次, 否则恢复校验会跑在半开的目标上。补一条回归测试。
This commit is contained in:
@@ -325,3 +325,33 @@ func TestWindowRefusesWhenGateNotDrained(t *testing.T) {
|
||||
t.Fatalf("writers were stopped before the ingress was drained: %v", c.calls)
|
||||
}
|
||||
}
|
||||
|
||||
// 窗口开过之后被人工拉起来的写入者,恢复时必须再停一次:
|
||||
// 上一次窗口写下的 StopRequested 不能当成"它现在还停着"。
|
||||
func TestStopAllStopsWriterRestartedAfterWindowOpened(t *testing.T) {
|
||||
_, c, engine := instanceFixture(t)
|
||||
j := journal{Version: 1, Source: "target-instance", Job: "job-restart",
|
||||
Result: Result{State: "held"}, Level: "instance",
|
||||
Services: []serviceRecord{{Service: Service{ID: "app", Running: true, Healthy: true}, StopRequested: true}}}
|
||||
if err := engine.stopAll(context.Background(), &j); err != nil {
|
||||
t.Fatalf("stopAll: %v", err)
|
||||
}
|
||||
items, err := c.Inventory(context.Background())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, s := range items {
|
||||
if s.ID == "app" && s.Running {
|
||||
t.Fatal("写入者被人工拉起后没有被重新停住")
|
||||
}
|
||||
}
|
||||
found := false
|
||||
for _, call := range c.calls {
|
||||
if call == "stop:app" {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("没有发出停止指令:%v", c.calls)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user