- netboot-base.nix with SSH key auth - Launch scripts for node01/02/03 - Node configuration.nix and disko.nix - Nix modules for first-boot automation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
53 lines
1.7 KiB
Rust
53 lines
1.7 KiB
Rust
use flaredb_server::config::{encode_namespaced_key, Config, NamespaceManager};
|
|
use flaredb_server::store::Store;
|
|
use flaredb_storage::rocks_engine::RocksEngine;
|
|
use flaredb_types::RegionMeta;
|
|
use std::collections::HashMap;
|
|
use std::sync::Arc;
|
|
|
|
fn test_peer_addrs() -> Arc<HashMap<u64, String>> {
|
|
let mut addrs = HashMap::new();
|
|
addrs.insert(1, "127.0.0.1:50051".to_string());
|
|
Arc::new(addrs)
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn split_via_store_api_routes_keys_correctly() {
|
|
let dir = tempfile::TempDir::new().unwrap();
|
|
let engine = Arc::new(RocksEngine::new(dir.path().to_str().unwrap()).unwrap());
|
|
let config = Config::default();
|
|
let namespace_manager = Arc::new(NamespaceManager::from_config(&config));
|
|
let ns = namespace_manager.get_namespace("default");
|
|
let store = Arc::new(Store::new(
|
|
1,
|
|
engine.clone(),
|
|
Arc::new(config),
|
|
namespace_manager.clone(),
|
|
test_peer_addrs(),
|
|
));
|
|
store
|
|
.bootstrap_regions(vec![(
|
|
RegionMeta {
|
|
id: 1,
|
|
start_key: encode_namespaced_key(ns.id, b""),
|
|
end_key: Vec::new(),
|
|
},
|
|
vec![1],
|
|
)])
|
|
.await
|
|
.unwrap();
|
|
|
|
// Manual split at key "m"
|
|
let new_region_id = store.allocate_region_id().await;
|
|
store
|
|
.split_region(1, encode_namespaced_key(ns.id, b"m"), new_region_id, vec![1])
|
|
.await
|
|
.unwrap();
|
|
|
|
// after split, routing should differentiate
|
|
let k_low = encode_namespaced_key(ns.id, b"a");
|
|
let k_high = encode_namespaced_key(ns.id, b"z");
|
|
let r1 = store.route_key(&k_low).await;
|
|
let r2 = store.route_key(&k_high).await;
|
|
assert_ne!(r1, r2, "split must route keys differently");
|
|
}
|