mirror of
https://github.com/telemt/telemt.git
synced 2026-11-05 23:32:00 +03:00
Bounded WEB HTTP conveyor with replay-safe streaming downlink added
Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
This commit is contained in:
@@ -453,3 +453,7 @@ mod base_path_tests;
|
||||
#[cfg(test)]
|
||||
#[path = "config_edit/tests.rs"]
|
||||
mod tests;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "config_edit/conveyor_tests.rs"]
|
||||
mod conveyor_tests;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn conveyor_api_is_boolean_hot_and_rejects_invalid_patch_atomically() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let path = directory.path().join("config.toml");
|
||||
std::fs::write(&path, "[web]\nconveyor = true\n").unwrap();
|
||||
for enabled in [false, true] {
|
||||
let active = ProxyConfig::load(&path).unwrap();
|
||||
let patch = serde_json::json!({"web": {"conveyor": enabled}});
|
||||
let mut response = apply_patch_to_path(&path, &patch, None).await.unwrap();
|
||||
let desired = ProxyConfig::load(&path).unwrap();
|
||||
let resolved = reconcile_runtime_effect(&mut response, &active, &desired).unwrap();
|
||||
assert_eq!(resolved.effective.web.conveyor, enabled);
|
||||
assert!(response.runtime_reload_required);
|
||||
assert!(!response.process_restart_required);
|
||||
let (managed, _) = read_managed_config(&path).await.unwrap();
|
||||
assert_eq!(managed["web"]["conveyor"].as_bool(), Some(enabled));
|
||||
let previous = std::fs::read(&path).unwrap();
|
||||
let invalid = serde_json::json!({"web": {"conveyor": "false"}});
|
||||
let error = apply_patch_to_path(&path, &invalid, None)
|
||||
.await
|
||||
.unwrap_err();
|
||||
assert_eq!(error.status, hyper::StatusCode::BAD_REQUEST);
|
||||
assert_eq!(std::fs::read(&path).unwrap(), previous);
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,8 @@ async fn patch_web_debug_is_hot_and_limits_are_process_deferred() {
|
||||
assert!(desired.web.debug.sideband);
|
||||
|
||||
let limits_patch: Json = serde_json::json!({
|
||||
"web": {"limits": {"max_http_connections": 2049}}
|
||||
// Extra HTTP heads must fit alongside the default-on conveyor metadata reservation.
|
||||
"web": {"limits": {"max_http_connections": 2049, "memory_envelope_bytes": 1610612736u64}}
|
||||
});
|
||||
let limits = apply_patch_to_path(&path, &limits_patch, None)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user