test(gossip): pilot for component tests #1744
All Vouch review confidence checks passed
Residual risk 0.35 = Change Risk (0.59) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1744"
general
weight: 0.35
ajw221
Summary
Goal of this PR is to establish some patterns for component tests (using gossip as a testing pilot target).
Additionally I have added a writeup to this PR description to start organizing ideas and patterns for testing and observability, I think it can evolve into a
testing.mdtype of document. The goal of this writeup is to record ideas and solutions for testing and observability that are not immediately obvious or apparent from the code, and to help establish a style and pattern of testing.Main Changes for Tests
TestNode, an in-processGossipNodeharness with deterministic identity, simulated time, captured outgoing packets, captured snapshot sources, reset support, and invariant checks.TestMetricStorefor allocator-backed metric registration and reset without exposing or running a complete telemetry region. This allows for reading and asserting metric values.lib.gossip.testinghelpers for deterministic keypairs, signed gossip values, message encoding, and decoding. These are shared by component, fuzz, and black-box tests.GossipNodecapacity limits so component tests can use smaller fixed-buffer allocations.unit-teststep and documented unit, black-box, filtered, and fuzz test commands in README.md.Adjacent Changes
gossip/bincode.zig; gossip now usesv2/lib/solana/bincode.zig.u64time parameters and local values with an_mssuffix. Serialized gossip protocol fields retain their protocol-defined names.EntryInfo.fromData().Variant.get()for metric assertions.Known Future TODO
Testing Writeup
Categories of Tests
Unit Tests
Component Tests
- Externally how is the component utilized and interacted with: inputs -> outputs and expected behavior.
- Internally what are the control flow paths and invariants of internal state.
Blackbox (Service) Tests
System Tests
Fuzzing
Asserts and Alerts
Asserts
Logged Alerts
Logged alerts are labeled logs that are easy to match in observability tools to trigger an alert. A labeled alert allows for the developer on the code side of things reason about producing an event that should be noisy to observers.
The value of an alert based on a labeled log is they can be reasoned about and maintained solely in the code, and they are single point events with unique messages/payload. This is in contrast to metrics based alerts which are created by queries on counts, gauges, histograms, etc. These queries are outside of the code and operate on aggregations.
Logged alerts do not replace asserts or metric query based alerts in grafana (or other tools). Logged alerts should only be considered when an assert or metric alert is inadequate or unwieldy. Examples:
Initial thinking is there are two kinds of alerts, categorized by audience:
devandoperator.An
operatoralert is something a node operator would want to be informed of. It would indicate something an operator has control of, for example disk space, network access, etc.A
devalert indicates an unexpected control flow or state was detected, but the code may handle the circumstance gracefully (should not crash the process).devalert even if the code handles it gracefully to ensure it is reviewed, the code is correct, and documented (the alert should either be removed with comment for how it's possible and handled properly, or if it's a bug then the bug should be fixed). This is much better than a silent continuation (especially given it could indicate a bug).operatoralerts are useful for things that may be caused by the environment the node is running in.operatoralert on first failure. E.g., it's expected that network IO can fail intermittently, only after some threshold should an alert be produced (for this case it's likely a metric query is more adequate).devalerts should always cause tests to fail, they indicate unexpected control flow or state and even if harmless indicate a bug according to reasoning.operatoralerts should cause tests to fail unless the alert path is being tested.