From 98275c075b33ffc03ce5568b079b3b75bca8c386 Mon Sep 17 00:00:00 2001 From: tison Date: Mon, 5 Oct 2026 14:55:50 +0800 Subject: [PATCH] test: update TCK snapshots and archive layout --- CONTRIBUTING.md | 2 +- .../tests/serde_tests/frequencies.rs | 30 +++++++++++++++++++ tests-integration/tests/serde_tests/req.rs | 2 +- xtask/src/main.rs | 7 +++-- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 889d68a4..841f8509 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -144,7 +144,7 @@ cargo install taplo-cli typos-cli hawkeye Serialization compatibility tests use snapshots from a pinned revision of [`apache/datasketches-tck`](https://github.com/apache/datasketches-tck). -The `cargo x prepare-testdata` command downloads the TCK archive and synchronizes its snapshots into: +The `cargo x prepare-testdata` command downloads the TCK archive and synchronizes `.sk` files from `serialization_test_data/_generated_files` into: - `tests-integration/tests/serde_tests/cpp_generated_files` - `tests-integration/tests/serde_tests/go_generated_files` diff --git a/tests-integration/tests/serde_tests/frequencies.rs b/tests-integration/tests/serde_tests/frequencies.rs index 21f32285..31c25cb1 100644 --- a/tests-integration/tests/serde_tests/frequencies.rs +++ b/tests-integration/tests/serde_tests/frequencies.rs @@ -159,6 +159,36 @@ fn test_items_purged_round_trip() { check_purged_round_trip(|item| item.to_string()); } +fn check_purged_compatibility(dir: &str, filename: &str) { + let bytes = fs::read(serialization_test_data(dir, filename)).unwrap(); + let sketch = FrequentItemsSketch::::deserialize(&bytes).unwrap(); + assert!(!sketch.is_empty()); + assert_eq!(sketch.num_active_items(), 0); + assert_eq!(sketch.total_weight(), 193); + assert_eq!(sketch.maximum_error(), 1); + assert_eq!(sketch.serialize(), bytes); +} + +#[test] +fn test_cpp_frequent_longs_purged() { + check_purged_compatibility::("cpp_generated_files", "frequent_long_purged_cpp.sk"); +} + +#[test] +fn test_cpp_frequent_strings_purged() { + check_purged_compatibility::("cpp_generated_files", "frequent_string_purged_cpp.sk"); +} + +#[test] +fn test_java_frequent_longs_purged() { + check_purged_compatibility::("java_generated_files", "frequent_long_purged_java.sk"); +} + +#[test] +fn test_java_frequent_strings_purged() { + check_purged_compatibility::("java_generated_files", "frequent_string_purged_java.sk"); +} + #[test] fn test_deserialize_rejects_zero_stream_weight() { let mut active_sketch = FrequentItemsSketch::::new(32).unwrap(); diff --git a/tests-integration/tests/serde_tests/req.rs b/tests-integration/tests/serde_tests/req.rs index 397f894d..d0a03e1e 100644 --- a/tests-integration/tests/serde_tests/req.rs +++ b/tests-integration/tests/serde_tests/req.rs @@ -487,7 +487,7 @@ fn deserialize_rejects_oversized_compactor_num_items() { // ---------- Cross-language compatibility ---------- // -// Requires fixtures generated by `tools/generate_serialization_test_data.py`. +// Requires fixtures downloaded by `cargo x prepare-testdata`. // If `tests/serde_tests/{cpp,java}_generated_files/` is missing, the // `serialization_test_data` helper panics with regeneration instructions. diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 5f6a8a02..9b3fb1f2 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -316,7 +316,7 @@ impl CommandPrepareTestData { } fn prepare(self) -> Result<()> { - const REVISION: &str = "c0a180708c6e6433e4cba7fba091713eb8af3eaa"; + const REVISION: &str = "8193bab45ca5da3b513ea43fb5793e7e5b4da548"; let serde_tests = Path::new(env!("CARGO_WORKSPACE_DIR")).join("tests-integration/tests/serde_tests"); let archive_url = @@ -341,8 +341,9 @@ impl CommandPrepareTestData { let mut targets = vec![]; for language in self.languages() { - let source_directory = Path::new("serialization").join(language).join("snapshots"); - let destination = serde_tests.join(format!("{language}_generated_files")); + let directory_name = format!("{language}_generated_files"); + let source_directory = Path::new("serialization_test_data").join(&directory_name); + let destination = serde_tests.join(directory_name); if fs::exists(&destination)? { println!( "Removing existing {language} snapshots from {}",