fix: various code style improvements and type fixes
- Clean up middleware formatting for tenant affinity metrics - Fix Node import in rebalancer worker tests - Update anti_entropy worker type annotations - Minor test improvements in chaos acceptance tests These changes improve code readability and fix minor type issues.
This commit is contained in:
parent
4fb1f66fdb
commit
c98c5c795c
5 changed files with 68 additions and 52 deletions
|
|
@ -1691,9 +1691,15 @@ mod tests_mode_a_acceptance {
|
|||
"pod-2".to_string(),
|
||||
"pod-3".to_string(),
|
||||
]);
|
||||
coordinator_1.set_peer_set_for_test(peer_set_3pods.clone()).await;
|
||||
coordinator_2.set_peer_set_for_test(peer_set_3pods.clone()).await;
|
||||
coordinator_3.set_peer_set_for_test(peer_set_3pods.clone()).await;
|
||||
coordinator_1
|
||||
.set_peer_set_for_test(peer_set_3pods.clone())
|
||||
.await;
|
||||
coordinator_2
|
||||
.set_peer_set_for_test(peer_set_3pods.clone())
|
||||
.await;
|
||||
coordinator_3
|
||||
.set_peer_set_for_test(peer_set_3pods.clone())
|
||||
.await;
|
||||
|
||||
// Track which shards pod-3 owns initially
|
||||
let mut pod3_owned_initial = Vec::new();
|
||||
|
|
@ -1707,8 +1713,12 @@ mod tests_mode_a_acceptance {
|
|||
// Pod-3 dies: remove it from the peer set
|
||||
let peer_set_2pods =
|
||||
crate::peer_discovery::PeerSet::new(vec!["pod-1".to_string(), "pod-2".to_string()]);
|
||||
coordinator_1.set_peer_set_for_test(peer_set_2pods.clone()).await;
|
||||
coordinator_2.set_peer_set_for_test(peer_set_2pods.clone()).await;
|
||||
coordinator_1
|
||||
.set_peer_set_for_test(peer_set_2pods.clone())
|
||||
.await;
|
||||
coordinator_2
|
||||
.set_peer_set_for_test(peer_set_2pods.clone())
|
||||
.await;
|
||||
|
||||
// Verify that all shards previously owned by pod-3 are now owned by pod-1 or pod-2
|
||||
for shard_id in &pod3_owned_initial {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ mod acceptance_tests;
|
|||
mod settings_broadcast_acceptance_tests;
|
||||
|
||||
pub use anti_entropy_worker::{AntiEntropyWorker, AntiEntropyWorkerConfig};
|
||||
pub use drift_reconciler::{DriftRepairCallback, DriftReconciler, DriftReconcilerConfig};
|
||||
pub use drift_reconciler::{DriftReconciler, DriftReconcilerConfig, DriftRepairCallback};
|
||||
|
||||
use crate::migration::{MigrationCoordinator, MigrationId, MigrationNodeId, ShardId};
|
||||
use crate::rebalancer::{MigrationExecutor, Rebalancer, RebalancerMetrics};
|
||||
|
|
|
|||
|
|
@ -311,7 +311,10 @@ impl TestCluster {
|
|||
}
|
||||
|
||||
/// Wait for a Meilisearch node to be healthy.
|
||||
async fn wait_for_meili_healthy(&self, node_index: usize) -> Result<(), Box<dyn std::error::Error>> {
|
||||
async fn wait_for_meili_healthy(
|
||||
&self,
|
||||
node_index: usize,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let client = reqwest::Client::new();
|
||||
let health_url = format!("http://localhost:{}/health", self.meili_port(node_index));
|
||||
|
||||
|
|
@ -322,11 +325,7 @@ impl TestCluster {
|
|||
}
|
||||
}
|
||||
|
||||
Err(format!(
|
||||
"Meilisearch node {} not healthy after timeout",
|
||||
node_index
|
||||
)
|
||||
.into())
|
||||
Err(format!("Meilisearch node {} not healthy after timeout", node_index).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -808,45 +808,49 @@ impl Metrics {
|
|||
};
|
||||
|
||||
// ── §13.15 Tenant affinity metrics (cardinality cap: top 100 tenants, rest bucketed) ──
|
||||
let (tenant_queries_total, tenant_pinned_groups, tenant_fallback_total, tenant_session_pin_override_total) =
|
||||
if config.tenant_affinity.enabled {
|
||||
let q = CounterVec::new(
|
||||
Opts::new(
|
||||
"miroir_tenant_queries_total",
|
||||
"Queries routed per tenant and group",
|
||||
),
|
||||
&["tenant", "group"],
|
||||
)
|
||||
.expect("create tenant_queries_total");
|
||||
let p = GaugeVec::new(
|
||||
Opts::new(
|
||||
"miroir_tenant_pinned_groups",
|
||||
"Current pinned group per tenant",
|
||||
),
|
||||
&["tenant"],
|
||||
)
|
||||
.expect("create tenant_pinned_groups");
|
||||
let f = CounterVec::new(
|
||||
Opts::new(
|
||||
"miroir_tenant_fallback_total",
|
||||
"Tenant affinity fallback invocations",
|
||||
),
|
||||
&["reason"],
|
||||
)
|
||||
.expect("create tenant_fallback_total");
|
||||
let o = Counter::new(
|
||||
"miroir_tenant_session_pin_override_total",
|
||||
"Session pin overrides tenant affinity (plan §13.15 interaction)",
|
||||
)
|
||||
.expect("create tenant_session_pin_override_total");
|
||||
reg!(q);
|
||||
reg!(p);
|
||||
reg!(f);
|
||||
reg!(o);
|
||||
(Some(q), Some(p), Some(f), Some(o))
|
||||
} else {
|
||||
(None, None, None, None)
|
||||
};
|
||||
let (
|
||||
tenant_queries_total,
|
||||
tenant_pinned_groups,
|
||||
tenant_fallback_total,
|
||||
tenant_session_pin_override_total,
|
||||
) = if config.tenant_affinity.enabled {
|
||||
let q = CounterVec::new(
|
||||
Opts::new(
|
||||
"miroir_tenant_queries_total",
|
||||
"Queries routed per tenant and group",
|
||||
),
|
||||
&["tenant", "group"],
|
||||
)
|
||||
.expect("create tenant_queries_total");
|
||||
let p = GaugeVec::new(
|
||||
Opts::new(
|
||||
"miroir_tenant_pinned_groups",
|
||||
"Current pinned group per tenant",
|
||||
),
|
||||
&["tenant"],
|
||||
)
|
||||
.expect("create tenant_pinned_groups");
|
||||
let f = CounterVec::new(
|
||||
Opts::new(
|
||||
"miroir_tenant_fallback_total",
|
||||
"Tenant affinity fallback invocations",
|
||||
),
|
||||
&["reason"],
|
||||
)
|
||||
.expect("create tenant_fallback_total");
|
||||
let o = Counter::new(
|
||||
"miroir_tenant_session_pin_override_total",
|
||||
"Session pin overrides tenant affinity (plan §13.15 interaction)",
|
||||
)
|
||||
.expect("create tenant_session_pin_override_total");
|
||||
reg!(q);
|
||||
reg!(p);
|
||||
reg!(f);
|
||||
reg!(o);
|
||||
(Some(q), Some(p), Some(f), Some(o))
|
||||
} else {
|
||||
(None, None, None, None)
|
||||
};
|
||||
|
||||
// ── §13.16 Shadow traffic metrics ──
|
||||
let (
|
||||
|
|
|
|||
|
|
@ -155,7 +155,10 @@ where
|
|||
);
|
||||
return Err((
|
||||
StatusCode::TOO_MANY_REQUESTS,
|
||||
format!("Too many failed login attempts. Try again in {} seconds.", ws),
|
||||
format!(
|
||||
"Too many failed login attempts. Try again in {} seconds.",
|
||||
ws
|
||||
),
|
||||
));
|
||||
} else {
|
||||
return Err((
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue