Clarify process CPU and improve Docker actions
This commit is contained in:
@@ -12,7 +12,7 @@ func TestAgentActionAllowlistAndLifecycle(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer store.Close()
|
||||
report, _ := json.Marshal(AgentReport{Services: []AgentService{{Name: "gitea.service"}}, Containers: []AgentContainer{{ID: "abc123", Name: "gitea"}}})
|
||||
report, _ := json.Marshal(AgentReport{Services: []AgentService{{Name: "gitea.service"}}, Containers: []AgentContainer{{ID: "abc123", Name: "gitea", State: "running"}, {ID: "old123", Name: "old", State: "exited"}}})
|
||||
_, err = store.db.Exec(`INSERT INTO agents(id,name,secret_hash,enrolled_at,last_seen,report_json) VALUES('a','agent','x',?,?,?)`, time.Now().Unix(), time.Now().Unix(), string(report))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -26,9 +26,12 @@ func TestAgentActionAllowlistAndLifecycle(t *testing.T) {
|
||||
if _, err = store.QueueAgentAction("a", "system-update", ""); err != nil {
|
||||
t.Fatalf("system update rejected: %v", err)
|
||||
}
|
||||
action, err := store.QueueAgentAction("a", "systemd-restart", "gitea.service")
|
||||
if _, err = store.QueueAgentAction("a", "docker-remove", "gitea"); err == nil {
|
||||
t.Fatal("running/unknown-state container accepted for removal")
|
||||
}
|
||||
action, err := store.QueueAgentAction("a", "docker-remove", "old")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatalf("stopped container rejected for removal: %v", err)
|
||||
}
|
||||
commands, err := store.DispatchAgentActions("a")
|
||||
if err != nil || len(commands) != 3 || commands[2].ID != action.ID {
|
||||
|
||||
Reference in New Issue
Block a user