feat: complete daemon operations and recovery tooling

This commit is contained in:
2026-08-22 15:34:09 +08:00
parent a0a4a7556a
commit 1abe8df6ee
19 changed files with 1421 additions and 171 deletions
+22
View File
@@ -91,6 +91,28 @@ func TestLoadValidContainerConfiguration(t *testing.T) {
}
}
// TestLoadAcceptsStopGraceSeconds 验证 backend.stop_grace_seconds 配置为合法正整数时
// 能被接受,并解析到 Backend.StopGraceSeconds。
func TestLoadAcceptsStopGraceSeconds(t *testing.T) {
content := strings.Replace(validContainerConfig, "systemctl_path = \"/bin/systemctl\"", "systemctl_path = \"/bin/systemctl\"\nstop_grace_seconds = 45", 1)
config, err := Load(writeConfig(t, content))
if err != nil {
t.Fatalf("load configuration with stop_grace_seconds: %v", err)
}
if config.Backend.StopGraceSeconds == nil || *config.Backend.StopGraceSeconds != 45 {
t.Fatalf("unexpected stop_grace_seconds: %+v", config.Backend.StopGraceSeconds)
}
}
// TestLoadRejectsNonPositiveStopGraceSeconds 验证 backend.stop_grace_seconds 配置为非正整数时被拒绝。
func TestLoadRejectsNonPositiveStopGraceSeconds(t *testing.T) {
content := strings.Replace(validContainerConfig, "systemctl_path = \"/bin/systemctl\"", "systemctl_path = \"/bin/systemctl\"\nstop_grace_seconds = 0", 1)
_, err := Load(writeConfig(t, content))
if err == nil || !strings.Contains(err.Error(), "backend.stop_grace_seconds") {
t.Fatalf("expected stop_grace_seconds rejection, got %v", err)
}
}
// TestLoadRejectsChangedContainerName 验证容器槽位的 container_name 被篡改时会被拒绝,
// 且错误信息精确指向 backend.slot.8081.container_name 字段。
func TestLoadRejectsChangedContainerName(t *testing.T) {