-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add logging for embedded meta test (#16384)
- Loading branch information
1 parent
bfab76d
commit 0ad9fdc
Showing
7 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ | |
|
||
mod kv_api_impl; | ||
mod schema_api_impl; | ||
mod testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2021 Datafuse Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::collections::BTreeMap; | ||
use std::sync::Once; | ||
|
||
use databend_common_base::base::tokio; | ||
use databend_common_tracing::closure_name; | ||
use databend_common_tracing::init_logging; | ||
use databend_common_tracing::Config; | ||
use fastrace::prelude::*; | ||
|
||
pub fn embedded_meta_test_harness<F, Fut>(test: F) | ||
where | ||
F: FnOnce() -> Fut + 'static, | ||
Fut: std::future::Future<Output = anyhow::Result<()>> + Send + 'static, | ||
{ | ||
setup_test(); | ||
|
||
let rt = tokio::runtime::Builder::new_multi_thread() | ||
.worker_threads(3) | ||
.enable_all() | ||
.build() | ||
.unwrap(); | ||
let root = Span::root(closure_name::<F>(), SpanContext::random()); | ||
let test = test().in_span(root); | ||
rt.block_on(test).unwrap(); | ||
|
||
shutdown_test(); | ||
} | ||
|
||
fn setup_test() { | ||
static INIT: Once = Once::new(); | ||
INIT.call_once(|| { | ||
let t = tempfile::tempdir().expect("create temp dir to sled db"); | ||
databend_common_meta_sled_store::init_temp_sled_db(t); | ||
|
||
let mut config = Config::new_testing(); | ||
config.file.prefix_filter = "".to_string(); | ||
|
||
let guards = init_logging("embedded_meta_unittests", &config, BTreeMap::new()); | ||
Box::leak(Box::new(guards)); | ||
}); | ||
} | ||
|
||
fn shutdown_test() { | ||
fastrace::flush(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters