-
-
Notifications
You must be signed in to change notification settings - Fork 0
Test Suite 2 — Aggregation functions
| Harness function |
suite2() in test-scripts/test-harness.js
|
| Checks | 9 (the # column below reconciles) |
| Kind | Synchronous |
Proves every numeric aggregation function against known values,
including the trimmed mean's named fallback. Each scenario builds a
fresh node with the function under test and a trigger value of 10000
(so the latch never interferes), feeds one reading per source, and
reads the aggregate back via a query snapshot.
Baseline config (applies unless a scenario says otherwise): plain numeric node — Above-mode, trigger 10000, quorum and staleness disabled, Emit aggregate on change only checked, heartbeat off, persistence off; aggregation function per scenario.
Traceability convention: the Check column is the harness's literal PASS/FAIL string — a failing line in the test output can be searched in this document verbatim. This document moves with the harness: a new, renamed, or removed check lands here in the same change.
One reading per source, aggregate read via query.
| # | Check | Protects |
|---|---|---|
| 1 | mean of 10,20,30 |
Arithmetic mean over fresh sources (expected 20) |
| 2 | median odd count 10,90,20 |
Median with an odd count picks the middle value (20), robust to the 90 outlier |
| 3 | median even count 10,20,30,40 |
Median with an even count averages the two middle values (25) |
| 4 | min of 7,3,9 |
Min for worst-case-style automations (3) |
| 5 | max of 7,3,9 |
Max for worst-case-style automations (9) |
Three sources, then only two.
| # | Check | Protects |
|---|---|---|
| 6 | trimmed mean drops high+low (10,50,90 -> 50) |
Trimmed mean drops the single highest and lowest fresh value |
| 7 | trimmed mean reports its name |
msg.aggregation names the function actually used (trimmedmean) |
| 8 | trimmed mean <3 sources falls back to mean |
Below 3 fresh sources the node silently falls back to mean (10,50 → 30) — never fails, never goes silent |
| 9 | fallback is named in the envelope |
The fallback is honest: msg.aggregation reports mean(fallback), not trimmedmean
|
Getting Started
Reference
Features
Examples
- Examples Basic Numeric Averaging
- Examples Staleness and Quorum
- Examples Boolean Voting
- Examples Runtime Commands
Test Script Coverage
- Overview
- Test Suite 1 — Output routing & envelope shape
- Test Suite 2 — Aggregation functions
- Test Suite 3 — Boolean mode
- Test Suite 4 — Commands
- Test Suite 5 — Threshold set-commands & release-follows-trigger
- Test Suite 6 — Status labels
- Test Suite 7 — Staleness, quorum policies, heartbeat
- Test Suite 8 — Persistence
Support