pub const PROXY_URL_DEFAULT: &str = "http://127.0.0.1:8081";
pub const QDRANT_URL_DEFAULT: &str = "http://localhost:6333";
pub const ELASTIC_URL_DEFAULT: &str = "http://localhost:9200";
pub const OPENSEARCH_URL_DEFAULT: &str = "http://localhost:9201";
pub const MEILI1_URL_DEFAULT: &str = "http://localhost:7700";
pub const MEILI2_URL_DEFAULT: &str = "http://localhost:7701";
#[allow(dead_code)]
pub fn proxy_url() -> &'static str {
static OVERRIDE: std::sync::OnceLock<String> = std::sync::OnceLock::new();
OVERRIDE
.get_or_init(|| {
std::env::var("PROXY_URL").unwrap_or_else(|_| PROXY_URL_DEFAULT.to_string())
})
.as_str()
}
#[allow(dead_code)]
pub fn qdrant_url() -> &'static str {
static OVERRIDE: std::sync::OnceLock<String> = std::sync::OnceLock::new();
OVERRIDE
.get_or_init(|| {
std::env::var("QDRANT_URL").unwrap_or_else(|_| QDRANT_URL_DEFAULT.to_string())
})
.as_str()
}
#[allow(dead_code)]
pub fn elastic_url() -> &'static str {
static OVERRIDE: std::sync::OnceLock<String> = std::sync::OnceLock::new();
OVERRIDE
.get_or_init(|| {
std::env::var("ELASTIC_URL").unwrap_or_else(|_| ELASTIC_URL_DEFAULT.to_string())
})
.as_str()
}
#[allow(dead_code)]
pub fn opensearch_url() -> &'static str {
static OVERRIDE: std::sync::OnceLock<String> = std::sync::OnceLock::new();
OVERRIDE
.get_or_init(|| {
std::env::var("OPENSEARCH_URL").unwrap_or_else(|_| OPENSEARCH_URL_DEFAULT.to_string())
})
.as_str()
}
#[allow(dead_code)]
pub fn meili1_url() -> &'static str {
static OVERRIDE: std::sync::OnceLock<String> = std::sync::OnceLock::new();
OVERRIDE
.get_or_init(|| {
std::env::var("MEILI1_URL").unwrap_or_else(|_| MEILI1_URL_DEFAULT.to_string())
})
.as_str()
}
#[allow(dead_code)]
pub fn meili2_url() -> &'static str {
static OVERRIDE: std::sync::OnceLock<String> = std::sync::OnceLock::new();
OVERRIDE
.get_or_init(|| {
std::env::var("MEILI2_URL").unwrap_or_else(|_| MEILI2_URL_DEFAULT.to_string())
})
.as_str()
}
#[allow(dead_code)]
pub fn external_proxy() -> bool {
std::env::var("E2E_EXTERNAL_PROXY").ok().as_deref() == Some("1")
}
pub const SHARED_QUERIES: [&str; 10] = [
"rust programming language",
"elasticsearch full text search",
"vector databases similarity search",
"cache ttl lru eviction",
"circuit breaker pattern distributed systems",
"load balancing failover",
"axum web framework rust",
"BM25 scoring algorithm",
"database migrations versioning",
"error handling patterns",
];
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Suite {
Qdrant,
Elastic,
Mixed,
All,
}
impl Suite {
pub fn from_env() -> Self {
match std::env::var("E2E_SUITE").as_deref() {
Ok("qdrant") => Suite::Qdrant,
Ok("elastic") => Suite::Elastic,
Ok("mixed") => Suite::Mixed,
_ => Suite::All,
}
}
pub fn has_multiple_upstreams(self) -> bool {
matches!(self, Suite::Mixed | Suite::All)
}
pub fn is_all(self) -> bool {
self == Suite::All
}
pub fn has_text_upstreams(self) -> bool {
self != Suite::Qdrant
}
pub fn config_name(self) -> &'static str {
match self {
Suite::Qdrant => "single-qdrant.toml",
Suite::Elastic => "single-elasticsearch.toml",
Suite::Mixed => "cascade-mixed.toml",
Suite::All => "multi-elasticsearch.toml",
}
}
}
impl std::fmt::Display for Suite {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Suite::Qdrant => write!(f, "qdrant"),
Suite::Elastic => write!(f, "elastic"),
Suite::Mixed => write!(f, "mixed"),
Suite::All => write!(f, "all"),
}
}
}
pub fn category_enabled(name: &str) -> bool {
match std::env::var("E2E_FILTER") {
Ok(filter) if !filter.is_empty() => filter.split(',').any(|c| c.trim() == name),
_ => true,
}
}