style: code formatting cleanup
- Remove trailing blank lines in lib.rs - Improve line breaking in documents.rs test - Other minor formatting consistency fixes Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
4777bb6834
commit
60a59e34e9
15 changed files with 46 additions and 80 deletions
File diff suppressed because one or more lines are too long
|
|
@ -13,8 +13,8 @@ use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criteri
|
|||
use miroir_core::merger::ScoreMergeStrategy;
|
||||
use miroir_core::replica_selection::ReplicaSelector;
|
||||
use miroir_core::scatter::{
|
||||
plan_search_scatter, GlobalIdf, MockNodeClient,
|
||||
PreflightRequest, PreflightResponse, SearchRequest, TermStats,
|
||||
plan_search_scatter, GlobalIdf, MockNodeClient, PreflightRequest, PreflightResponse,
|
||||
SearchRequest, TermStats,
|
||||
};
|
||||
use miroir_core::topology::{Node, NodeId, Topology};
|
||||
use serde_json::json;
|
||||
|
|
|
|||
|
|
@ -5,14 +5,11 @@
|
|||
// Allow functions with many parameters - refactoring to use parameter structs
|
||||
// would be a significant API change. These functions are well-documented.
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
// Some unused variables are intentional (e.g., for future use or debug-only),
|
||||
// or are part of complex async patterns where suppressing is cleaner than
|
||||
// adding conditional compilation attributes throughout.
|
||||
#![allow(unused_variables)]
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
// Additional test-specific allowances
|
||||
#![cfg_attr(test, allow(clippy::useless_vec))]
|
||||
#![cfg_attr(test, allow(non_snake_case))]
|
||||
|
|
|
|||
|
|
@ -591,7 +591,10 @@ mod tests {
|
|||
JobState::parse_state("in_progress"),
|
||||
Some(JobState::InProgress)
|
||||
);
|
||||
assert_eq!(JobState::parse_state("completed"), Some(JobState::Completed));
|
||||
assert_eq!(
|
||||
JobState::parse_state("completed"),
|
||||
Some(JobState::Completed)
|
||||
);
|
||||
assert_eq!(JobState::parse_state("failed"), Some(JobState::Failed));
|
||||
assert_eq!(JobState::parse_state("unknown"), None);
|
||||
|
||||
|
|
@ -603,7 +606,10 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_job_type_roundtrip() {
|
||||
assert_eq!(JobType::parse_type("dump_import"), Some(JobType::DumpImport));
|
||||
assert_eq!(
|
||||
JobType::parse_type("dump_import"),
|
||||
Some(JobType::DumpImport)
|
||||
);
|
||||
assert_eq!(
|
||||
JobType::parse_type("reshard_backfill"),
|
||||
Some(JobType::ReshardBackfill)
|
||||
|
|
|
|||
|
|
@ -116,9 +116,7 @@ impl TaskStore for MockTaskStore {
|
|||
Ok(jobs
|
||||
.iter()
|
||||
.filter(|j| {
|
||||
j.state == "in_progress"
|
||||
&& j.claim_expires_at
|
||||
.is_some_and(|exp| exp < now_ms)
|
||||
j.state == "in_progress" && j.claim_expires_at.is_some_and(|exp| exp < now_ms)
|
||||
})
|
||||
.cloned()
|
||||
.collect())
|
||||
|
|
|
|||
|
|
@ -280,7 +280,10 @@ mod tests {
|
|||
MergeStrategy::parse_strategy("convex"),
|
||||
Some(MergeStrategy::Convex)
|
||||
);
|
||||
assert_eq!(MergeStrategy::parse_strategy("rrf"), Some(MergeStrategy::Rrf));
|
||||
assert_eq!(
|
||||
MergeStrategy::parse_strategy("rrf"),
|
||||
Some(MergeStrategy::Rrf)
|
||||
);
|
||||
assert_eq!(MergeStrategy::parse_strategy("unknown"), None);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -177,9 +177,7 @@ impl TestCluster {
|
|||
delay_ms: u32,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let container_name = format!("{}_meili-{}_1", self.project_name, node_index);
|
||||
println!(
|
||||
"Applying {delay_ms}ms delay to container {container_name}..."
|
||||
);
|
||||
println!("Applying {delay_ms}ms delay to container {container_name}...");
|
||||
|
||||
// Try to remove existing qdisc first, then add new one
|
||||
let _ = std::process::Command::new("docker")
|
||||
|
|
@ -366,9 +364,7 @@ async fn wait_for_task(
|
|||
// Check if task is finished (Succeeded or Failed)
|
||||
match task {
|
||||
Task::Succeeded { .. } => return Ok(task),
|
||||
Task::Failed { .. } => {
|
||||
return Err(format!("Task {task_uid} failed: {task:?}").into())
|
||||
}
|
||||
Task::Failed { .. } => return Err(format!("Task {task_uid} failed: {task:?}").into()),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,9 +63,7 @@ async fn wait_for_task(
|
|||
// Check if task is finished (Succeeded or Failed)
|
||||
match task {
|
||||
Task::Succeeded { .. } => return Ok(task),
|
||||
Task::Failed { .. } => {
|
||||
return Err(format!("Task {task_uid} failed: {task:?}").into())
|
||||
}
|
||||
Task::Failed { .. } => return Err(format!("Task {task_uid} failed: {task:?}").into()),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
@ -168,10 +166,7 @@ async fn document_round_trip() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
// Total across nodes equals 1000
|
||||
let total: usize = node_doc_counts.values().sum();
|
||||
assert_eq!(
|
||||
total, 1000,
|
||||
"Total documents mismatch: {node_doc_counts:?}"
|
||||
);
|
||||
assert_eq!(total, 1000, "Total documents mismatch: {node_doc_counts:?}");
|
||||
|
||||
// Clean up
|
||||
delete_index(&client, index_name).await?;
|
||||
|
|
|
|||
|
|
@ -745,9 +745,7 @@ async fn p42_log_inspection_old_node_not_queried_after_migration() {
|
|||
let fetch_calls = executor.fetch_calls.lock().unwrap();
|
||||
println!("Total fetch calls: {}", fetch_calls.len());
|
||||
for ((node, shard, offset), count) in fetch_calls.iter() {
|
||||
println!(
|
||||
" {node} shard {shard} offset {offset}: {count} calls"
|
||||
);
|
||||
println!(" {node} shard {shard} offset {offset}: {count} calls");
|
||||
}
|
||||
|
||||
// Verify the new node HAS documents for migrated shards
|
||||
|
|
@ -807,12 +805,7 @@ async fn p42_verify_dual_write_during_migration() {
|
|||
for shard_id in 0..shards {
|
||||
let assigned = assign_shard_in_group(shard_id, &node_ids, 2);
|
||||
for node_id in &assigned {
|
||||
populate_node(
|
||||
&executor,
|
||||
node_id.as_str(),
|
||||
&[shard_id],
|
||||
docs_per_shard,
|
||||
);
|
||||
populate_node(&executor, node_id.as_str(), &[shard_id], docs_per_shard);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -939,12 +932,7 @@ async fn p42_pagination_limit_offset() {
|
|||
for shard_id in 0..shards {
|
||||
let assigned = assign_shard_in_group(shard_id, &node_ids, 2);
|
||||
for node_id in &assigned {
|
||||
populate_node(
|
||||
&executor,
|
||||
node_id.as_str(),
|
||||
&[shard_id],
|
||||
docs_per_shard,
|
||||
);
|
||||
populate_node(&executor, node_id.as_str(), &[shard_id], docs_per_shard);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1033,9 +1021,7 @@ async fn p42_pagination_limit_offset() {
|
|||
);
|
||||
|
||||
let (shard_id, offsets) = found_paginated_shard.unwrap();
|
||||
println!(
|
||||
"Shard {shard_id} has paginated fetches with offsets: {offsets:?}"
|
||||
);
|
||||
println!("Shard {shard_id} has paginated fetches with offsets: {offsets:?}");
|
||||
|
||||
// Verify offsets are multiples of batch size
|
||||
for offset in &offsets {
|
||||
|
|
|
|||
|
|
@ -344,19 +344,11 @@ async fn acceptance_3_mid_sync_writes_present_on_both_groups_after_sync() {
|
|||
let node_map = t.node_map();
|
||||
let group_0_count = targets
|
||||
.iter()
|
||||
.filter(|n| {
|
||||
node_map
|
||||
.get(n)
|
||||
.is_some_and(|node| node.replica_group == 0)
|
||||
})
|
||||
.filter(|n| node_map.get(n).is_some_and(|node| node.replica_group == 0))
|
||||
.count();
|
||||
let group_1_count = targets
|
||||
.iter()
|
||||
.filter(|n| {
|
||||
node_map
|
||||
.get(n)
|
||||
.is_some_and(|node| node.replica_group == 1)
|
||||
})
|
||||
.filter(|n| node_map.get(n).is_some_and(|node| node.replica_group == 1))
|
||||
.count();
|
||||
|
||||
assert_eq!(group_0_count, 2, "Should have 2 nodes from group 0");
|
||||
|
|
|
|||
|
|
@ -191,10 +191,7 @@ async fn rotate_node_master(
|
|||
if !status.is_success() {
|
||||
let text = resp.text().await.unwrap_or_default();
|
||||
rollback_create(&client, &created_on, &new_key_uid, ¤t_key).await;
|
||||
return Err(format!(
|
||||
"Key creation failed on {addr}: HTTP {status} — {text}"
|
||||
)
|
||||
.into());
|
||||
return Err(format!("Key creation failed on {addr}: HTTP {status} — {text}").into());
|
||||
}
|
||||
|
||||
let body: MeiliKeyCreated = resp
|
||||
|
|
@ -226,9 +223,7 @@ async fn rotate_node_master(
|
|||
" kubectl -n {} patch secret {} \\",
|
||||
args.namespace, args.secret_name
|
||||
);
|
||||
println!(
|
||||
" -p '{{\"stringData\":{{\"nodeMasterKey\":\"{new_key}\"}}}}'"
|
||||
);
|
||||
println!(" -p '{{\"stringData\":{{\"nodeMasterKey\":\"{new_key}\"}}}}'");
|
||||
println!("\nOr update your ExternalSecret / OpenBao source.\n");
|
||||
|
||||
// ── Step 3: Rolling restart instructions ─────────────────────────
|
||||
|
|
@ -291,9 +286,7 @@ async fn rotate_node_master(
|
|||
} else {
|
||||
let status = resp.status();
|
||||
let text = resp.text().await.unwrap_or_default();
|
||||
eprintln!(
|
||||
" Warning: delete on {addr} returned HTTP {status} — {text}"
|
||||
);
|
||||
eprintln!(" Warning: delete on {addr} returned HTTP {status} — {text}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -433,9 +426,7 @@ async fn find_old_key_uid(
|
|||
if !resp.status().is_success() {
|
||||
let status = resp.status();
|
||||
let text = resp.text().await.unwrap_or_default();
|
||||
eprintln!(
|
||||
" Warning: could not list keys on {node_addr} (HTTP {status} — {text})"
|
||||
);
|
||||
eprintln!(" Warning: could not list keys on {node_addr} (HTTP {status} — {text})");
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,10 +71,7 @@ where
|
|||
post(canary::create_from_capture::<S>),
|
||||
)
|
||||
// Explain endpoint (plan §13.20)
|
||||
.route(
|
||||
"/indexes/{index}/explain",
|
||||
post(explain::explain_search),
|
||||
)
|
||||
.route("/indexes/{index}/explain", post(explain::explain_search))
|
||||
// Node management (plan §2 node addition flow)
|
||||
.route("/nodes", post(admin_endpoints::add_node::<S>))
|
||||
.route("/nodes/{id}", delete(admin_endpoints::remove_node::<S>))
|
||||
|
|
|
|||
|
|
@ -716,8 +716,8 @@ impl AppState {
|
|||
// This must be created before drift_reconciler and anti_entropy_worker so they can be wired up
|
||||
let pod_name = std::env::var("POD_NAME").unwrap_or_else(|_| "unknown".to_string());
|
||||
let namespace = std::env::var("POD_NAMESPACE").unwrap_or_else(|_| "default".to_string());
|
||||
let service_name = std::env::var("MIROR_SERVICE_NAME")
|
||||
.unwrap_or_else(|_| "miroir-headless".to_string());
|
||||
let service_name =
|
||||
std::env::var("MIROR_SERVICE_NAME").unwrap_or_else(|_| "miroir-headless".to_string());
|
||||
let peer_discovery = Arc::new(PeerDiscovery::new(
|
||||
pod_name.clone(),
|
||||
namespace,
|
||||
|
|
|
|||
|
|
@ -1254,7 +1254,10 @@ mod tests {
|
|||
assert_eq!(extract_primary_key(&doc_with_key), Some("key".to_string()));
|
||||
|
||||
let doc_with_id_field = serde_json::json!({"_id": "test000", "name": "Test"});
|
||||
assert_eq!(extract_primary_key(&doc_with_id_field), Some("_id".to_string()));
|
||||
assert_eq!(
|
||||
extract_primary_key(&doc_with_id_field),
|
||||
Some("_id".to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ pub async fn explain_search(
|
|||
Extension(state): Extension<Arc<AppState>>,
|
||||
headers: HeaderMap,
|
||||
Json(query): Json<SearchQuery>,
|
||||
) -> Result<Json<serde_json::Value>, StatusCode>
|
||||
{
|
||||
) -> Result<Json<serde_json::Value>, StatusCode> {
|
||||
if !state.config.explain.enabled {
|
||||
return Err(StatusCode::NOT_FOUND);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue