Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzl25 committed Sep 23, 2024
1 parent aef661d commit 0061e53
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/batch/src/monitor/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ impl BatchExecutorMetrics {
}

/// Create a new `BatchTaskMetrics` instance used in tests or other places.
pub fn for_test() -> Self {
GLOBAL_BATCH_EXECUTOR_METRICS.clone()
#[cfg(test)]
pub fn for_test() -> Arc<Self> {
Arc::new(GLOBAL_BATCH_EXECUTOR_METRICS.clone())
}
}

Expand Down Expand Up @@ -89,6 +90,14 @@ impl BatchMetricsInner {
pub fn batch_manager_metrics(&self) -> &BatchManagerMetrics {
&self.batch_manager_metrics
}

#[cfg(test)]
pub fn for_test() -> BatchMetrics {
Arc::new(Self {
batch_manager_metrics: BatchManagerMetrics::for_test(),
executor_metrics: BatchExecutorMetrics::for_test(),
})
}
}

#[derive(Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/batch/src/task/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl ComputeNodeContext {
pub fn for_test() -> Self {
Self {
env: BatchEnvironment::for_test(),
batch_metrics: BatchMetrics::for_test().into(),
batch_metrics: BatchMetricsInner::for_test(),
mem_context: MemoryContext::none(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/batch/src/task/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl BatchEnvironment {
client_pool: Arc::new(ComputeClientPool::for_test()),
dml_manager: Arc::new(DmlManager::for_test()),
source_metrics: Arc::new(SourceMetrics::default()),
executor_metrics: Arc::new(BatchExecutorMetrics::for_test()),
executor_metrics: BatchExecutorMetrics::for_test(),
spill_metrics: BatchSpillMetrics::for_test(),
metric_level: MetricLevel::Debug,
}
Expand Down

0 comments on commit 0061e53

Please sign in to comment.