refactor: use nginx -s reload instead of systemd
- doc: add comment
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
"yms-daemon/internal/transaction"
|
||||
)
|
||||
|
||||
// TestPathOperationReplacesRegularCompatibilityJarAndRestoresIt 验证 pathOperation 能把普通文件形态的
|
||||
// 兼容 JAR 替换为目标软链接,随后又能依据快照恢复为原始普通文件内容。
|
||||
func TestPathOperationReplacesRegularCompatibilityJarAndRestoresIt(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
activePath := filepath.Join(root, "glory-soft-yms.jar")
|
||||
@@ -47,6 +49,8 @@ func TestPathOperationReplacesRegularCompatibilityJarAndRestoresIt(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
// TestResolveCurrentUnitSupportsFirstLegacyMigrationAndTemplateRotation 验证 resolveCurrentUnit 在
|
||||
// 首次从旧版单元迁移和模板单元轮换两种场景下,都能选出当前真正运行的单元。
|
||||
func TestResolveCurrentUnitSupportsFirstLegacyMigrationAndTemplateRotation(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -72,6 +76,8 @@ func TestResolveCurrentUnitSupportsFirstLegacyMigrationAndTemplateRotation(t *te
|
||||
}
|
||||
}
|
||||
|
||||
// TestUnitStopOperationAcceptsSystemdFailedAsStopped 验证 unitStopOperation 的 Inspect 把 systemd 的
|
||||
// failed 状态视为已停止(InspectionApplied),因为旧服务在 JVM 以 SIGTERM 退出后常表现为 failed。
|
||||
func TestUnitStopOperationAcceptsSystemdFailedAsStopped(t *testing.T) {
|
||||
units := &unitStateManager{units: map[string]systemd.Unit{
|
||||
legacyUnit8081: {Name: legacyUnit8081, LoadState: "loaded", ActiveState: "failed"},
|
||||
@@ -86,14 +92,19 @@ func TestUnitStopOperationAcceptsSystemdFailedAsStopped(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// unitStateManager systemd 单元管理器的只读测试替身,仅返回预先配置的单元状态,
|
||||
// 用于隔离 resolveCurrentUnit 与 unitStopOperation 的检查逻辑。
|
||||
type unitStateManager struct {
|
||||
units map[string]systemd.Unit
|
||||
}
|
||||
|
||||
// Inspect 返回指定名称的单元状态。
|
||||
func (m *unitStateManager) Inspect(_ context.Context, name string) (systemd.Unit, error) {
|
||||
return m.units[name], nil
|
||||
}
|
||||
|
||||
// Start 空实现,测试中不涉及启动单元。
|
||||
func (m *unitStateManager) Start(context.Context, string) error { return nil }
|
||||
|
||||
// Stop 空实现,测试中不涉及停止单元。
|
||||
func (m *unitStateManager) Stop(context.Context, string) error { return nil }
|
||||
|
||||
Reference in New Issue
Block a user