test: move the last inline test modules to tests/, document new signals
- All remaining #[cfg(test)] modules left src/ (manager auth/heartbeat, protocol registry and HTTP parser, traffic hook/prefix/profile, TUI Prometheus); 41 tests moved into 10 integration suites with the same names and assertions, so `grep -rn '#[cfg(test)]' src/` is now empty. - runbook.md: degradation signals (overloaded connections, ClickHouse drops, XDP drops, generic mode, EMFILE backoff) and how to verify XDP was detached. - troubleshooting.md: accept backoff, orphaned XDP, password/JWT startup requirements, ClickHouse event loss. - TODO: review round recorded as fixed/deferred.
This commit is contained in:
parent
e456cb583f
commit
da87d2a11f
21 changed files with 600 additions and 521 deletions
41
tests/protocol_registry_contract.rs
Normal file
41
tests/protocol_registry_contract.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
//! Protocol registry contract: an empty registry fails fast at startup and a
|
||||
//! registered handler resolves by name.
|
||||
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
|
||||
use rampart::protocol::{HandshakeResult, ProtocolHandler, ProtocolRegistry, Upstream};
|
||||
use tokio::net::TcpStream;
|
||||
|
||||
struct DummyHandler;
|
||||
|
||||
impl ProtocolHandler for DummyHandler {
|
||||
fn name(&self) -> &'static str {
|
||||
"dummy"
|
||||
}
|
||||
|
||||
fn handshake<'a>(
|
||||
&'a self,
|
||||
_stream: &'a mut TcpStream,
|
||||
) -> Pin<Box<dyn Future<Output = anyhow::Result<HandshakeResult>> + Send + 'a>> {
|
||||
Box::pin(async { Ok(HandshakeResult::new(Upstream::new("127.0.0.1:9000"))) })
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_registry_fails_fast() {
|
||||
let registry = ProtocolRegistry::new();
|
||||
assert!(registry.is_empty());
|
||||
assert!(registry.primary().is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn registered_handler_is_resolvable() {
|
||||
let mut registry = ProtocolRegistry::new();
|
||||
registry.register(Box::new(DummyHandler));
|
||||
assert_eq!(registry.len(), 1);
|
||||
assert_eq!(registry.names(), vec!["dummy"]);
|
||||
assert!(registry.primary().is_ok());
|
||||
assert!(registry.get("dummy").is_some());
|
||||
assert!(registry.get("missing").is_none());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue