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
38 changes: 38 additions & 0 deletions ui/src/model/overview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,44 @@ describe("the overview", () => {
expect(activity[1]).not.toHaveProperty("tone");
});

it("lists the eight latest events across a daemon restart, not the eight with the highest seq", () => {
// why: the console's first load reads the daemon's event file, which survives a restart, so one
// buffer holds the previous run's events beside the restarted counter's own. `seq` restarts with
// every daemon, so only `timestamp` then `seq` orders them (docs/EVENTS.md).
const previousGeneration = [91, 92, 93, 94, 95, 96].map((seq, index) => ({
event: "lease.released",
id: `before-${seq}`,
payload: {},
seq,
timestamp: NOW - (20 - index) * 60_000,
}));
const currentGeneration = [1, 2, 3, 4].map((seq, index) => ({
event: "lease.granted",
id: `after-${seq}`,
payload: {},
seq,
timestamp: NOW - (4 - index) * 60_000,
}));

const { activity } = overviewOf({
events: [...previousGeneration, ...currentGeneration],
now: NOW,
requests: [],
workers: fleet,
});

expect(activity.map((row) => row.key)).toEqual([
"after-4",
"after-3",
"after-2",
"after-1",
"before-96",
"before-95",
"before-94",
"before-93",
]);
});

it("gives each worker its health square, its slots and its load, and a lost worker no load", () => {
const { workers } = overviewOf({ events: [], now: NOW, requests: [], workers: fleet });

Expand Down
2 changes: 1 addition & 1 deletion ui/src/model/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export function overviewOf(input: {
const minutes = held === undefined ? [] : leaseHistory(held, events, now);
return {
activity: [...events]
.sort((a, b) => b.seq - a.seq)
.sort((a, b) => b.timestamp - a.timestamp || b.seq - a.seq)
.slice(0, ACTIVITY_ROWS)
.map((event) => {
const tone = eventTone(event.event);
Expand Down
Loading