panel-redesign: three things the first look at the deployed panel showed
Seen by the owner on the test server, on real data (2026-10-10).
- Overview's Processes card said "7 of 7 running" with six programs
running and postfix-reload idle. The card counts the programs that
are meant to stay up; a one-shot helper (health.Process.OneShot) is
left out of both numbers and named only when it is in trouble.
- The Milter sockets card clipped its second line ("OpenDKIM,
send-log,...") once the spam filter was the third socket. The line
names the sockets that do not answer when some do not; with all
answering it is their names, or "incl. the spam filter" - the
mockup's words - when the filter is among them.
- A real 2048-bit DKIM value did not fit the three rows of its field
and scrolled inside it. The field is as tall as the value needs
(3 to 12 rows).
The fixtures had a shortened key, two sockets and no one-shot program,
so none of this showed in the evidence screenshots.
go test -count=1 ./internal/health/... ./internal/web/...: ok
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -92,7 +92,7 @@ func TestFilterOnAnsweringIsTheThirdSocket(t *testing.T) {
|
||||
}
|
||||
}
|
||||
card := socketCard(t, h)
|
||||
if card.Value != "3 of 3 answering" || card.Sub != "OpenDKIM, send-log, Spam filter" || card.Level != "" {
|
||||
if card.Value != "3 of 3 answering" || card.Sub != "incl. the spam filter" || card.Level != "" {
|
||||
t.Errorf("card = %+v", card)
|
||||
}
|
||||
|
||||
|
||||
@@ -245,15 +245,22 @@ func healthCards(c map[string]any) []view.HealthCard {
|
||||
ram = "RAM " + machine.Memory.PctText()
|
||||
}
|
||||
|
||||
running, notRunning := 0, []string{}
|
||||
// The count is of the programs that are meant to stay up. A one-shot helper
|
||||
// (postfix-reload) idles between runs: it is not "running" and not missing,
|
||||
// so it is left out of both numbers and named only when it is in trouble.
|
||||
running, expected, notRunning := 0, 0, []string{}
|
||||
for _, p := range procs {
|
||||
if p.Status == health.StatusOK {
|
||||
running++
|
||||
} else {
|
||||
if !p.OneShot {
|
||||
expected++
|
||||
if p.Status == health.StatusOK {
|
||||
running++
|
||||
}
|
||||
}
|
||||
if p.Status != health.StatusOK {
|
||||
notRunning = append(notRunning, p.Name)
|
||||
}
|
||||
}
|
||||
procValue, procSub := fmt.Sprintf("%d of %d running", running, len(procs)), "all programs"
|
||||
procValue, procSub := fmt.Sprintf("%d of %d running", running, expected), "all programs"
|
||||
if len(notRunning) > 0 {
|
||||
procSub = strings.Join(notRunning, ", ")
|
||||
}
|
||||
@@ -271,13 +278,28 @@ func healthCards(c map[string]any) []view.HealthCard {
|
||||
queueValue = "Could not be read"
|
||||
}
|
||||
|
||||
answering, socketNames := 0, make([]string, 0, len(sockets))
|
||||
// The line under the count has to fit a card: the sockets that do not
|
||||
// answer when some do not; otherwise their names, or - with the inbound spam
|
||||
// filter among them, when three names no longer fit - that it is included.
|
||||
answering, socketNames, silent, withFilter := 0, make([]string, 0, len(sockets)), []string{}, false
|
||||
for _, s := range sockets {
|
||||
if s.Present {
|
||||
answering++
|
||||
} else {
|
||||
silent = append(silent, s.Name)
|
||||
}
|
||||
if s.Note != "" {
|
||||
withFilter = true
|
||||
}
|
||||
socketNames = append(socketNames, s.Name)
|
||||
}
|
||||
socketSub := strings.Join(socketNames, ", ")
|
||||
switch {
|
||||
case len(silent) > 0:
|
||||
socketSub = strings.Join(silent, ", ")
|
||||
case withFilter:
|
||||
socketSub = "incl. the spam filter"
|
||||
}
|
||||
|
||||
ptrValue := "Forward = reverse"
|
||||
if ptr.Status != health.StatusOK {
|
||||
@@ -293,7 +315,7 @@ func healthCards(c map[string]any) []view.HealthCard {
|
||||
card("TLS certificate", "ti-certificate", "/server/health#certificate", cert.Status, certValue, cert.Subject),
|
||||
card("Queue", "ti-stack-2", "/outbound/queue", c["QueueStatus"].(health.Status), queueValue, "outbound"),
|
||||
card("Milter sockets", "ti-plug-connected", "/server/health#sockets", c["SocketStatus"].(health.Status),
|
||||
fmt.Sprintf("%d of %d answering", answering, len(sockets)), strings.Join(socketNames, ", ")),
|
||||
fmt.Sprintf("%d of %d answering", answering, len(sockets)), socketSub),
|
||||
card("Reverse DNS", "ti-arrows-exchange", "/server/health#hostname", ptr.Status, ptrValue, c["Hostname"].(string)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestHealthCards(t *testing.T) {
|
||||
{"Processes", "fail", "1 of 2 running", "postfix", "/server/health#processes"},
|
||||
{"TLS certificate", "warn", "Expires in 12 days", "mail.example.org", "/server/health#certificate"},
|
||||
{"Queue", "", "Empty", "outbound", "/outbound/queue"},
|
||||
{"Milter sockets", "warn", "1 of 2 answering", "OpenDKIM, send-log", "/server/health#sockets"},
|
||||
{"Milter sockets", "warn", "1 of 2 answering", "send-log", "/server/health#sockets"},
|
||||
{"Reverse DNS", "", "Forward = reverse", "mail.example.org", "/server/health#hostname"},
|
||||
}
|
||||
if len(cards) != len(want) {
|
||||
@@ -80,3 +80,28 @@ func TestQueueCardValue(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The Processes card counts the programs that are meant to stay up. The one-shot
|
||||
// reload helper idles between runs: it is neither running nor missing.
|
||||
func TestProcessesCardLeavesOutTheIdleOneShot(t *testing.T) {
|
||||
c := checksFixture()
|
||||
c["Processes"] = []health.Process{
|
||||
{Name: "opendkim", State: "RUNNING", Status: health.StatusOK},
|
||||
{Name: "postfix", State: "RUNNING", Status: health.StatusOK},
|
||||
{Name: "postfix-reload", State: "STOPPED", Status: health.StatusOK, OneShot: true},
|
||||
}
|
||||
c["ProcessStatus"] = health.StatusOK
|
||||
card := healthCards(c)[1]
|
||||
if card.Value != "2 of 2 running" || card.Sub != "all programs" {
|
||||
t.Errorf("card = %q / %q, want 2 of 2 running / all programs", card.Value, card.Sub)
|
||||
}
|
||||
|
||||
c["Processes"] = []health.Process{
|
||||
{Name: "opendkim", State: "RUNNING", Status: health.StatusOK},
|
||||
{Name: "postfix-reload", State: "FATAL", Status: health.StatusError, OneShot: true},
|
||||
}
|
||||
card = healthCards(c)[1]
|
||||
if card.Value != "1 of 1 running" || card.Sub != "postfix-reload" {
|
||||
t.Errorf("card = %q / %q, want 1 of 1 running / postfix-reload", card.Value, card.Sub)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user