Skip to content

Commit f077dce

Browse files
tobzclaude
andcommitted
chore(repo): align test naming and proptest authoring style
Apply the naming and proptest conventions from testing-patterns.md: rename the lone mod test (singular) in topology/graph.rs to mod tests; fix the dispoint->disjoint typo in a saluki-context proptest name; rename the saluki-tls partial_load_succeeds integration test fn to match its file stem; and convert the synchronous apm_stats property test from the #[test_strategy::proptest] attribute macro to the classic proptest! block macro (keeping request_builder's genuinely-async proptest on the attribute macro). The property_test_ CI routing is preserved. Convert test_-prefixed function names to bare descriptive names in the mixed-style modules the doc calls out (47 functions across 8 files), leaving internally consistent files for incremental conversion and deferring translator.rs / dogstatsd_prefix_filter to G13/G14 which rebuild those tests. Resolves G11 (KI-14, KI-15, KI-16) of the test suite cleanup plan. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0f99ce3 commit f077dce

13 files changed

Lines changed: 76 additions & 74 deletions

File tree

lib/saluki-components/src/transforms/apm_stats/aggregation.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ mod tests {
515515
use crate::transforms::apm_stats::statsraw::new_aggregation_from_span;
516516

517517
#[test]
518-
fn test_get_status_code() {
518+
fn get_status_code_from_attributes() {
519519
// Empty attrs
520520
let attrs: FastHashMap<MetaString, AV> = FastHashMap::default();
521521
assert_eq!(get_status_code(&attrs), 0);
@@ -545,7 +545,7 @@ mod tests {
545545
}
546546

547547
#[test]
548-
fn test_get_grpc_status_code() {
548+
fn get_grpc_status_code_from_attributes() {
549549
// Empty attrs
550550
let attrs: FastHashMap<MetaString, AV> = FastHashMap::default();
551551
assert_eq!(get_grpc_status_code(&attrs), GrpcStatusCode::Unset);
@@ -618,7 +618,7 @@ mod tests {
618618
}
619619

620620
#[test]
621-
fn test_new_aggregation() {
621+
fn new_aggregation() {
622622
// Helper to create a span with given service, meta, and metrics
623623
let make_span = |service: &str,
624624
meta: FastHashMap<MetaString, MetaString>,
@@ -736,7 +736,7 @@ mod tests {
736736
}
737737

738738
#[test]
739-
fn test_peer_tags_to_aggregate_for_span() {
739+
fn peer_tags_to_aggregate_for_span() {
740740
// Tests that peer tags are only returned for client/producer/consumer span kinds
741741
let peer_tags = vec![MetaString::from("server.address"), MetaString::from("_dd.base_service")];
742742

@@ -782,7 +782,7 @@ mod tests {
782782
}
783783

784784
#[test]
785-
fn test_is_root_span() {
785+
fn is_root_span() {
786786
let concentrator = SpanConcentrator::new(true, true, &[], 0);
787787

788788
// Span with parent_id = 0 -> is_trace_root = true

lib/saluki-components/src/transforms/apm_stats/mod.rs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,30 +1484,28 @@ mod tests {
14841484
);
14851485
}
14861486

1487-
#[test_strategy::proptest]
1488-
#[cfg_attr(miri, ignore)]
1489-
fn property_test_split_respects_max_entries(
1490-
#[strategy(arb_split_inputs())] inputs: (Vec<ClientStatsPayload>, usize),
1491-
) {
1492-
let (payloads, max_entries_per_event) = inputs;
1493-
1494-
let input_total: usize = payloads.iter().flat_map(|p| p.stats()).map(|b| b.stats().len()).sum();
1495-
1496-
let result = split_into_trace_stats(payloads, max_entries_per_event);
1487+
proptest! {
1488+
#[test]
1489+
#[cfg_attr(miri, ignore)]
1490+
fn property_test_split_respects_max_entries((payloads, max_entries_per_event) in arb_split_inputs()) {
1491+
let input_total: usize = payloads.iter().flat_map(|p| p.stats()).map(|b| b.stats().len()).sum();
1492+
1493+
let result = split_into_trace_stats(payloads, max_entries_per_event);
1494+
1495+
// Property 1: No TraceStats should exceed max_entries_per_event
1496+
for trace_stats in &result {
1497+
let count = count_grouped_stats(trace_stats);
1498+
prop_assert!(
1499+
count <= max_entries_per_event,
1500+
"TraceStats has {} grouped stats, exceeds max of {}",
1501+
count,
1502+
max_entries_per_event
1503+
);
1504+
}
14971505

1498-
// Property 1: No TraceStats should exceed max_entries_per_event
1499-
for trace_stats in &result {
1500-
let count = count_grouped_stats(trace_stats);
1501-
prop_assert!(
1502-
count <= max_entries_per_event,
1503-
"TraceStats has {} grouped stats, exceeds max of {}",
1504-
count,
1505-
max_entries_per_event
1506-
);
1506+
// Property 2: Total stats should be preserved
1507+
let output_total: usize = result.iter().map(count_grouped_stats).sum();
1508+
prop_assert_eq!(input_total, output_total, "Total stats count should be preserved");
15071509
}
1508-
1509-
// Property 2: Total stats should be preserved
1510-
let output_total: usize = result.iter().map(count_grouped_stats).sum();
1511-
prop_assert_eq!(input_total, output_total, "Total stats count should be preserved");
15121510
}
15131511
}

lib/saluki-components/src/transforms/metric_router/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ mod tests {
184184
use super::*;
185185

186186
#[test]
187-
fn test_exact_metric_name_matching() {
187+
fn exact_metric_name_matching() {
188188
let router = MetricRouter::new(MetricRouterConfiguration {
189189
metric_names: vec!["test.counter".to_string(), "another.metric".to_string()],
190190
})
@@ -208,7 +208,7 @@ mod tests {
208208
}
209209

210210
#[test]
211-
fn test_empty_metric_names_list() {
211+
fn empty_metric_names_list() {
212212
let router = MetricRouter::new(MetricRouterConfiguration { metric_names: vec![] })
213213
.expect("Should create router successfully");
214214

lib/saluki-components/src/transforms/trace_obfuscation/sql.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ mod tests {
150150
}
151151

152152
#[test]
153-
fn test_sql_quantizer() {
153+
fn sql_quantizer() {
154154
let cases = vec![
155155
// Basic cases
156156
(
@@ -382,7 +382,7 @@ mod tests {
382382
}
383383

384384
#[test]
385-
fn test_keep_sql_alias() {
385+
fn keep_sql_alias() {
386386
let query = "SELECT username AS person FROM users WHERE id=4";
387387

388388
// Test with keep_sql_alias = false (default)
@@ -403,7 +403,7 @@ mod tests {
403403
}
404404

405405
#[test]
406-
fn test_can_obfuscate_autovacuum() {
406+
fn can_obfuscate_autovacuum() {
407407
let config = default_config();
408408
let cases = vec![
409409
(
@@ -427,7 +427,7 @@ mod tests {
427427
}
428428

429429
#[test]
430-
fn test_dollar_quoted_func() {
430+
fn dollar_quoted_func() {
431431
let query = "SELECT $func$INSERT INTO table VALUES ('a', 1, 2)$func$ FROM users";
432432

433433
// Test with dollar_quoted_func = false (default)
@@ -451,7 +451,7 @@ mod tests {
451451
}
452452

453453
#[test]
454-
fn test_sql_replace_digits() {
454+
fn sql_replace_digits() {
455455
let config = SqlObfuscationConfig {
456456
replace_digits: true,
457457
..default_config()
@@ -480,7 +480,7 @@ mod tests {
480480

481481
#[test]
482482
#[ignore] // TODO: $action is obfuscated to ? - tokenizer needs to recognize $identifier as SQL Server variable
483-
fn test_single_dollar_identifier() {
483+
fn single_dollar_identifier() {
484484
let query = r#"
485485
MERGE INTO Employees AS target
486486
USING EmployeeUpdates AS source
@@ -509,7 +509,7 @@ mod tests {
509509
}
510510

511511
#[test]
512-
fn test_pg_json_operators() {
512+
fn pg_json_operators() {
513513
let config = SqlObfuscationConfig {
514514
dbms: "postgres".to_string(),
515515
..default_config()
@@ -553,7 +553,7 @@ mod tests {
553553
}
554554

555555
#[test]
556-
fn test_multiple_process() {
556+
fn multiple_process() {
557557
let config = default_config();
558558

559559
let cases = vec![

lib/saluki-components/src/transforms/trace_sampler/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ mod tests {
606606
}
607607

608608
#[test]
609-
fn test_user_priority_detection() {
609+
fn user_priority_detection() {
610610
let sampler = create_test_sampler();
611611

612612
// Test trace with user-set priority = 2 (UserKeep)
@@ -636,7 +636,7 @@ mod tests {
636636
}
637637

638638
#[test]
639-
fn test_trace_level_priority_takes_precedence() {
639+
fn trace_level_priority_takes_precedence() {
640640
let sampler = create_test_sampler();
641641

642642
// Test trace-level priority overrides span priorities (last-seen priority)
@@ -671,7 +671,7 @@ mod tests {
671671
}
672672

673673
#[test]
674-
fn test_manual_keep_with_trace_level_priority() {
674+
fn manual_keep_with_trace_level_priority() {
675675
let mut sampler = create_test_sampler();
676676
sampler.probabilistic_sampler_enabled = false; // Use legacy path that checks user priority
677677

@@ -706,7 +706,7 @@ mod tests {
706706
}
707707

708708
#[test]
709-
fn test_probabilistic_sampling_known_decisions() {
709+
fn probabilistic_sampling_known_decisions() {
710710
// The bucketed probabilistic sampler is fully deterministic: it hashes the trace ID into one of 0x4000
711711
// buckets and keeps the trace when `bucket < (rate * 0x4000)`. These cases pin the exact keep/drop decision
712712
// for known trace IDs at known rates, so a regression in the hash, the bucket mask, or the comparison is
@@ -783,7 +783,7 @@ mod tests {
783783
}
784784

785785
#[test]
786-
fn test_probabilistic_sampling_is_deterministic() {
786+
fn probabilistic_sampling_is_deterministic() {
787787
// Determinism is a documented property of `ProbabilisticSampler::sample` (same trace ID + rate always yields
788788
// the same decision). This is intentionally a determinism-only check; correctness is covered by
789789
// `test_probabilistic_sampling_known_decisions`.
@@ -796,7 +796,7 @@ mod tests {
796796
}
797797

798798
#[test]
799-
fn test_error_detection() {
799+
fn error_detection() {
800800
let sampler = create_test_sampler();
801801

802802
// Test trace with error field set
@@ -811,7 +811,7 @@ mod tests {
811811
}
812812

813813
#[test]
814-
fn test_sampling_priority_order() {
814+
fn sampling_priority_order() {
815815
// Test modern path: error sampler overrides probabilistic drop
816816
let mut sampler = create_test_sampler();
817817
sampler.sampling_rate = 0.5; // 50% sampling rate
@@ -844,7 +844,7 @@ mod tests {
844844
}
845845

846846
#[test]
847-
fn test_empty_trace_handling() {
847+
fn empty_trace_handling() {
848848
let mut sampler = create_test_sampler();
849849
let mut trace = create_test_trace(vec![]);
850850

@@ -854,7 +854,7 @@ mod tests {
854854
}
855855

856856
#[test]
857-
fn test_root_span_detection() {
857+
fn root_span_detection() {
858858
let sampler = create_test_sampler();
859859

860860
// Test 1: Root span with parent_id = 0 (common case)
@@ -911,7 +911,7 @@ mod tests {
911911
}
912912

913913
#[test]
914-
fn test_single_span_sampling() {
914+
fn single_span_sampling() {
915915
let mut sampler = create_test_sampler();
916916

917917
// Test 1: Trace with SSS tags should be kept even when probabilistic would drop it
@@ -949,7 +949,7 @@ mod tests {
949949
}
950950

951951
#[test]
952-
fn test_analytics_events() {
952+
fn analytics_events() {
953953
let sampler = create_test_sampler();
954954

955955
// Test 1: Trace with analyzed spans
@@ -992,7 +992,7 @@ mod tests {
992992
}
993993

994994
#[test]
995-
fn test_probabilistic_sampling_with_prob_rate_key() {
995+
fn probabilistic_sampling_with_prob_rate_key() {
996996
let mut sampler = create_test_sampler();
997997
sampler.sampling_rate = 0.75; // 75% sampling rate
998998
sampler.probabilistic_sampler_enabled = true;

lib/saluki-config/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ mod tests {
930930
use super::*;
931931

932932
#[tokio::test]
933-
async fn test_static_configuration() {
933+
async fn static_configuration() {
934934
let (cfg, _) = ConfigurationLoader::for_tests(
935935
Some(serde_json::json!({
936936
"foo": "bar",
@@ -954,7 +954,7 @@ mod tests {
954954
}
955955

956956
#[tokio::test]
957-
async fn test_dynamic_configuration() {
957+
async fn dynamic_configuration() {
958958
let (cfg, sender) = ConfigurationLoader::for_tests(
959959
Some(serde_json::json!({
960960
"foo": "bar",
@@ -1098,7 +1098,7 @@ mod tests {
10981098
}
10991099

11001100
#[tokio::test]
1101-
async fn test_environment_precedence_over_dynamic() {
1101+
async fn environment_precedence_over_dynamic() {
11021102
let (cfg, sender) = ConfigurationLoader::for_tests(
11031103
Some(serde_json::json!({
11041104
"foo": "bar",
@@ -1168,7 +1168,7 @@ mod tests {
11681168
}
11691169

11701170
#[tokio::test]
1171-
async fn test_dynamic_configuration_add_new_nested_key() {
1171+
async fn dynamic_configuration_add_new_nested_key() {
11721172
let (cfg, sender) = ConfigurationLoader::for_tests(
11731173
Some(serde_json::json!({
11741174
"foo": "bar",
@@ -1214,7 +1214,7 @@ mod tests {
12141214
}
12151215

12161216
#[tokio::test]
1217-
async fn test_underscore_fallback_on_get() {
1217+
async fn underscore_fallback_on_get() {
12181218
let (cfg, _) = ConfigurationLoader::for_tests(
12191219
Some(serde_json::json!({})),
12201220
Some(&[("RANDOM_KEY".to_string(), "from_env_only".to_string())]),
@@ -1227,7 +1227,7 @@ mod tests {
12271227
}
12281228

12291229
#[tokio::test]
1230-
async fn test_underscore_fallback_on_get_multi_segment_key() {
1230+
async fn underscore_fallback_on_get_multi_segment_key() {
12311231
// A single-underscore Agent-style env var (e.g. `DD_DATA_PLANE_API_LISTEN_ADDRESS`, which
12321232
// `for_tests` simulates with the `TEST_` prefix) produces a flat figment key. A deeply
12331233
// nested `get`/`try_get_typed` query must still resolve it via the dot-to-underscore
@@ -1250,7 +1250,7 @@ mod tests {
12501250
}
12511251

12521252
#[tokio::test]
1253-
async fn test_static_configuration_ready_and_subscribe() {
1253+
async fn static_configuration_ready_and_subscribe() {
12541254
let (cfg, maybe_sender) = ConfigurationLoader::for_tests(Some(serde_json::json!({})), None, false).await;
12551255
assert!(maybe_sender.is_none());
12561256

@@ -1262,7 +1262,7 @@ mod tests {
12621262
}
12631263

12641264
#[tokio::test]
1265-
async fn test_dynamic_configuration_ready_requires_initial_snapshot() {
1265+
async fn dynamic_configuration_ready_requires_initial_snapshot() {
12661266
// Enable dynamic but do not send the initial snapshot.
12671267
let (cfg, maybe_sender) = ConfigurationLoader::for_tests(Some(serde_json::json!({})), None, true).await;
12681268
assert!(maybe_sender.is_some());
@@ -1273,7 +1273,7 @@ mod tests {
12731273
}
12741274

12751275
#[tokio::test]
1276-
async fn test_flattened_keys_flat_and_nested() {
1276+
async fn flattened_keys_flat_and_nested() {
12771277
let (cfg, _) = ConfigurationLoader::for_tests(
12781278
Some(serde_json::json!({
12791279
"top": "value",
@@ -1297,7 +1297,7 @@ mod tests {
12971297
}
12981298

12991299
#[tokio::test]
1300-
async fn test_flattened_keys_arrays_are_leaves() {
1300+
async fn flattened_keys_arrays_are_leaves() {
13011301
let (cfg, _) = ConfigurationLoader::for_tests(
13021302
Some(serde_json::json!({
13031303
"tags": ["a", "b"],
@@ -1318,7 +1318,7 @@ mod tests {
13181318
}
13191319

13201320
#[tokio::test]
1321-
async fn test_flattened_keys_null_values_absent() {
1321+
async fn flattened_keys_null_values_absent() {
13221322
let (cfg, _) = ConfigurationLoader::for_tests(
13231323
Some(serde_json::json!({
13241324
"present": "yes",

0 commit comments

Comments
 (0)