Skip to content

Commit 360d6d9

Browse files
committed
Add HTTP integration tests
1 parent 42d15e0 commit 360d6d9

5 files changed

Lines changed: 421 additions & 28 deletions

File tree

Cargo.lock

Lines changed: 63 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

minikv/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ authors.workspace = true
1010
keywords.workspace = true
1111
categories.workspace = true
1212

13+
[lib]
14+
name = "minikv_server"
15+
path = "src/lib.rs"
16+
1317
[dependencies]
1418
minikv-core = { workspace = true }
1519
tracing = { workspace = true }
@@ -26,3 +30,8 @@ clap = { version = "4", features = ["derive", "env"] }
2630
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
2731
axum = { version = "0.7", features = [] }
2832
quick-xml = { version = "0.31", features = ["serialize"] }
33+
34+
[dev-dependencies]
35+
tower-util = { version = "0.3" }
36+
minikv-core = { workspace = true }
37+
wiremock = "0.6"

minikv/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pub mod cli;
2+
mod error;
3+
pub mod http;
4+
5+
pub use error::Error;

minikv/src/main.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
//! - `rebuild` → DB reconstruction from volume servers
77
//! - `rebalance` → key migration to ideal volumes
88
9-
mod cli;
10-
mod error;
11-
mod http;
12-
139
use minikv_core::storage;
1410

1511
use std::collections::HashMap;
@@ -21,12 +17,12 @@ use dashmap::DashMap;
2117
use tracing::{error, info};
2218
use tracing_subscriber::EnvFilter;
2319

24-
use cli::{Cli, Command};
2520
use minikv_core::locking::KeyLock;
2621
use minikv_core::rebalance::rebalance_all;
2722
use minikv_core::rebuild::rebuild_all;
2823
use minikv_core::replication::build_volume_client;
2924
use minikv_core::state::AppState;
25+
use minikv_server::cli::{Cli, Command, CommonArgs, validate_common};
3026
use storage::leveldb::LevelDbStore;
3127

3228
#[tokio::main]
@@ -39,7 +35,7 @@ async fn main() {
3935
}
4036
Command::Server(args) => {
4137
init_logging(args.verbose);
42-
cli::validate_common(&args.common);
38+
validate_common(&args.common);
4339

4440
info!(
4541
port = args.port,
@@ -78,7 +74,7 @@ async fn main() {
7874
http_client: build_volume_client(),
7975
});
8076

81-
let router = http::build_router(Arc::clone(&state));
77+
let router = minikv_server::http::build_router(Arc::clone(&state));
8278
let addr = SocketAddr::from(([0, 0, 0, 0], args.port));
8379
let listener = tokio::net::TcpListener::bind(addr)
8480
.await
@@ -96,7 +92,7 @@ async fn main() {
9692

9793
Command::Rebuild(args) => {
9894
init_logging(false);
99-
cli::validate_common(&args);
95+
validate_common(&args);
10096

10197
info!(volumes = ?args.volumes, "starting rebuild");
10298

@@ -122,7 +118,7 @@ async fn main() {
122118

123119
Command::Rebalance(args) => {
124120
init_logging(false);
125-
cli::validate_common(&args);
121+
validate_common(&args);
126122

127123
info!(volumes = ?args.volumes, "starting rebalance");
128124

@@ -149,7 +145,7 @@ async fn main() {
149145
}
150146

151147
/// Open LevelDB or exit with a clear error message.
152-
fn open_db(args: &cli::CommonArgs) -> LevelDbStore {
148+
fn open_db(args: &CommonArgs) -> LevelDbStore {
153149
LevelDbStore::open(&args.db).unwrap_or_else(|e| {
154150
eprintln!("error: failed to open LevelDB at {:?}: {e}", args.db);
155151
std::process::exit(1);

0 commit comments

Comments
 (0)