nightlight: trim test-only helpers
This commit is contained in:
parent
bd09761def
commit
ec55fdea05
4 changed files with 13 additions and 2 deletions
|
|
@ -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)?;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<Self> {
|
||||
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<String> {
|
||||
let mut values: Vec<String> = self
|
||||
.label_index
|
||||
|
|
|
|||
|
|
@ -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<String>) -> Result<Vec<SeriesId>> {
|
||||
let parsed: Vec<(String, String)> = matchers
|
||||
.iter()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue