mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-15 01:32:56 +00:00
fix: test_fulltext_intm_path (#4314)
* fix: test_fulltext_intm_path Signed-off-by: Zhenchi <zhongzc_arch@outlook.com> * address comments Signed-off-by: Zhenchi <zhongzc_arch@outlook.com> --------- Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
This commit is contained in:
@@ -84,7 +84,6 @@ impl IntermediateManager {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct IntermediateLocation {
|
||||
files_dir: String,
|
||||
sst_dir: String,
|
||||
}
|
||||
|
||||
impl IntermediateLocation {
|
||||
@@ -97,13 +96,12 @@ impl IntermediateLocation {
|
||||
let uuid = Uuid::new_v4();
|
||||
Self {
|
||||
files_dir: format!("{INTERMEDIATE_DIR}/{region_id}/{sst_file_id}/{uuid}/"),
|
||||
sst_dir: format!("{INTERMEDIATE_DIR}/{region_id}/{sst_file_id}/"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the directory to clean up when the sorting is done
|
||||
pub fn dir_to_cleanup(&self) -> &str {
|
||||
&self.sst_dir
|
||||
&self.files_dir
|
||||
}
|
||||
|
||||
/// Returns the path of the directory for intermediate files associated with a column:
|
||||
@@ -121,6 +119,8 @@ impl IntermediateLocation {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::ffi::OsStr;
|
||||
|
||||
use common_test_util::temp_dir;
|
||||
use regex::Regex;
|
||||
|
||||
@@ -152,11 +152,6 @@ mod tests {
|
||||
let sst_file_id = FileId::random();
|
||||
let location = IntermediateLocation::new(&RegionId::new(0, 0), &sst_file_id);
|
||||
|
||||
assert_eq!(
|
||||
location.dir_to_cleanup(),
|
||||
format!("{INTERMEDIATE_DIR}/0/{sst_file_id}/")
|
||||
);
|
||||
|
||||
let re = Regex::new(&format!(
|
||||
"{INTERMEDIATE_DIR}/0/{sst_file_id}/{}/",
|
||||
r"\w{8}-\w{4}-\w{4}-\w{4}-\w{12}"
|
||||
@@ -187,21 +182,19 @@ mod tests {
|
||||
let manager = IntermediateManager::init_fs(&aux_path).await.unwrap();
|
||||
let region_id = RegionId::new(0, 0);
|
||||
let sst_file_id = FileId::random();
|
||||
let column_id = 0;
|
||||
let column_id = 1;
|
||||
let fulltext_path = manager.fulltext_path(®ion_id, &sst_file_id, column_id);
|
||||
|
||||
if cfg!(windows) {
|
||||
let p = fulltext_path.to_string_lossy().to_string();
|
||||
let r = Regex::new(&format!(
|
||||
"{aux_path}\\\\{INTERMEDIATE_DIR}\\\\0\\\\{sst_file_id}\\\\fulltext-0-\\w{{8}}-\\w{{4}}-\\w{{4}}-\\w{{4}}-\\w{{12}}",
|
||||
)).unwrap();
|
||||
assert!(r.is_match(&p));
|
||||
} else {
|
||||
let p = fulltext_path.to_string_lossy().to_string();
|
||||
let r = Regex::new(&format!(
|
||||
"{aux_path}/{INTERMEDIATE_DIR}/0/{sst_file_id}/fulltext-0-\\w{{8}}-\\w{{4}}-\\w{{4}}-\\w{{4}}-\\w{{12}}",
|
||||
)).unwrap();
|
||||
assert!(r.is_match(&p));
|
||||
let mut pi = fulltext_path.iter();
|
||||
for a in temp_dir.path().iter() {
|
||||
assert_eq!(a, pi.next().unwrap());
|
||||
}
|
||||
assert_eq!(pi.next().unwrap(), INTERMEDIATE_DIR);
|
||||
assert_eq!(pi.next().unwrap(), "0"); // region id
|
||||
assert_eq!(pi.next().unwrap(), OsStr::new(&sst_file_id.to_string())); // sst file id
|
||||
assert!(Regex::new(r"fulltext-1-\w{8}-\w{4}-\w{4}-\w{4}-\w{12}")
|
||||
.unwrap()
|
||||
.is_match(&pi.next().unwrap().to_string_lossy())); // fulltext path
|
||||
assert!(pi.next().is_none());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user