refactor: move test builders out of compactor2 code (#6953)
* refactor: move test builders out of compactor2 code * fix: docspull/24376/head
parent
de765a99b7
commit
779fb93ce7
|
@ -126,7 +126,7 @@ mod tests {
|
|||
use arrow_util::assert_batches_sorted_eq;
|
||||
use backoff::BackoffConfig;
|
||||
use data_types::{ColumnType, CompactionLevel, ParquetFileId};
|
||||
use iox_tests::util::{TestCatalog, TestParquetFileBuilder, TestTable};
|
||||
use iox_tests::{TestCatalog, TestParquetFileBuilder, TestTable};
|
||||
use iox_time::{SystemProvider, TimeProvider};
|
||||
use parquet_file::storage::StorageId;
|
||||
use std::collections::HashMap;
|
||||
|
|
|
@ -602,7 +602,7 @@ pub mod tests {
|
|||
ColumnId, ColumnSet, CompactionLevel, ParquetFileParams, SequenceNumber, ShardIndex,
|
||||
Timestamp,
|
||||
};
|
||||
use iox_tests::util::{TestCatalog, TestPartition};
|
||||
use iox_tests::{TestCatalog, TestPartition};
|
||||
use iox_time::SystemProvider;
|
||||
use parquet_file::storage::StorageId;
|
||||
use uuid::Uuid;
|
||||
|
|
|
@ -98,7 +98,7 @@ mod tests {
|
|||
ShardIndex,
|
||||
};
|
||||
use futures::{StreamExt, TryStreamExt};
|
||||
use iox_tests::util::TestCatalog;
|
||||
use iox_tests::TestCatalog;
|
||||
use std::time::Duration;
|
||||
use uuid::Uuid;
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ mod tests {
|
|||
};
|
||||
use backoff::BackoffConfig;
|
||||
use data_types::CompactionLevel;
|
||||
use iox_tests::util::{TestCatalog, TestParquetFileBuilder, TestShard, TestTable};
|
||||
use iox_tests::{TestCatalog, TestParquetFileBuilder, TestShard, TestTable};
|
||||
use iox_time::TimeProvider;
|
||||
use parquet_file::storage::{ParquetStorage, StorageId};
|
||||
use std::sync::Arc;
|
||||
|
|
|
@ -545,9 +545,7 @@ pub mod tests {
|
|||
use arrow_util::assert_batches_sorted_eq;
|
||||
use backoff::BackoffConfig;
|
||||
use data_types::{ColumnType, CompactionLevel, ParquetFileId};
|
||||
use iox_tests::util::{
|
||||
TestCatalog, TestParquetFileBuilder, TestPartition, TestShard, TestTable,
|
||||
};
|
||||
use iox_tests::{TestCatalog, TestParquetFileBuilder, TestPartition, TestShard, TestTable};
|
||||
use iox_time::{SystemProvider, TimeProvider};
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
|
|
|
@ -126,7 +126,7 @@ impl From<CompactorParquetFile> for ParquetFile {
|
|||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use iox_tests::util::TestParquetFile;
|
||||
use iox_tests::TestParquetFile;
|
||||
|
||||
impl From<TestParquetFile> for CompactorParquetFile {
|
||||
fn from(tpf: TestParquetFile) -> Self {
|
||||
|
|
|
@ -884,7 +884,7 @@ mod tests {
|
|||
use arrow::record_batch::RecordBatch;
|
||||
use arrow_util::{assert_batches_eq, assert_batches_sorted_eq};
|
||||
use data_types::{ColumnType, PartitionParam};
|
||||
use iox_tests::util::{TestCatalog, TestParquetFileBuilder, TestTable};
|
||||
use iox_tests::{TestCatalog, TestParquetFileBuilder, TestTable};
|
||||
use iox_time::SystemProvider;
|
||||
use itertools::Itertools;
|
||||
use metric::U64HistogramOptions;
|
||||
|
|
|
@ -211,7 +211,7 @@ mod tests {
|
|||
use super::*;
|
||||
use backoff::BackoffConfig;
|
||||
use data_types::ColumnType;
|
||||
use iox_tests::util::{TestCatalog, TestParquetFileBuilder, TestPartition};
|
||||
use iox_tests::{TestCatalog, TestParquetFileBuilder, TestPartition};
|
||||
use iox_time::{SystemProvider, TimeProvider};
|
||||
use parquet_file::storage::{ParquetStorage, StorageId};
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ impl QueryChunk for QueryableParquetChunk {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use data_types::ColumnType;
|
||||
use iox_tests::util::{TestCatalog, TestParquetFileBuilder};
|
||||
use iox_tests::{TestCatalog, TestParquetFileBuilder};
|
||||
use iox_time::{SystemProvider, TimeProvider};
|
||||
use parquet_file::storage::{ParquetStorage, StorageId};
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ mod tests {
|
|||
use backoff::BackoffConfig;
|
||||
use data_types::{ColumnType, CompactionLevel, TablePartition, Timestamp};
|
||||
use futures::{stream::FuturesUnordered, StreamExt};
|
||||
use iox_tests::util::{TestCatalog, TestParquetFileBuilder};
|
||||
use iox_tests::{TestCatalog, TestParquetFileBuilder};
|
||||
use iox_time::{SystemProvider, Time, TimeProvider};
|
||||
use parquet_file::storage::{ParquetStorage, StorageId};
|
||||
use std::sync::Arc;
|
||||
|
|
|
@ -82,12 +82,9 @@ mod tests {
|
|||
|
||||
use test_helpers::tracing::TracingCapture;
|
||||
|
||||
use crate::{
|
||||
components::commit::mock::{CommitHistoryEntry, MockCommit},
|
||||
test_util::ParquetFileBuilder,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
use crate::components::commit::mock::{CommitHistoryEntry, MockCommit};
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
#[test]
|
||||
fn test_display() {
|
||||
|
|
|
@ -208,10 +208,8 @@ mod tests {
|
|||
|
||||
use metric::{Attributes, HistogramObservation, Metric};
|
||||
|
||||
use crate::{
|
||||
components::commit::mock::{CommitHistoryEntry, MockCommit},
|
||||
test_util::ParquetFileBuilder,
|
||||
};
|
||||
use crate::components::commit::mock::{CommitHistoryEntry, MockCommit};
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ impl Commit for MockCommit {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util::ParquetFileBuilder;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ impl DivideInitial for SingleBranchDivideInitial {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util::ParquetFileBuilder;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ impl FileFilter for LevelRangeFileFilter {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util::ParquetFileBuilder;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ impl LevelExist for OneLevelExist {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util::ParquetFileBuilder;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ impl PartitionFilesSource for MockPartitionFilesSource {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util::ParquetFileBuilder;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -61,9 +61,8 @@ where
|
|||
mod tests {
|
||||
use data_types::CompactionLevel;
|
||||
|
||||
use crate::{
|
||||
components::file_filter::level_range::LevelRangeFileFilter, test_util::ParquetFileBuilder,
|
||||
};
|
||||
use crate::components::file_filter::level_range::LevelRangeFileFilter;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -74,9 +74,8 @@ where
|
|||
mod tests {
|
||||
use data_types::CompactionLevel;
|
||||
|
||||
use crate::{
|
||||
components::file_filter::level_range::LevelRangeFileFilter, test_util::ParquetFileBuilder,
|
||||
};
|
||||
use crate::components::file_filter::level_range::LevelRangeFileFilter;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ impl PartitionFilter for HasFilesPartitionFilter {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util::ParquetFileBuilder;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -51,9 +51,8 @@ where
|
|||
mod tests {
|
||||
use data_types::CompactionLevel;
|
||||
|
||||
use crate::{
|
||||
components::file_filter::level_range::LevelRangeFileFilter, test_util::ParquetFileBuilder,
|
||||
};
|
||||
use crate::components::file_filter::level_range::LevelRangeFileFilter;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -73,10 +73,8 @@ where
|
|||
mod tests {
|
||||
use test_helpers::tracing::TracingCapture;
|
||||
|
||||
use crate::{
|
||||
components::partition_filter::has_files::HasFilesPartitionFilter,
|
||||
test_util::ParquetFileBuilder,
|
||||
};
|
||||
use crate::components::partition_filter::has_files::HasFilesPartitionFilter;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ impl PartitionFilter for MaxFilesPartitionFilter {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{error::ErrorKindExt, test_util::ParquetFileBuilder};
|
||||
use crate::error::ErrorKindExt;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ impl PartitionFilter for MaxParquetBytesPartitionFilter {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{error::ErrorKindExt, test_util::ParquetFileBuilder};
|
||||
use crate::error::ErrorKindExt;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -83,10 +83,8 @@ where
|
|||
mod tests {
|
||||
use metric::{Attributes, Metric};
|
||||
|
||||
use crate::{
|
||||
components::partition_filter::has_files::HasFilesPartitionFilter,
|
||||
test_util::ParquetFileBuilder,
|
||||
};
|
||||
use crate::components::partition_filter::has_files::HasFilesPartitionFilter;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -55,9 +55,8 @@ where
|
|||
mod tests {
|
||||
use test_helpers::tracing::TracingCapture;
|
||||
|
||||
use crate::{
|
||||
components::partition_source::mock::MockPartitionSource, test_util::PartitionBuilder,
|
||||
};
|
||||
use crate::components::partition_source::mock::MockPartitionSource;
|
||||
use iox_tests::PartitionBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -64,9 +64,8 @@ where
|
|||
mod tests {
|
||||
use metric::{Attributes, Metric};
|
||||
|
||||
use crate::{
|
||||
components::partition_source::mock::MockPartitionSource, test_util::PartitionBuilder,
|
||||
};
|
||||
use crate::components::partition_source::mock::MockPartitionSource;
|
||||
use iox_tests::PartitionBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ impl PartitionSource for MockPartitionSource {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util::PartitionBuilder;
|
||||
use iox_tests::PartitionBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ impl RoundSplit for AllNowRoundSplit {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util::ParquetFileBuilder;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ impl SkippedCompactionsSource for MockSkippedCompactionsSource {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util::SkippedCompactionBuilder;
|
||||
use iox_tests::SkippedCompactionBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ impl TablesSource for MockTablesSource {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util::TableBuilder;
|
||||
use iox_tests::TableBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ impl TargetLevelChooser for AllAtOnceTargetLevelChooser {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util::ParquetFileBuilder;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -58,7 +58,8 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{components::level_exist::one_level::OneLevelExist, test_util::ParquetFileBuilder};
|
||||
use crate::components::level_exist::one_level::OneLevelExist;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ pub fn split_by_level(
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::test_util::ParquetFileBuilder;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
#[test]
|
||||
fn files_time_range_empty() {
|
||||
|
|
|
@ -14,21 +14,20 @@ use std::{
|
|||
use async_trait::async_trait;
|
||||
use backoff::BackoffConfig;
|
||||
use data_types::{
|
||||
ColumnId, ColumnSchema, ColumnSet, ColumnType, CompactionLevel, Namespace, NamespaceId,
|
||||
NamespaceSchema, ParquetFile, ParquetFileId, Partition, PartitionId, PartitionKey, QueryPoolId,
|
||||
SequenceNumber, ShardId, SkippedCompaction, Table, TableId, TableSchema, Timestamp, TopicId,
|
||||
ColumnId, ColumnSchema, ColumnType, CompactionLevel, Namespace, NamespaceId, NamespaceSchema,
|
||||
ParquetFile, PartitionId, PartitionKey, QueryPoolId, Table, TableId, TableSchema, TopicId,
|
||||
TRANSITION_SHARD_NUMBER,
|
||||
};
|
||||
use datafusion::arrow::record_batch::RecordBatch;
|
||||
use futures::TryStreamExt;
|
||||
use iox_tests::util::{
|
||||
TestCatalog, TestNamespace, TestParquetFileBuilder, TestPartition, TestShard, TestTable,
|
||||
use iox_tests::{
|
||||
ParquetFileBuilder, TestCatalog, TestNamespace, TestParquetFileBuilder, TestPartition,
|
||||
TestShard, TestTable,
|
||||
};
|
||||
use iox_time::TimeProvider;
|
||||
use object_store::{path::Path, DynObjectStore};
|
||||
use parquet_file::storage::{ParquetStorage, StorageId};
|
||||
use schema::sort::SortKey;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
components::{
|
||||
|
@ -42,116 +41,7 @@ use crate::{
|
|||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ParquetFileBuilder {
|
||||
file: ParquetFile,
|
||||
}
|
||||
|
||||
impl ParquetFileBuilder {
|
||||
pub fn new(id: i64) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
id: ParquetFileId::new(id),
|
||||
shard_id: ShardId::new(0),
|
||||
namespace_id: NamespaceId::new(0),
|
||||
table_id: TableId::new(0),
|
||||
partition_id: PartitionId::new(0),
|
||||
object_store_id: Uuid::from_u128(id.try_into().expect("invalid id")),
|
||||
max_sequence_number: SequenceNumber::new(0),
|
||||
min_time: Timestamp::new(0),
|
||||
max_time: Timestamp::new(0),
|
||||
to_delete: None,
|
||||
file_size_bytes: 1,
|
||||
row_count: 1,
|
||||
compaction_level: CompactionLevel::FileNonOverlapped,
|
||||
created_at: Timestamp::new(0),
|
||||
column_set: ColumnSet::new(vec![]),
|
||||
max_l0_created_at: Timestamp::new(0),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_partition(self, id: i64) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
partition_id: PartitionId::new(id),
|
||||
..self.file
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_compaction_level(self, level: CompactionLevel) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
compaction_level: level,
|
||||
..self.file
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_file_size_bytes(self, file_size_bytes: i64) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
file_size_bytes,
|
||||
..self.file
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_time_range(self, min_time: i64, max_time: i64) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
min_time: Timestamp::new(min_time),
|
||||
max_time: Timestamp::new(max_time),
|
||||
..self.file
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_row_count(self, row_count: i64) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
row_count,
|
||||
..self.file
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build(self) -> ParquetFile {
|
||||
self.file
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TableBuilder {
|
||||
table: Table,
|
||||
}
|
||||
|
||||
impl TableBuilder {
|
||||
pub fn new(id: i64) -> Self {
|
||||
Self {
|
||||
table: Table {
|
||||
id: TableId::new(id),
|
||||
namespace_id: NamespaceId::new(0),
|
||||
name: "table".to_string(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_name(self, name: &str) -> Self {
|
||||
Self {
|
||||
table: Table {
|
||||
name: name.to_string(),
|
||||
..self.table
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build(self) -> Table {
|
||||
self.table
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Build [`NamespaceWrapper`] for testing
|
||||
pub struct NamespaceBuilder {
|
||||
namespace: NamespaceWrapper,
|
||||
}
|
||||
|
@ -245,66 +135,6 @@ impl NamespaceBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PartitionBuilder {
|
||||
partition: Partition,
|
||||
}
|
||||
|
||||
impl PartitionBuilder {
|
||||
pub fn new(id: i64) -> Self {
|
||||
Self {
|
||||
partition: Partition {
|
||||
id: PartitionId::new(id),
|
||||
shard_id: ShardId::new(0),
|
||||
table_id: TableId::new(0),
|
||||
partition_key: PartitionKey::from("key"),
|
||||
sort_key: vec![],
|
||||
persisted_sequence_number: None,
|
||||
new_file_at: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build(self) -> Partition {
|
||||
self.partition
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SkippedCompactionBuilder {
|
||||
skipped_compaction: SkippedCompaction,
|
||||
}
|
||||
|
||||
impl SkippedCompactionBuilder {
|
||||
pub fn new(id: i64) -> Self {
|
||||
Self {
|
||||
skipped_compaction: SkippedCompaction {
|
||||
partition_id: PartitionId::new(id),
|
||||
reason: "test skipped compaction".to_string(),
|
||||
skipped_at: Timestamp::new(0),
|
||||
num_files: 0,
|
||||
limit_num_files: 0,
|
||||
estimated_bytes: 0,
|
||||
limit_bytes: 0,
|
||||
limit_num_files_first_in_partition: 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_reason(self, reason: &str) -> Self {
|
||||
Self {
|
||||
skipped_compaction: SkippedCompaction {
|
||||
reason: reason.to_string(),
|
||||
..self.skipped_compaction
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build(self) -> SkippedCompaction {
|
||||
self.skipped_compaction
|
||||
}
|
||||
}
|
||||
|
||||
// Default values for the test setup builder
|
||||
const SHARD_INDEX: i32 = TRANSITION_SHARD_NUMBER;
|
||||
const PARTITION_THRESHOLD: Duration = Duration::from_secs(10 * 60); // 10min
|
||||
|
|
|
@ -297,7 +297,7 @@ fn display_format(file: &ParquetFile, show_size: bool) -> String {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::test_util::ParquetFileBuilder;
|
||||
use iox_tests::ParquetFileBuilder;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::time::Duration;
|
|||
|
||||
use arrow_util::assert_batches_sorted_eq;
|
||||
use data_types::{CompactionLevel, ParquetFile, PartitionId};
|
||||
use iox_tests::util::TestParquetFileBuilder;
|
||||
use iox_tests::TestParquetFileBuilder;
|
||||
|
||||
use crate::{
|
||||
config::AlgoVersion,
|
||||
|
|
|
@ -0,0 +1,195 @@
|
|||
use data_types::{
|
||||
ColumnSet, CompactionLevel, NamespaceId, ParquetFile, ParquetFileId, Partition, PartitionId,
|
||||
PartitionKey, SequenceNumber, ShardId, SkippedCompaction, Table, TableId, Timestamp,
|
||||
};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Build up [`ParquetFile`]s for testing
|
||||
pub struct ParquetFileBuilder {
|
||||
file: ParquetFile,
|
||||
}
|
||||
|
||||
impl ParquetFileBuilder {
|
||||
/// Create a builder that will create a parquet file with
|
||||
/// `parquet_id` of `id`
|
||||
pub fn new(id: i64) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
id: ParquetFileId::new(id),
|
||||
shard_id: ShardId::new(0),
|
||||
namespace_id: NamespaceId::new(0),
|
||||
table_id: TableId::new(0),
|
||||
partition_id: PartitionId::new(0),
|
||||
object_store_id: Uuid::from_u128(id.try_into().expect("invalid id")),
|
||||
max_sequence_number: SequenceNumber::new(0),
|
||||
min_time: Timestamp::new(0),
|
||||
max_time: Timestamp::new(0),
|
||||
to_delete: None,
|
||||
file_size_bytes: 1,
|
||||
row_count: 1,
|
||||
compaction_level: CompactionLevel::FileNonOverlapped,
|
||||
created_at: Timestamp::new(0),
|
||||
column_set: ColumnSet::new(vec![]),
|
||||
max_l0_created_at: Timestamp::new(0),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the partition id
|
||||
pub fn with_partition(self, id: i64) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
partition_id: PartitionId::new(id),
|
||||
..self.file
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the compaction level
|
||||
pub fn with_compaction_level(self, level: CompactionLevel) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
compaction_level: level,
|
||||
..self.file
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the file size
|
||||
pub fn with_file_size_bytes(self, file_size_bytes: i64) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
file_size_bytes,
|
||||
..self.file
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the min/max time range
|
||||
pub fn with_time_range(self, min_time: i64, max_time: i64) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
min_time: Timestamp::new(min_time),
|
||||
max_time: Timestamp::new(max_time),
|
||||
..self.file
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the row_count
|
||||
pub fn with_row_count(self, row_count: i64) -> Self {
|
||||
Self {
|
||||
file: ParquetFile {
|
||||
row_count,
|
||||
..self.file
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Create the [`ParquetFile`]
|
||||
pub fn build(self) -> ParquetFile {
|
||||
self.file
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Build [`Table`]s for testing
|
||||
pub struct TableBuilder {
|
||||
table: Table,
|
||||
}
|
||||
|
||||
impl TableBuilder {
|
||||
/// Create a builder to create a table with `table_id` `id`
|
||||
pub fn new(id: i64) -> Self {
|
||||
Self {
|
||||
table: Table {
|
||||
id: TableId::new(id),
|
||||
namespace_id: NamespaceId::new(0),
|
||||
name: "table".to_string(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the table name
|
||||
pub fn with_name(self, name: &str) -> Self {
|
||||
Self {
|
||||
table: Table {
|
||||
name: name.to_string(),
|
||||
..self.table
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Create the table
|
||||
pub fn build(self) -> Table {
|
||||
self.table
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Builds [`Partition`]s for testing
|
||||
pub struct PartitionBuilder {
|
||||
partition: Partition,
|
||||
}
|
||||
|
||||
impl PartitionBuilder {
|
||||
/// Create a builder to create a partition with `partition_id` `id`
|
||||
pub fn new(id: i64) -> Self {
|
||||
Self {
|
||||
partition: Partition {
|
||||
id: PartitionId::new(id),
|
||||
shard_id: ShardId::new(0),
|
||||
table_id: TableId::new(0),
|
||||
partition_key: PartitionKey::from("key"),
|
||||
sort_key: vec![],
|
||||
persisted_sequence_number: None,
|
||||
new_file_at: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Create the partition
|
||||
pub fn build(self) -> Partition {
|
||||
self.partition
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
/// A builder to create a skipped compaction record
|
||||
pub struct SkippedCompactionBuilder {
|
||||
skipped_compaction: SkippedCompaction,
|
||||
}
|
||||
|
||||
impl SkippedCompactionBuilder {
|
||||
/// Create the builder for skipped_compaction_id = id
|
||||
pub fn new(id: i64) -> Self {
|
||||
Self {
|
||||
skipped_compaction: SkippedCompaction {
|
||||
partition_id: PartitionId::new(id),
|
||||
reason: "test skipped compaction".to_string(),
|
||||
skipped_at: Timestamp::new(0),
|
||||
num_files: 0,
|
||||
limit_num_files: 0,
|
||||
estimated_bytes: 0,
|
||||
limit_bytes: 0,
|
||||
limit_num_files_first_in_partition: 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Add a reason for the skipped compaction
|
||||
pub fn with_reason(self, reason: &str) -> Self {
|
||||
Self {
|
||||
skipped_compaction: SkippedCompaction {
|
||||
reason: reason.to_string(),
|
||||
..self.skipped_compaction
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the skipped compaction
|
||||
pub fn build(self) -> SkippedCompaction {
|
||||
self.skipped_compaction
|
||||
}
|
||||
}
|
|
@ -12,4 +12,11 @@
|
|||
clippy::dbg_macro
|
||||
)]
|
||||
|
||||
pub mod util;
|
||||
mod catalog;
|
||||
pub use catalog::{
|
||||
TestCatalog, TestNamespace, TestParquetFile, TestParquetFileBuilder, TestPartition, TestShard,
|
||||
TestTable,
|
||||
};
|
||||
|
||||
mod builders;
|
||||
pub use builders::{ParquetFileBuilder, PartitionBuilder, SkippedCompactionBuilder, TableBuilder};
|
||||
|
|
|
@ -88,7 +88,7 @@ impl proto::namespace_service_server::NamespaceService for NamespaceServiceImpl
|
|||
mod tests {
|
||||
use super::*;
|
||||
use generated_types::influxdata::iox::namespace::v1::namespace_service_server::NamespaceService;
|
||||
use iox_tests::util::TestCatalog;
|
||||
use iox_tests::TestCatalog;
|
||||
use querier::{create_ingester_connection_for_testing, QuerierCatalogCache};
|
||||
use tokio::runtime::Handle;
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ mod tests {
|
|||
use crate::cache::{ram::test_util::test_ram_pool, test_util::assert_histogram_metric_count};
|
||||
use arrow::datatypes::DataType;
|
||||
use data_types::ColumnType;
|
||||
use iox_tests::util::TestCatalog;
|
||||
use iox_tests::TestCatalog;
|
||||
use schema::SchemaBuilder;
|
||||
|
||||
use super::*;
|
||||
|
|
|
@ -314,7 +314,7 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
use data_types::{ColumnType, ParquetFileId};
|
||||
use iox_tests::util::{
|
||||
use iox_tests::{
|
||||
TestCatalog, TestNamespace, TestParquetFile, TestParquetFileBuilder, TestPartition,
|
||||
TestTable,
|
||||
};
|
||||
|
|
|
@ -224,7 +224,7 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::cache::{ram::test_util::test_ram_pool, test_util::assert_histogram_metric_count};
|
||||
use data_types::ColumnType;
|
||||
use iox_tests::util::TestCatalog;
|
||||
use iox_tests::TestCatalog;
|
||||
use schema::{Schema, SchemaBuilder};
|
||||
|
||||
#[tokio::test]
|
||||
|
|
|
@ -139,7 +139,7 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::cache::{ram::test_util::test_ram_pool, test_util::assert_histogram_metric_count};
|
||||
use data_types::ColumnType;
|
||||
use iox_tests::util::{TestCatalog, TestParquetFileBuilder};
|
||||
use iox_tests::{TestCatalog, TestParquetFileBuilder};
|
||||
|
||||
const TABLE_LINE_PROTOCOL: &str = "table foo=1 11";
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
use data_types::TombstoneId;
|
||||
use iox_tests::util::TestCatalog;
|
||||
use iox_tests::TestCatalog;
|
||||
|
||||
use crate::cache::{ram::test_util::test_ram_pool, test_util::assert_histogram_metric_count};
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ pub async fn create_sharder(
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::create_ingester_connection_for_testing;
|
||||
use iox_tests::util::TestCatalog;
|
||||
use iox_tests::TestCatalog;
|
||||
use test_helpers::assert_error;
|
||||
use tokio::runtime::Handle;
|
||||
|
||||
|
|
|
@ -1393,7 +1393,7 @@ mod tests {
|
|||
use data_types::TableId;
|
||||
use generated_types::influxdata::iox::ingester::v1::PartitionStatus;
|
||||
use influxdb_iox_client::flight::generated_types::IngesterQueryResponseMetadata;
|
||||
use iox_tests::util::TestCatalog;
|
||||
use iox_tests::TestCatalog;
|
||||
use metric::Attributes;
|
||||
use mutable_batch_lp::test_helpers::lp_to_mutable_batch;
|
||||
use schema::{builder::SchemaBuilder, InfluxFieldType};
|
||||
|
|
|
@ -141,7 +141,7 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::namespace::test_util::querier_namespace;
|
||||
use data_types::ColumnType;
|
||||
use iox_tests::util::TestCatalog;
|
||||
use iox_tests::TestCatalog;
|
||||
use schema::{
|
||||
builder::SchemaBuilder, InfluxColumnType, InfluxFieldType, Schema, TIME_COLUMN_NAME,
|
||||
};
|
||||
|
|
|
@ -203,7 +203,7 @@ mod tests {
|
|||
use data_types::ColumnType;
|
||||
use datafusion::common::DataFusionError;
|
||||
use iox_query::frontend::sql::SqlQueryPlanner;
|
||||
use iox_tests::util::{TestCatalog, TestParquetFileBuilder};
|
||||
use iox_tests::{TestCatalog, TestParquetFileBuilder};
|
||||
use metric::{Observation, RawReporter};
|
||||
use regex::Regex;
|
||||
use snafu::{ResultExt, Snafu};
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
use data_types::{ShardIndex, TableId};
|
||||
use iox_catalog::interface::get_schema_by_name;
|
||||
use iox_query::exec::ExecutorType;
|
||||
use iox_tests::util::TestNamespace;
|
||||
use iox_tests::TestNamespace;
|
||||
use sharder::JumpHash;
|
||||
use std::sync::Arc;
|
||||
use tokio::runtime::Handle;
|
||||
|
|
|
@ -172,7 +172,7 @@ pub mod tests {
|
|||
exec::{ExecutorType, IOxSessionContext},
|
||||
QueryChunk, QueryChunkMeta,
|
||||
};
|
||||
use iox_tests::util::{TestCatalog, TestNamespace, TestParquetFileBuilder};
|
||||
use iox_tests::{TestCatalog, TestNamespace, TestParquetFileBuilder};
|
||||
use metric::{Attributes, Observation, RawReporter};
|
||||
use predicate::Predicate;
|
||||
use schema::{builder::SchemaBuilder, sort::SortKeyBuilder};
|
||||
|
|
|
@ -556,7 +556,7 @@ mod tests {
|
|||
use assert_matches::assert_matches;
|
||||
use data_types::{ChunkId, ColumnType, CompactionLevel, SequenceNumber};
|
||||
use iox_query::exec::IOxSessionContext;
|
||||
use iox_tests::util::{TestCatalog, TestParquetFileBuilder, TestTable};
|
||||
use iox_tests::{TestCatalog, TestParquetFileBuilder, TestTable};
|
||||
use iox_time::TimeProvider;
|
||||
use predicate::Predicate;
|
||||
use schema::{builder::SchemaBuilder, InfluxFieldType};
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
use arrow::record_batch::RecordBatch;
|
||||
use data_types::{ChunkId, SequenceNumber, ShardIndex};
|
||||
use iox_catalog::interface::get_schema_by_name;
|
||||
use iox_tests::util::{TestCatalog, TestPartition, TestShard, TestTable};
|
||||
use iox_tests::{TestCatalog, TestPartition, TestShard, TestTable};
|
||||
use mutable_batch_lp::test_helpers::lp_to_mutable_batch;
|
||||
use schema::{sort::SortKey, Projection, Schema};
|
||||
use sharder::JumpHash;
|
||||
|
|
|
@ -127,7 +127,7 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use iox_tests::util::{TestCatalog, TestNamespace};
|
||||
use iox_tests::{TestCatalog, TestNamespace};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
|
@ -487,7 +487,7 @@ mod tests {
|
|||
|
||||
use assert_matches::assert_matches;
|
||||
use data_types::{ColumnType, TimestampRange};
|
||||
use iox_tests::util::{TestCatalog, TestNamespace};
|
||||
use iox_tests::{TestCatalog, TestNamespace};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in New Issue