test: share populate_catalog() across tests
Parametrises test_util::populate_catalog() and exports for re-use in
ingester tests.
@@ -626,7 +626,8 @@ pub(crate) async fn make_ingester_data(two_partitions: bool, loc: DataLocation)
// Make data for one shard and two tables
let shard_index = ShardIndex::new(1);
- let shard_id = populate_catalog(&*catalog).await;
+ let (shard_id, _, _) =
+ populate_catalog(&*catalog, shard_index, TEST_NAMESPACE, TEST_TABLE).await;
let ingester = IngesterData::new(
object_store,
@@ -693,7 +694,8 @@ pub(crate) async fn make_ingester_data_with_tombstones(loc: DataLocation) -> Ing
// Make data for one shard and two tables
let shard_index = ShardIndex::new(0);
- let shard_id = populate_catalog(&*catalog).await;
+ let (shard_id, _, _) =
+ populate_catalog(&*catalog, shard_index, TEST_NAMESPACE, TEST_TABLE).await;
let ingester = IngesterData::new(
object_store,
@@ -1020,15 +1022,19 @@ fn make_first_partition_data(
(out, SequenceNumber::new(seq_num))
}
-async fn populate_catalog(catalog: &dyn Catalog) -> ShardId {
+pub(crate) async fn populate_catalog(
+ catalog: &dyn Catalog,
+ shard_index: ShardIndex,
+ namespace: &str,
+ table: &str,
+) -> (ShardId, NamespaceId, TableId) {
let mut c = catalog.repositories().await;
- let topic = c.topics().create_or_get("whatevs").await.unwrap();
- let query_pool = c.query_pools().create_or_get("whatevs").await.unwrap();
- let shard_index = ShardIndex::new(0);
+ let topic = c.topics().create_or_get("kafka-topic").await.unwrap();
+ let query_pool = c.query_pools().create_or_get("query-pool").await.unwrap();
let ns_id = c
.namespaces()
.create(
- TEST_NAMESPACE,
+ namespace,
iox_catalog::INFINITE_RETENTION_POLICY,
topic.id,
query_pool.id,
@@ -1036,10 +1042,12 @@ async fn populate_catalog(catalog: &dyn Catalog) -> ShardId {
.await
.unwrap()
.id;
- c.tables().create_or_get(TEST_TABLE, ns_id).await.unwrap();
- c.shards()
+ let table_id = c.tables().create_or_get(table, ns_id).await.unwrap().id;
+ let shard_id = c
+ .shards()
.create_or_get(&topic, shard_index)
.await
.unwrap()
- .id
+ .id;
+ (shard_id, ns_id, table_id)
}
