test: Keep track of namespaces by ID in ingester TestContext

pull/24376/head
Carol (Nichols || Goulding) 2022-11-14 15:41:33 -05:00
parent e2d2e69076
commit c203e8295f
No known key found for this signature in database
GPG Key ID: E907EE5A736F87D4
1 changed files with 20 additions and 10 deletions

View File

@ -1,8 +1,8 @@
use std::{collections::HashMap, num::NonZeroU32, sync::Arc, time::Duration}; use std::{collections::HashMap, num::NonZeroU32, sync::Arc, time::Duration};
use data_types::{ use data_types::{
Namespace, NamespaceSchema, PartitionKey, QueryPoolId, Sequence, SequenceNumber, ShardId, Namespace, NamespaceId, NamespaceSchema, PartitionKey, QueryPoolId, Sequence, SequenceNumber,
ShardIndex, TableId, TopicId, ShardId, ShardIndex, TableId, TopicId,
}; };
use dml::{DmlMeta, DmlWrite}; use dml::{DmlMeta, DmlWrite};
use futures::{stream::FuturesUnordered, StreamExt}; use futures::{stream::FuturesUnordered, StreamExt};
@ -53,9 +53,9 @@ pub struct TestContext {
topic_id: TopicId, topic_id: TopicId,
shard_id: ShardId, shard_id: ShardId,
// A map of namespaces to schemas, also serving as the set of known // A map of namespace IDs to schemas, also serving as the set of known
// namespaces. // namespaces.
namespaces: HashMap<String, NamespaceSchema>, namespaces: HashMap<NamespaceId, NamespaceSchema>,
catalog: Arc<dyn Catalog>, catalog: Arc<dyn Catalog>,
object_store: Arc<DynObjectStore>, object_store: Arc<DynObjectStore>,
@ -188,7 +188,7 @@ impl TestContext {
assert!( assert!(
self.namespaces self.namespaces
.insert( .insert(
name.to_owned(), ns.id,
NamespaceSchema::new( NamespaceSchema::new(
ns.id, ns.id,
self.topic_id, self.topic_id,
@ -219,7 +219,7 @@ impl TestContext {
pub async fn enqueue_write(&mut self, op: DmlWrite) -> SequenceNumber { pub async fn enqueue_write(&mut self, op: DmlWrite) -> SequenceNumber {
let schema = self let schema = self
.namespaces .namespaces
.get_mut(op.namespace()) .get_mut(&op.namespace_id())
.expect("namespace does not exist"); .expect("namespace does not exist");
// Pull the sequence number out of the op to return it back to the user // Pull the sequence number out of the op to return it back to the user
@ -259,8 +259,13 @@ impl TestContext {
) -> SequenceNumber { ) -> SequenceNumber {
// Resolve the namespace ID needed to construct the DML op // Resolve the namespace ID needed to construct the DML op
let namespace_id = self let namespace_id = self
.namespaces .catalog
.get(namespace) .repositories()
.await
.namespaces()
.get_by_name(namespace)
.await
.expect("should be able to get namespace by name")
.expect("namespace does not exist") .expect("namespace does not exist")
.id; .id;
@ -307,8 +312,13 @@ impl TestContext {
/// Return the [`TableId`] in the catalog for `name`, or panic. /// Return the [`TableId`] in the catalog for `name`, or panic.
pub async fn table_id(&self, namespace: &str, name: &str) -> TableId { pub async fn table_id(&self, namespace: &str, name: &str) -> TableId {
let namespace_id = self let namespace_id = self
.namespaces .catalog
.get(namespace) .repositories()
.await
.namespaces()
.get_by_name(namespace)
.await
.expect("should be able to get namespace by name")
.expect("namespace does not exist") .expect("namespace does not exist")
.id; .id;