Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<language>_generated_files` into:

- `tests-integration/tests/serde_tests/cpp_generated_files`
- `tests-integration/tests/serde_tests/go_generated_files`
Expand Down
30 changes: 30 additions & 0 deletions tests-integration/tests/serde_tests/frequencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,36 @@ fn test_items_purged_round_trip() {
check_purged_round_trip(|item| item.to_string());
}

fn check_purged_compatibility<T: FrequentItemValue>(dir: &str, filename: &str) {
let bytes = fs::read(serialization_test_data(dir, filename)).unwrap();
let sketch = FrequentItemsSketch::<T>::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::<i64>("cpp_generated_files", "frequent_long_purged_cpp.sk");
}

#[test]
fn test_cpp_frequent_strings_purged() {
check_purged_compatibility::<String>("cpp_generated_files", "frequent_string_purged_cpp.sk");
}

#[test]
fn test_java_frequent_longs_purged() {
check_purged_compatibility::<i64>("java_generated_files", "frequent_long_purged_java.sk");
}

#[test]
fn test_java_frequent_strings_purged() {
check_purged_compatibility::<String>("java_generated_files", "frequent_string_purged_java.sk");
}

#[test]
fn test_deserialize_rejects_zero_stream_weight() {
let mut active_sketch = FrequentItemsSketch::<i64>::new(32).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tests-integration/tests/serde_tests/req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
7 changes: 4 additions & 3 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 {}",
Expand Down
Loading