v0.31.5
This commit is contained in:
1 parent
d942c1a35d
commit
75104f87ba
103 files changed
+1344
-370
No files matched your search
@@ -34,6 +34,7 @@ fn stored_log_tail_enforces_line_budget() {
|
||||
let source = source_from_path(
|
||||
"access".into(),
|
||||
"Access log".into(),
|
||||
"access".into(),
|
||||
"access",
|
||||
path,
|
||||
false,
|
||||
@@ -61,6 +62,7 @@ fn stored_log_normalizes_mapped_client_ip_and_searches_diagnostics() {
|
||||
let source = source_from_path(
|
||||
"vhost:app".into(),
|
||||
"app.jsonl".into(),
|
||||
"vhost:app".into(),
|
||||
"access",
|
||||
dir.path().join("app.jsonl"),
|
||||
true,
|
||||
@@ -168,6 +170,7 @@ fn stored_log_tail_reads_rotated_gzip_and_inventory_discovers_it() {
|
||||
let source = source_from_path(
|
||||
"access:gz:access.jsonl.1.gz".into(),
|
||||
"Access log · access.jsonl.1.gz".into(),
|
||||
"access".into(),
|
||||
"access",
|
||||
rotated.clone(),
|
||||
true,
|
||||
@@ -186,3 +189,48 @@ fn stored_log_tail_reads_rotated_gzip_and_inventory_discovers_it() {
|
||||
let sources = configured_file_log_sources(&config);
|
||||
assert!(sources.iter().any(|item| item.path == rotated && item.compressed));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stored_log_per_vhost_inventory_groups_active_and_rotated_files() {
|
||||
use std::io::Write;
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let active = dir.path().join("app.jsonl");
|
||||
std::fs::write(&active, b"{\"event\":\"request\"}\n").unwrap();
|
||||
let rotated = dir.path().join("app.jsonl.1.gz");
|
||||
let file = std::fs::File::create(&rotated).unwrap();
|
||||
let mut encoder = flate2::write::GzEncoder::new(file, flate2::Compression::default());
|
||||
writeln!(encoder, r#"{{"event":"request"}}"#).unwrap();
|
||||
encoder.finish().unwrap();
|
||||
|
||||
let mut config = Config::default();
|
||||
config.logging.file.per_vhost = true;
|
||||
config.logging.file.directory = dir.path().to_string_lossy().into_owned();
|
||||
let sources = configured_file_log_sources(&config);
|
||||
let app = sources.iter().filter(|source| source.group_id == "vhost:app").collect::<Vec<_>>();
|
||||
assert_eq!(app.len(), 2);
|
||||
assert!(app.iter().any(|source| source.id == "vhost:app"));
|
||||
assert!(app.iter().any(|source| source.compressed));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stored_log_aggregate_values_support_scalars_and_bounded_arrays() {
|
||||
let value = json!(["BadBot/1", "BadBot/1", 503, true, {"ignored":"object"}]);
|
||||
let mut values = Vec::new();
|
||||
file_log_aggregate_values(&value, &mut values);
|
||||
assert_eq!(values, vec!["BadBot/1".to_string(), "BadBot/1".to_string(), "503".to_string(), "true".to_string()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stored_log_query_validates_aggregation_controls() {
|
||||
assert!(validate_file_log_query(&FileLogQuery {
|
||||
aggregate_field: Some("user_agent".into()),
|
||||
aggregate_min_count: Some(2),
|
||||
aggregate_limit: Some(50),
|
||||
..FileLogQuery::default()
|
||||
}).is_ok());
|
||||
assert!(validate_file_log_query(&FileLogQuery {
|
||||
aggregate_field: Some("bad field".into()),
|
||||
..FileLogQuery::default()
|
||||
}).is_err());
|
||||
}
|
||||
Reference in new issue
Block a user