Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude/specs/statusngin_statechanges.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"host_name": "localhost",
"service_description": "Flapping",
"output": "Your random value is: 158",
"long_output": "Your random value is: 158",
"long_output": "Your random value is: 158\nThis line only appears in the long output.",
"statechange_type": 1,
"state": 0,
"state_type": 1,
Expand All @@ -30,7 +30,7 @@
"host_name": "demo.statusengine.org",
"service_description": "Flapping",
"output": "Your random value is: 87",
"long_output": "Your random value is: 87",
"long_output": "Your random value is: 87\nThis line only appears in the long output.",
"statechange_type": 1,
"state": 0,
"state_type": 0,
Expand Down
8 changes: 6 additions & 2 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,11 @@ components:
type: string
description: Empty for a host state change (see statechange_type).
output: { type: string }
long_output: { type: string }
long_output:
type: string
description: >
The object's long plugin output, not a copy of `output`. Empty
when the object has none, matching the host/service check queues.
statechange_type:
type: integer
description: "0 = host state change, 1 = service state change."
Expand All @@ -679,7 +683,7 @@ components:
host_name: localhost
last_hard_state: 1
last_state: 1
long_output: "Your random value is: 158"
long_output: "Your random value is: 158\nThis line only appears in the long output."
max_attempts: 4
output: "Your random value is: 158"
service_description: Flapping
Expand Down
6 changes: 6 additions & 0 deletions internal/queue/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ func TestDecodeBulkQueues(t *testing.T) {
if len(events) != 2 || events[0].Timestamp != 1785470683 || events[0].ServiceDescription != "Flapping" {
t.Fatalf("unexpected events: %+v", events)
}
// The broker sends the real long output for state changes, not a copy
// of output. The fixture's value is deliberately different from its
// output, so a decoder that dropped the field would fail here.
if want := "Your random value is: 158\nThis line only appears in the long output."; events[0].LongOutput != want {
t.Fatalf("events[0].LongOutput = %q, want %q", events[0].LongOutput, want)
}
})

t.Run("LogEntry", func(t *testing.T) {
Expand Down
13 changes: 13 additions & 0 deletions internal/queue/statechange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ func TestHostStateHistoryRowAndServiceStateHistoryRowColumns(t *testing.T) {
}
ev := items[0]

// The fixture's long_output differs from output on purpose: the broker
// sends the real long output now, and the row assertions below have to
// catch a dropped field rather than a value that merely mirrors output.
if ev.LongOutput == "" || ev.LongOutput == ev.Output {
t.Fatalf("fixture long_output = %q, want a distinct non-empty long output", ev.LongOutput)
}

hostRow := hostStateHistoryRow(ev, nil)
if len(hostRow) != 12 {
t.Fatalf("hostStateHistoryRow has %d values, want 12", len(hostRow))
Expand All @@ -87,6 +94,9 @@ func TestHostStateHistoryRowAndServiceStateHistoryRowColumns(t *testing.T) {
t.Fatalf("hostStateHistoryRow[0:4] = %v, want [%v %v %v %v]",
hostRow[0:4], ev.HostName, ev.Timestamp, ev.TimestampUsec, ev.StateChangeType)
}
if hostRow[11] != ev.LongOutput {
t.Fatalf("hostStateHistoryRow[11] = %v, want LongOutput %q", hostRow[11], ev.LongOutput)
}

serviceRow := serviceStateHistoryRow(ev, nil)
if len(serviceRow) != 13 {
Expand All @@ -98,4 +108,7 @@ func TestHostStateHistoryRowAndServiceStateHistoryRowColumns(t *testing.T) {
if serviceRow[3] != ev.HostName || serviceRow[4] != ev.StateChangeType {
t.Fatalf("serviceStateHistoryRow[3:5] = %v, want [%v %v]", serviceRow[3:5], ev.HostName, ev.StateChangeType)
}
if serviceRow[12] != ev.LongOutput {
t.Fatalf("serviceStateHistoryRow[12] = %v, want LongOutput %q", serviceRow[12], ev.LongOutput)
}
}
Loading