This is an automated email from the ASF dual-hosted git repository. tisonkun pushed a commit to branch rework-integration-tests in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git
commit 325274e924f22b264690a7a38c786e3ef31a0ac0 Author: tison <[email protected]> AuthorDate: Tue Jul 28 08:45:09 2026 +0800 more 3 Signed-off-by: tison <[email protected]> --- .github/workflows/ci.yml | 2 +- CONTRIBUTING.md | 16 +++---- datasketches/tests/countmin_test/main.rs | 2 - datasketches/tests/cpc_test/main.rs | 2 - datasketches/tests/frequencies_test/main.rs | 2 - datasketches/tests/hll_test/main.rs | 2 - datasketches/tests/serde_tests.rs | 46 +++++++++++++++------ .../.gitignore | 0 .../{serialization_tests => serde_tests}/bloom.rs | 2 +- .../countmin.rs | 2 +- .../{serialization_tests => serde_tests}/cpc.rs | 2 +- .../frequencies.rs | 2 +- .../{serialization_tests => serde_tests}/hll.rs | 2 +- .../tdigest_ref_k100_n10000_double.sk | Bin .../tdigest_ref_k100_n10000_float.sk | Bin .../tdigest.rs | 2 +- .../{serialization_tests => serde_tests}/theta.rs | 2 +- .../{serialization_tests => serde_tests}/tuple.rs | 2 +- datasketches/tests/serialization_tests/support.rs | 43 ------------------- datasketches/tests/tdigest_test/main.rs | 2 - datasketches/tests/theta_test/main.rs | 2 - datasketches/tests/tuple_test/main.rs | 2 - ...n_test_data.py => download_serde_tests_data.py} | 6 +-- 23 files changed, 53 insertions(+), 90 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcae649..13c665e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,7 +93,7 @@ jobs: cache-bin: "false" - name: Prepare test data shell: bash - run: ./tools/download_serialization_test_data.py + run: ./tools/download_serde_tests_data.py - name: Run unit tests shell: bash run: cargo x test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 02e98ee..f2d5e15 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,9 +77,9 @@ When adding a case to an existing sketch target, add it to the appropriate modul ### Serialization compatibility tests -Cargo automatically discovers `datasketches/tests/serde_tests.rs`, which aggregates the sketch-specific modules under `datasketches/tests/serialization_tests`. Each module is gated by its corresponding sketch feature in `serde_tests.rs`. +Cargo automatically discovers `datasketches/tests/serde_tests.rs`, which aggregates the sketch-specific modules under `datasketches/tests/serde_tests`. Each module is gated by its corresponding sketch feature in `serde_tests.rs`. -To add serialization tests for another sketch, add `serialization_tests/<sketch>.rs` and a feature-gated module declaration in `serde_tests.rs`. Do not add a separate `[[test]]` entry. Shared path handling belongs in `serialization_tests/support.rs`, and serialization fixtures belong in the appropriate subdirectory under `serialization_tests`. +To add serialization tests for another sketch, add `serde_tests/<sketch>.rs` and a feature-gated module declaration in `serde_tests.rs`. Do not add a separate `[[test]]` entry. Shared path handling belongs in `serde_tests.rs`, and serialization fixtures belong in the appropriate subdirectory under `serde_tests`. ## Manual workflow (without xtask) @@ -110,23 +110,23 @@ cargo install taplo-cli typos-cli hawkeye ## Serialization snapshots -Some tests depend on snapshot files under `datasketches/tests/serialization_tests`. If they are missing, tests will fail. Download them with: +Some tests depend on snapshot files under `datasketches/tests/serde_tests`. If they are missing, tests will fail. Download them with: ```shell -python3 ./tools/download_serialization_test_data.py --all +python3 ./tools/download_serde_tests_data.py --all ``` The script downloads the latest snapshots from the `main` branch of [`apache/datasketches-tck`](https://github.com/apache/datasketches-tck) and writes them to: -- `datasketches/tests/serialization_tests/java_generated_files` -- `datasketches/tests/serialization_tests/cpp_generated_files` +- `datasketches/tests/serde_tests/java_generated_files` +- `datasketches/tests/serde_tests/cpp_generated_files` You can download them separately: ```shell -python3 ./tools/download_serialization_test_data.py --java -python3 ./tools/download_serialization_test_data.py --cpp +python3 ./tools/download_serde_tests_data.py --java +python3 ./tools/download_serde_tests_data.py --cpp ``` The script requires Python 3 and network access. diff --git a/datasketches/tests/countmin_test/main.rs b/datasketches/tests/countmin_test/main.rs index 9778d3e..825a628 100644 --- a/datasketches/tests/countmin_test/main.rs +++ b/datasketches/tests/countmin_test/main.rs @@ -15,6 +15,4 @@ // specific language governing permissions and limitations // under the License. -//! Integration tests for Count-Min sketches. - mod sketch; diff --git a/datasketches/tests/cpc_test/main.rs b/datasketches/tests/cpc_test/main.rs index 92a6f0e..0583ff1 100644 --- a/datasketches/tests/cpc_test/main.rs +++ b/datasketches/tests/cpc_test/main.rs @@ -15,8 +15,6 @@ // specific language governing permissions and limitations // under the License. -//! Integration tests for CPC sketches and set operations. - mod union; mod update; mod wrapper; diff --git a/datasketches/tests/frequencies_test/main.rs b/datasketches/tests/frequencies_test/main.rs index 97beca9..1dea33b 100644 --- a/datasketches/tests/frequencies_test/main.rs +++ b/datasketches/tests/frequencies_test/main.rs @@ -15,6 +15,4 @@ // specific language governing permissions and limitations // under the License. -//! Integration tests for frequent-items sketches. - mod update; diff --git a/datasketches/tests/hll_test/main.rs b/datasketches/tests/hll_test/main.rs index 21e4c0c..e56cecc 100644 --- a/datasketches/tests/hll_test/main.rs +++ b/datasketches/tests/hll_test/main.rs @@ -15,7 +15,5 @@ // specific language governing permissions and limitations // under the License. -//! Integration tests for HLL sketches and unions. - mod union; mod update; diff --git a/datasketches/tests/serde_tests.rs b/datasketches/tests/serde_tests.rs index 86ffea3..92cdc42 100644 --- a/datasketches/tests/serde_tests.rs +++ b/datasketches/tests/serde_tests.rs @@ -15,41 +15,61 @@ // specific language governing permissions and limitations // under the License. -//! Serialization compatibility tests grouped by sketch. +use std::path::PathBuf; -// This target is also compiled without sketch features during feature-matrix checks. -#[allow(dead_code)] -#[path = "serialization_tests/support.rs"] -mod support; +pub fn serialization_test_data(sub_dir: &str, name: &str) -> PathBuf { + const SERDE_TESTS_DIR: &str = "tests/serde_tests"; + + let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join(SERDE_TESTS_DIR) + .join(sub_dir) + .join(name); + + if !path.exists() { + panic!( + r#"serialization test data file not found: {} + + Please ensure test data files are present in the repository. Generally, you can + run the following commands from the project root to download the test data files + if they are missing: + + $ ./tools/download_serde_tests_data.py + "#, + path.display(), + ); + } + + path +} #[cfg(feature = "bloom")] -#[path = "serialization_tests/bloom.rs"] +#[path = "serde_tests/bloom.rs"] mod bloom; #[cfg(feature = "countmin")] -#[path = "serialization_tests/countmin.rs"] +#[path = "serde_tests/countmin.rs"] mod countmin; #[cfg(feature = "cpc")] -#[path = "serialization_tests/cpc.rs"] +#[path = "serde_tests/cpc.rs"] mod cpc; #[cfg(feature = "frequencies")] -#[path = "serialization_tests/frequencies.rs"] +#[path = "serde_tests/frequencies.rs"] mod frequencies; #[cfg(feature = "hll")] -#[path = "serialization_tests/hll.rs"] +#[path = "serde_tests/hll.rs"] mod hll; #[cfg(feature = "tdigest")] -#[path = "serialization_tests/tdigest.rs"] +#[path = "serde_tests/tdigest.rs"] mod tdigest; #[cfg(feature = "theta")] -#[path = "serialization_tests/theta.rs"] +#[path = "serde_tests/theta.rs"] mod theta; #[cfg(feature = "tuple")] -#[path = "serialization_tests/tuple.rs"] +#[path = "serde_tests/tuple.rs"] mod tuple; diff --git a/datasketches/tests/serialization_tests/.gitignore b/datasketches/tests/serde_tests/.gitignore similarity index 100% rename from datasketches/tests/serialization_tests/.gitignore rename to datasketches/tests/serde_tests/.gitignore diff --git a/datasketches/tests/serialization_tests/bloom.rs b/datasketches/tests/serde_tests/bloom.rs similarity index 99% rename from datasketches/tests/serialization_tests/bloom.rs rename to datasketches/tests/serde_tests/bloom.rs index 966dc8f..5875b1f 100644 --- a/datasketches/tests/serialization_tests/bloom.rs +++ b/datasketches/tests/serde_tests/bloom.rs @@ -20,7 +20,7 @@ use std::path::PathBuf; use datasketches::bloom::BloomFilter; -use crate::support::serialization_test_data; +use crate::serialization_test_data; fn test_bloom_filter_file(path: PathBuf, expected_num_items: u64, expected_num_hashes: u16) { let bytes = fs::read(&path).unwrap(); diff --git a/datasketches/tests/serialization_tests/countmin.rs b/datasketches/tests/serde_tests/countmin.rs similarity index 98% rename from datasketches/tests/serialization_tests/countmin.rs rename to datasketches/tests/serde_tests/countmin.rs index a7499cd..49745f1 100644 --- a/datasketches/tests/serialization_tests/countmin.rs +++ b/datasketches/tests/serde_tests/countmin.rs @@ -21,7 +21,7 @@ use datasketches::countmin::CountMinSketch; use googletest::assert_that; use googletest::prelude::contains_substring; -use crate::support::serialization_test_data; +use crate::serialization_test_data; // This test validates binary format compatibility (deserialize + byte round-trip) for // C++ Count-Min snapshots. It intentionally does not assert estimate equivalence against diff --git a/datasketches/tests/serialization_tests/cpc.rs b/datasketches/tests/serde_tests/cpc.rs similarity index 98% rename from datasketches/tests/serialization_tests/cpc.rs rename to datasketches/tests/serde_tests/cpc.rs index 0475edc..7d90250 100644 --- a/datasketches/tests/serialization_tests/cpc.rs +++ b/datasketches/tests/serde_tests/cpc.rs @@ -22,7 +22,7 @@ use datasketches::cpc::CpcSketch; use googletest::assert_that; use googletest::prelude::near; -use crate::support::serialization_test_data; +use crate::serialization_test_data; fn test_sketch_file(path: PathBuf, expected_cardinality: usize) { let expected = expected_cardinality as f64; diff --git a/datasketches/tests/serialization_tests/frequencies.rs b/datasketches/tests/serde_tests/frequencies.rs similarity index 99% rename from datasketches/tests/serialization_tests/frequencies.rs rename to datasketches/tests/serde_tests/frequencies.rs index 5f9372d..07051ba 100644 --- a/datasketches/tests/serialization_tests/frequencies.rs +++ b/datasketches/tests/serde_tests/frequencies.rs @@ -24,7 +24,7 @@ use datasketches::error::ErrorKind; use datasketches::frequencies::FrequentItemValue; use datasketches::frequencies::FrequentItemsSketch; -use crate::support::serialization_test_data; +use crate::serialization_test_data; #[derive(Debug, PartialEq, Eq, Hash)] struct NonCloneSerializableItem(i64); diff --git a/datasketches/tests/serialization_tests/hll.rs b/datasketches/tests/serde_tests/hll.rs similarity index 99% rename from datasketches/tests/serialization_tests/hll.rs rename to datasketches/tests/serde_tests/hll.rs index dc64a74..fb1e4fb 100644 --- a/datasketches/tests/serialization_tests/hll.rs +++ b/datasketches/tests/serde_tests/hll.rs @@ -22,7 +22,7 @@ use datasketches::hash_value::natural_extend; use datasketches::hll::HllSketch; use datasketches::hll::HllType; -use crate::support::serialization_test_data; +use crate::serialization_test_data; fn test_sketch_file(path: PathBuf, expected_cardinality: usize, expected_lg_k: u8) { let expected = expected_cardinality as f64; diff --git a/datasketches/tests/serialization_tests/reference_files/tdigest_ref_k100_n10000_double.sk b/datasketches/tests/serde_tests/reference_files/tdigest_ref_k100_n10000_double.sk similarity index 100% rename from datasketches/tests/serialization_tests/reference_files/tdigest_ref_k100_n10000_double.sk rename to datasketches/tests/serde_tests/reference_files/tdigest_ref_k100_n10000_double.sk diff --git a/datasketches/tests/serialization_tests/reference_files/tdigest_ref_k100_n10000_float.sk b/datasketches/tests/serde_tests/reference_files/tdigest_ref_k100_n10000_float.sk similarity index 100% rename from datasketches/tests/serialization_tests/reference_files/tdigest_ref_k100_n10000_float.sk rename to datasketches/tests/serde_tests/reference_files/tdigest_ref_k100_n10000_float.sk diff --git a/datasketches/tests/serialization_tests/tdigest.rs b/datasketches/tests/serde_tests/tdigest.rs similarity index 99% rename from datasketches/tests/serialization_tests/tdigest.rs rename to datasketches/tests/serde_tests/tdigest.rs index 626843b..bfe4d40 100644 --- a/datasketches/tests/serialization_tests/tdigest.rs +++ b/datasketches/tests/serde_tests/tdigest.rs @@ -23,7 +23,7 @@ use googletest::assert_that; use googletest::prelude::eq; use googletest::prelude::near; -use crate::support::serialization_test_data; +use crate::serialization_test_data; fn test_sketch_file(path: PathBuf, n: u64, with_buffer: bool, is_f32: bool) { let bytes = fs::read(&path).unwrap(); diff --git a/datasketches/tests/serialization_tests/theta.rs b/datasketches/tests/serde_tests/theta.rs similarity index 98% rename from datasketches/tests/serialization_tests/theta.rs rename to datasketches/tests/serde_tests/theta.rs index 1154807..a1206aa 100644 --- a/datasketches/tests/serialization_tests/theta.rs +++ b/datasketches/tests/serde_tests/theta.rs @@ -22,7 +22,7 @@ use datasketches::theta::CompactThetaSketch; use googletest::assert_that; use googletest::prelude::near; -use crate::support::serialization_test_data; +use crate::serialization_test_data; fn test_sketch_file(path: PathBuf, expected_cardinality: usize, use_compressed_round_trip: bool) { let expected = expected_cardinality as f64; diff --git a/datasketches/tests/serialization_tests/tuple.rs b/datasketches/tests/serde_tests/tuple.rs similarity index 98% rename from datasketches/tests/serialization_tests/tuple.rs rename to datasketches/tests/serde_tests/tuple.rs index 104ec88..00a3ca2 100644 --- a/datasketches/tests/serialization_tests/tuple.rs +++ b/datasketches/tests/serde_tests/tuple.rs @@ -22,7 +22,7 @@ use datasketches::tuple::CompactTupleSketch; use googletest::assert_that; use googletest::prelude::near; -use crate::support::serialization_test_data; +use crate::serialization_test_data; fn test_sketch_file(path: PathBuf, expected_cardinality: usize) { let expected = expected_cardinality as f64; diff --git a/datasketches/tests/serialization_tests/support.rs b/datasketches/tests/serialization_tests/support.rs deleted file mode 100644 index 9796f83..0000000 --- a/datasketches/tests/serialization_tests/support.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -use std::path::PathBuf; - -pub fn serialization_test_data(sub_dir: &str, name: &str) -> PathBuf { - const SERIALIZATION_TESTS_DIR: &str = "tests/serialization_tests"; - - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join(SERIALIZATION_TESTS_DIR) - .join(sub_dir) - .join(name); - - if !path.exists() { - panic!( - r#"serialization test data file not found: {} - - Please ensure test data files are present in the repository. Generally, you can - run the following commands from the project root to download the test data files - if they are missing: - - $ ./tools/download_serialization_test_data.py - "#, - path.display(), - ); - } - - path -} diff --git a/datasketches/tests/tdigest_test/main.rs b/datasketches/tests/tdigest_test/main.rs index 0d79c55..825a628 100644 --- a/datasketches/tests/tdigest_test/main.rs +++ b/datasketches/tests/tdigest_test/main.rs @@ -15,6 +15,4 @@ // specific language governing permissions and limitations // under the License. -//! Integration tests for t-digest sketches. - mod sketch; diff --git a/datasketches/tests/theta_test/main.rs b/datasketches/tests/theta_test/main.rs index 3550880..f3d4a72 100644 --- a/datasketches/tests/theta_test/main.rs +++ b/datasketches/tests/theta_test/main.rs @@ -15,8 +15,6 @@ // specific language governing permissions and limitations // under the License. -//! Integration tests for Theta sketches and set operations. - mod a_not_b; mod intersection; mod sketch; diff --git a/datasketches/tests/tuple_test/main.rs b/datasketches/tests/tuple_test/main.rs index 4e2ab27..f5747e9 100644 --- a/datasketches/tests/tuple_test/main.rs +++ b/datasketches/tests/tuple_test/main.rs @@ -15,8 +15,6 @@ // specific language governing permissions and limitations // under the License. -//! Integration tests for tuple sketches and set operations. - mod a_not_b; mod intersection; mod sketch; diff --git a/tools/download_serialization_test_data.py b/tools/download_serde_tests_data.py similarity index 95% rename from tools/download_serialization_test_data.py rename to tools/download_serde_tests_data.py index 4bed8fe..a659611 100755 --- a/tools/download_serialization_test_data.py +++ b/tools/download_serde_tests_data.py @@ -89,10 +89,10 @@ def main(): args = parser.parse_args() repository_root = Path(__file__).resolve().parents[1] - serialization_tests = repository_root / "datasketches" / "tests" / "serialization_tests" + serde_tests = repository_root / "datasketches" / "tests" / "serde_tests" generated_targets = { - "cpp": serialization_tests / "cpp_generated_files", - "java": serialization_tests / "java_generated_files", + "cpp": serde_tests / "cpp_generated_files", + "java": serde_tests / "java_generated_files", } languages = [] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
