Skip to content

Commit

Permalink
refactor: rename crate hudi-tests to hudi-test
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiyan committed Jan 24, 2025
1 parent f722508 commit d450516
Show file tree
Hide file tree
Showing 41 changed files with 24 additions and 57 deletions.
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ datafusion-physical-expr = { workspace = true, optional = true }
percent-encoding = { workspace = true }

[dev-dependencies]
hudi-tests = { path = "../tests" }
hudi-test = { path = "../test" }

[features]
datafusion = [
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/config/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,6 @@ mod tests {
));
assert!(!UseReadOptimizedMode
.parse_value_or_default(&options)
.to::<bool>(),)
.to::<bool>())
}
}
3 changes: 1 addition & 2 deletions crates/core/src/file_group/base_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ impl TryFrom<FileMetadata> for BaseFile {
#[cfg(test)]
mod tests {
use super::*;
use hudi_tests::assert_not;

#[test]
fn test_create_base_file_from_file_name() {
Expand All @@ -144,7 +143,7 @@ mod tests {
assert_eq!(base_file.commit_timestamp, "20240402144910683");
let file_metadata = base_file.file_metadata.unwrap();
assert_eq!(file_metadata.size, 1024);
assert_not!(file_metadata.fully_populated);
assert!(!file_metadata.fully_populated);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/table/fs_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mod tests {
use crate::expr::filter::Filter;
use crate::table::Table;

use hudi_tests::SampleTable;
use hudi_test::SampleTable;
use std::collections::HashSet;

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/table/listing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl FileLister {
mod test {
use super::*;
use crate::table::Table;
use hudi_tests::SampleTable;
use hudi_test::SampleTable;
use std::collections::HashSet;

#[tokio::test]
Expand Down
8 changes: 4 additions & 4 deletions crates/core/src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ mod tests {
use crate::storage::util::join_url_segments;
use crate::storage::Storage;
use crate::table::Filter;
use hudi_tests::{assert_not, SampleTable};
use hudi_test::SampleTable;
use std::collections::HashSet;
use std::fs::canonicalize;
use std::path::PathBuf;
Expand Down Expand Up @@ -635,7 +635,7 @@ mod tests {
configs.get_or_default(DatabaseName).to::<String>(),
"default"
);
assert_not!(configs.get_or_default(DropsPartitionFields).to::<bool>());
assert!(!configs.get_or_default(DropsPartitionFields).to::<bool>());
assert!(panic::catch_unwind(|| configs.get_or_default(IsHiveStylePartitioning)).is_err());
assert!(panic::catch_unwind(|| configs.get_or_default(IsPartitionPathUrlencoded)).is_err());
assert!(panic::catch_unwind(|| configs.get_or_default(KeyGeneratorClass)).is_err());
Expand Down Expand Up @@ -929,7 +929,7 @@ mod tests {
mod test_snapshot_and_time_travel_queries {
use super::super::*;
use arrow::compute::concat_batches;
use hudi_tests::SampleTable;
use hudi_test::SampleTable;

#[tokio::test]
async fn test_empty() -> Result<()> {
Expand Down Expand Up @@ -1065,7 +1065,7 @@ mod tests {
mod test_incremental_queries {
use super::super::*;
use arrow_select::concat::concat_batches;
use hudi_tests::SampleTable;
use hudi_test::SampleTable;

#[tokio::test]
async fn test_empty() -> Result<()> {
Expand Down
13 changes: 6 additions & 7 deletions crates/core/src/table/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ mod tests {

use arrow::datatypes::{DataType, Field, Schema};
use arrow_array::Date32Array;
use hudi_tests::assert_not;
use std::str::FromStr;

fn create_test_schema() -> Schema {
Expand Down Expand Up @@ -205,15 +204,15 @@ mod tests {
let pruner = pruner.unwrap();
assert_eq!(pruner.and_filters.len(), 2);
assert!(pruner.is_hive_style);
assert_not!(pruner.is_url_encoded);
assert!(!pruner.is_url_encoded);
}

#[test]
fn test_partition_pruner_empty() {
let pruner = PartitionPruner::empty();
assert!(pruner.is_empty());
assert_not!(pruner.is_hive_style);
assert_not!(pruner.is_url_encoded);
assert!(!pruner.is_hive_style);
assert!(!pruner.is_url_encoded);
}

#[test]
Expand All @@ -226,7 +225,7 @@ mod tests {

let filter_gt_date = Filter::try_from(("date", ">", "2023-01-01")).unwrap();
let pruner_non_empty = PartitionPruner::new(&[filter_gt_date], &schema, &configs).unwrap();
assert_not!(pruner_non_empty.is_empty());
assert!(!pruner_non_empty.is_empty());
}

#[test]
Expand All @@ -247,8 +246,8 @@ mod tests {

assert!(pruner.should_include("date=2023-02-01/category=A/count=10"));
assert!(pruner.should_include("date=2023-02-01/category=A/count=100"));
assert_not!(pruner.should_include("date=2022-12-31/category=A/count=10"));
assert_not!(pruner.should_include("date=2023-02-01/category=B/count=10"));
assert!(!pruner.should_include("date=2022-12-31/category=A/count=10"));
assert!(!pruner.should_include("date=2023-02-01/category=B/count=10"));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ mod tests {

use url::Url;

use hudi_tests::SampleTable;
use hudi_test::SampleTable;

use crate::config::table::HudiTableConfig;

Expand Down
3 changes: 1 addition & 2 deletions crates/core/src/timeline/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ mod tests {
use super::*;
use crate::config::table::HudiTableConfig;
use crate::config::HudiConfigs;
use hudi_tests::assert_not;
use std::collections::HashMap;
use std::str::FromStr;
use std::sync::Arc;
Expand Down Expand Up @@ -535,7 +534,7 @@ mod tests {
#[tokio::test]
async fn test_select_no_instants() {
let timeline = create_test_timeline().await;
assert_not!(timeline.completed_commits.is_empty());
assert!(!timeline.completed_commits.is_empty());

let selector = TimelineSelector {
actions: vec![Action::ReplaceCommit],
Expand Down
2 changes: 1 addition & 1 deletion crates/datafusion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ tokio = { workspace = true }
url = { workspace = true }

[dev-dependencies]
hudi-tests = { path = "../tests" }
hudi-test = { path = "../test" }
6 changes: 3 additions & 3 deletions crates/datafusion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,13 @@ mod tests {

use datafusion::logical_expr::BinaryExpr;
use hudi_core::config::read::HudiReadConfig::InputPartitions;
use hudi_tests::SampleTable::{
use hudi_test::SampleTable::{
V6ComplexkeygenHivestyle, V6Empty, V6Nonpartitioned, V6SimplekeygenHivestyleNoMetafields,
V6SimplekeygenNonhivestyle, V6SimplekeygenNonhivestyleOverwritetable,
V6TimebasedkeygenNonhivestyle,
};
use hudi_tests::{utils, SampleTable};
use utils::{get_bool_column, get_i32_column, get_str_column};
use hudi_test::{util, SampleTable};
use util::{get_bool_column, get_i32_column, get_str_column};

use crate::HudiDataSource;
use crate::HudiTableFactory;
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/Cargo.toml → crates/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

[package]
name = "hudi-tests"
name = "hudi-test"
version.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion crates/tests/src/lib.rs → crates/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use strum_macros::{AsRefStr, EnumIter, EnumString};
use tempfile::tempdir;
use url::Url;

pub mod utils;
pub mod util;

pub fn extract_test_table(zip_path: &Path) -> PathBuf {
let target_dir = tempdir().unwrap().path().to_path_buf();
Expand Down
30 changes: 0 additions & 30 deletions crates/tests/src/utils.rs → crates/test/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,6 @@
use arrow::record_batch::RecordBatch;
use arrow_array::{Array, BooleanArray, Int32Array, StringArray};

#[macro_export]
macro_rules! assert_not {
($cond:expr) => {
if $cond {
panic!("assertion failed: condition is true");
}
};
($cond:expr, $($arg:tt)+) => {
if $cond {
panic!("assertion failed: condition is true: {}", format_args!($($arg)+));
}
};
}

#[macro_export]
macro_rules! assert_approx_eq {
($a:expr, $b:expr, $delta:expr) => {{
let a = $a;
let b = $b;
let delta = $delta;
let diff = if a > b { a - b } else { b - a };

assert!(
diff <= delta,
"assertion failed: `(left ≈ right)`\n left: `{:?}`,\n right: `{:?}`,\n delta: `{:?}`",
a, b, delta
);
}};
}

pub fn get_str_column<'a>(record_batch: &'a RecordBatch, name: &str) -> Vec<&'a str> {
record_batch
.column_by_name(name)
Expand Down
2 changes: 1 addition & 1 deletion demo/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
minio:
condition: service_healthy
volumes:
- ../crates/tests/data:/opt/data:ro
- ../crates/test/data:/opt/data:ro
- ./infra/mc/prepare_data.sh:/opt/prepare_data.sh
command:
- /bin/sh
Expand Down

0 comments on commit d450516

Please sign in to comment.