mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-05 20:42:54 +00:00
Enable logs in unit tests
This commit is contained in:
committed by
Kirill Bulatov
parent
826e89b9ce
commit
90f66aa51b
@@ -8,6 +8,7 @@ use strum_macros::{EnumString, EnumVariantNames};
|
||||
pub enum LogFormat {
|
||||
Plain,
|
||||
Json,
|
||||
Test,
|
||||
}
|
||||
|
||||
impl LogFormat {
|
||||
@@ -39,6 +40,7 @@ pub fn init(log_format: LogFormat) -> anyhow::Result<()> {
|
||||
match log_format {
|
||||
LogFormat::Json => base_logger.json().init(),
|
||||
LogFormat::Plain => base_logger.init(),
|
||||
LogFormat::Test => base_logger.with_test_writer().init(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -2626,9 +2626,11 @@ where
|
||||
#[cfg(test)]
|
||||
pub mod harness {
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use once_cell::sync::OnceCell;
|
||||
use std::sync::Arc;
|
||||
use std::{fs, path::PathBuf};
|
||||
use tempfile::TempDir;
|
||||
use utils::logging;
|
||||
use utils::lsn::Lsn;
|
||||
|
||||
use crate::{
|
||||
@@ -2694,6 +2696,10 @@ pub mod harness {
|
||||
|
||||
impl TenantHarness {
|
||||
pub fn new() -> anyhow::Result<Self> {
|
||||
LOG_HANDLE.get_or_init(|| {
|
||||
logging::init(logging::LogFormat::Test).expect("Failed to init test logging")
|
||||
});
|
||||
|
||||
let temp_repo_dir = tempfile::tempdir()?;
|
||||
// `TempDir` uses a randomly generated subdirectory of a system tmp dir,
|
||||
// so far it's enough to take care of concurrently running tests.
|
||||
|
||||
Reference in New Issue
Block a user