-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #579 from tursodatabase/fix-batch-replication-index
fix batch replication index
- Loading branch information
Showing
7 changed files
with
95 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use insta::assert_json_snapshot; | ||
use sqld::hrana_proto::{Batch, BatchStep, Stmt}; | ||
|
||
use crate::common::http::Client; | ||
|
||
#[test] | ||
fn sample_request() { | ||
let mut sim = turmoil::Builder::new().build(); | ||
sim.host("primary", super::make_standalone_server); | ||
sim.client("client", async { | ||
let batch = Batch { | ||
steps: vec![BatchStep { | ||
condition: None, | ||
stmt: Stmt { | ||
sql: Some("create table test (x)".to_string()), | ||
..Default::default() | ||
}, | ||
}], | ||
replication_index: None, | ||
}; | ||
let client = Client::new(); | ||
|
||
let resp = client | ||
.post( | ||
"http://primary:8080/v1/batch", | ||
serde_json::json!({ "batch": batch }), | ||
) | ||
.await | ||
.unwrap(); | ||
assert_json_snapshot!(resp.json_value().await.unwrap()); | ||
|
||
Ok(()) | ||
}); | ||
|
||
sim.run().unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//! Test hrana related functionalities | ||
|
||
use sqld::config::UserApiConfig; | ||
use tempfile::tempdir; | ||
|
||
use crate::common::net::{init_tracing, SimServer, TestServer}; | ||
mod batch; | ||
|
||
async fn make_standalone_server() -> Result<(), Box<dyn std::error::Error>> { | ||
init_tracing(); | ||
let tmp = tempdir()?; | ||
let server = TestServer { | ||
path: tmp.path().to_owned().into(), | ||
user_api_config: UserApiConfig { | ||
hrana_ws_acceptor: None, | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}; | ||
|
||
server.start_sim(8080).await?; | ||
|
||
Ok(()) | ||
} |
20 changes: 20 additions & 0 deletions
20
libsql-server/tests/hrana/snapshots/tests__hrana__batch__sample_request.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
source: libsql-server/tests/hrana/batch.rs | ||
expression: resp.json_value().await.unwrap() | ||
--- | ||
{ | ||
"result": { | ||
"step_results": [ | ||
{ | ||
"cols": [], | ||
"rows": [], | ||
"affected_row_count": 0, | ||
"last_insert_rowid": null | ||
} | ||
], | ||
"step_errors": [ | ||
null | ||
], | ||
"replication_index": 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,6 @@ mod common; | |
|
||
mod cluster; | ||
mod embedded_replica; | ||
mod hrana; | ||
mod namespaces; | ||
mod standalone; |