Skip to content

Commit

Permalink
test namespace creation on dirty instance
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma authored and ashleygwilliams committed Nov 17, 2023
1 parent 4aace20 commit dbffaed
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions libsql-server/tests/standalone/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Tests for standalone primary configuration
use crate::common::{net::SimServer, snapshot_metrics};
use crate::common::net::{SimServer, TurmoilAcceptor};
use crate::common::{http::Client, snapshot_metrics};

use super::common;

Expand All @@ -11,7 +12,7 @@ use libsql::{Database, Value};
use tempfile::tempdir;
use tokio::sync::Notify;

use libsql_server::config::UserApiConfig;
use libsql_server::config::{AdminApiConfig, UserApiConfig};

use common::net::{init_tracing, TestServer, TurmoilConnector};

Expand Down Expand Up @@ -260,3 +261,50 @@ fn random_rowid() {

sim.run().unwrap();
}

#[test]
fn dirty_startup_dont_prevent_namespace_creation() {
let mut sim = turmoil::Builder::new().build();

sim.host("primary", || async {
init_tracing();
let tmp = tempdir()?;
let server = TestServer {
path: tmp.path().to_owned().into(),
user_api_config: UserApiConfig {
hrana_ws_acceptor: None,
..Default::default()
},
admin_api_config: Some(AdminApiConfig {
acceptor: TurmoilAcceptor::bind(([0, 0, 0, 0], 9090)).await.unwrap(),
connector: TurmoilConnector,
disable_metrics: true,
}),
disable_default_namespace: true,
disable_namespaces: false,
..Default::default()
};

tokio::fs::File::create(tmp.path().join(".sentinel"))
.await
.unwrap();
server.start_sim(8080).await?;

Ok(())
});

sim.client("test", async {
let client = Client::new();
let resp = client
.post(
"http://primary:9090/v1/namespaces/test/create",
serde_json::json!({}),
)
.await
.unwrap();
assert!(resp.status().is_success());
Ok(())
});

sim.run().unwrap();
}

0 comments on commit dbffaed

Please sign in to comment.