v0.34.0_2
This commit is contained in:
1 parent
0a8bc6f040
commit
434e789144
38 files changed
+899
-238
No files matched your search
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Source invariants for 0.34.0 RPS optimizations (NOT a Rust build or RPS test).
|
||||
|
||||
These guards reject accidental removal of important branch/safety conditions.
|
||||
They must be paired with ``cargo test`` and live black-box HTTP acceptance.
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def source(path):
|
||||
return (ROOT / path).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
# Random request identifiers retain CSPRNG entropy, SHA-256, format and sequence.
|
||||
identifier = source("src/proxy/request_id.rs")
|
||||
assert "rand::random()" in identifier
|
||||
assert "hash.update(sequence.to_be_bytes());" in identifier
|
||||
assert "hash.update(nonce);" in identifier
|
||||
assert "request_id_hex(&hash.finalize())" in identifier
|
||||
assert "SysRng.try_fill_bytes" not in identifier
|
||||
|
||||
# Compiled/validated target authority survives request URI construction.
|
||||
config = source("src/config/backend.rs")
|
||||
model = source("src/config/model.rs")
|
||||
request = source("src/proxy/types.rs")
|
||||
assert "let request_origin_uri: http::Uri = request_origin.parse()?;" in config
|
||||
assert "request_origin_uri," in config
|
||||
assert "pub request_origin_uri: http::Uri," in model
|
||||
assert "let path: http::uri::PathAndQuery = suffix.parse().ok()?;" in request
|
||||
assert "let mut parts = backend.request_origin_uri.clone().into_parts();" in request
|
||||
assert "parts.path_and_query = Some(path);" in request
|
||||
assert "Uri::from_parts(parts).ok()" in request
|
||||
|
||||
# No new unbounded caches or disabled LB safety gates.
|
||||
pool = source("src/balance/pool_core.rs")
|
||||
assert "if self.members.len() == 1 && !self.cookie_affinity()" in pool
|
||||
assert "try_acquire_active(member.definition.max_concurrent_requests)" in pool
|
||||
assert "m.state.healthy()" in pool
|
||||
assert "scheduling.get_mut(member.definition.id.as_str())" in pool
|
||||
assert "scheduling.entry(member.definition.id.clone())" in pool
|
||||
health = source("src/balance/lease_runtime.rs")
|
||||
assert "async fn probe(member: Arc<Member>, settings: Arc<HealthCheck>)" in health
|
||||
assert "checks.spawn(probe(Arc::clone(member), health.clone()))" in health
|
||||
assert "tokio::time::timeout" in health
|
||||
|
||||
# Configurable keep-alive policy, exact recycle-request threshold and age backup.
|
||||
upstream = source("src/upstream/client.rs")
|
||||
assert "self.current.load_full()" in upstream
|
||||
assert "request_due || age_due" in upstream
|
||||
assert "let now = monotonic_millis();" in upstream
|
||||
assert "let age_ms = now.saturating_sub(self.generation_started_ms.load(Ordering::Relaxed));" in upstream
|
||||
assert "fn maintain_rotation_at(" in upstream
|
||||
assert "self.factory.keepalive.pool_recycle_requests" in upstream
|
||||
assert "self.factory.keepalive.pool_recycle_seconds" in upstream
|
||||
assert "pool_max_idle_per_host(if keepalive.enabled" in upstream
|
||||
assert "retry_canceled_requests(false)" in upstream
|
||||
assert "observe_protocol" in upstream
|
||||
|
||||
# Request/response streamed payloads retain accounting and timeout/cancellation.
|
||||
body = source("src/proxy/body.rs")
|
||||
assert "request_backend: Option<Arc<crate::balance::Lease>>" in body
|
||||
assert "this.request_backend = exchange.backend" in body
|
||||
assert "lease.bytes(count, true)" in body
|
||||
assert "lease.bytes(count, false)" in body
|
||||
assert "exchange.request_bytes.fetch_add(count" in body
|
||||
assert "exchange.response_bytes.fetch_add(count" in body
|
||||
assert "get_or_insert_with(|| Box::pin(sleep_until(this.deadline)))" in body
|
||||
assert "this.finish();" in body
|
||||
|
||||
# Persist history and preserve live streaming/sink drop accounting.
|
||||
logs = source("src/logging/format.rs")
|
||||
assert "let has_viewers = self.live.receiver_count() != 0;" in logs
|
||||
assert "let has_sink = self.settings.load().enabled();" in logs
|
||||
assert "external.take().expect(\"entry\")" in logs
|
||||
assert "self.live.send(entry.clone())" in logs
|
||||
assert "self.sink.try_send(entry)" in logs
|
||||
assert "self.sink_dropped.fetch_add(1" in logs
|
||||
|
||||
# Never weaken routing, identity, HTTP version and cache eligibility while tuning.
|
||||
route = source("src/proxy/forward/route_cache.rs")
|
||||
assert "admin_session_passthrough" in route
|
||||
assert "cache_plan.request_policy" in route
|
||||
assert "exchange.set_cache_enabled" in route
|
||||
assert "exchange.set_transform_enabled" in route
|
||||
assert "upstream_uri(&backend, &origin_suffix)" in route
|
||||
assert "headers::strip_hop_by_hop" in route
|
||||
assert "pool.select_wait(context.client_ip" in route or ".select_wait(context.client_ip" in route
|
||||
assert "pool.select_member_wait(id)" in route
|
||||
assert "max_idle_per_host: 4" in source("src/balance/model.rs")
|
||||
assert "pool_recycle_requests: 25_000" in source("src/balance/model.rs")
|
||||
assert 'version = "0.34.0"' in source("Cargo.toml")
|
||||
|
||||
for file in (ROOT / "src").rglob("*.rs"):
|
||||
if "/tests/" in file.as_posix() or file.name == "tests.rs":
|
||||
continue
|
||||
assert len(file.read_text(encoding="utf-8").splitlines()) <= 500, file
|
||||
print("PASS RPS hot-path source invariants (STATIC ONLY; new binary not compiled)")
|
||||
Reference in new issue
Block a user