diff --git a/nightlight/crates/nightlight-server/src/config.rs b/nightlight/crates/nightlight-server/src/config.rs index dd2300b..6c996e7 100644 --- a/nightlight/crates/nightlight-server/src/config.rs +++ b/nightlight/crates/nightlight-server/src/config.rs @@ -130,6 +130,7 @@ impl Config { } /// Save configuration to a YAML file + #[cfg(test)] pub fn save(&self, path: &str) -> Result<()> { let content = serde_yaml::to_string(self)?; fs::write(path, content)?; diff --git a/nightlight/crates/nightlight-server/src/ingestion.rs b/nightlight/crates/nightlight-server/src/ingestion.rs index 93cc8f7..bf9f428 100644 --- a/nightlight/crates/nightlight-server/src/ingestion.rs +++ b/nightlight/crates/nightlight-server/src/ingestion.rs @@ -138,6 +138,7 @@ impl IngestionService { } /// Get current storage statistics + #[cfg(test)] pub async fn storage_stats(&self) -> Result<(usize, usize), Error> { let stats = self .storage diff --git a/nightlight/crates/nightlight-server/src/query.rs b/nightlight/crates/nightlight-server/src/query.rs index 99c064b..2d7a353 100644 --- a/nightlight/crates/nightlight-server/src/query.rs +++ b/nightlight/crates/nightlight-server/src/query.rs @@ -24,7 +24,9 @@ use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::Arc; use std::time::Instant; use tokio::sync::RwLock; -use tracing::{debug, error, info}; +use tracing::{debug, error}; +#[cfg(test)] +use tracing::info; const QUERY_DURATION_HISTORY_LIMIT: usize = 512; @@ -83,6 +85,7 @@ impl QueryService { } /// Create QueryService and load persistent state from disk if it exists + #[cfg(test)] pub fn new_with_persistence(data_path: &std::path::Path) -> Result { let storage = QueryableStorage::load_from_file(data_path)?; info!("Loaded {} series from persistent storage", storage.series.len()); @@ -94,6 +97,7 @@ impl QueryService { } /// Save current storage state to disk + #[cfg(test)] pub async fn save_to_disk(&self, data_path: &std::path::Path) -> Result<()> { let storage = self.storage.read().await; storage.save_to_file(data_path)?; @@ -799,6 +803,7 @@ impl QueryableStorage { } /// Get label values for a specific label name + #[cfg(test)] pub fn label_values(&self, label_name: &str) -> Vec { let mut values: Vec = self .label_index diff --git a/nightlight/crates/nightlight-server/src/storage.rs b/nightlight/crates/nightlight-server/src/storage.rs index 620a315..9537a3e 100644 --- a/nightlight/crates/nightlight-server/src/storage.rs +++ b/nightlight/crates/nightlight-server/src/storage.rs @@ -3,7 +3,9 @@ use anyhow::Result; use chrono::Utc; -use nightlight_types::{SeriesId, TimeSeries}; +#[cfg(test)] +use nightlight_types::SeriesId; +use nightlight_types::TimeSeries; use std::{ fs::{File, OpenOptions}, io::{Read, Write}, @@ -79,6 +81,7 @@ impl Storage { Ok(()) } + #[cfg(test)] pub async fn query_series( &self, series_id: SeriesId, @@ -92,6 +95,7 @@ impl Storage { .map(|series| series.filter_by_time(start, end))) } + #[cfg(test)] pub async fn find_series(&self, matchers: Vec) -> Result> { let parsed: Vec<(String, String)> = matchers .iter()