Skip to content

Commit

Permalink
net: Add pipeline client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ohsayan committed Apr 5, 2024
1 parent 2dd6537 commit 337ea9e
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 14 deletions.
40 changes: 28 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ libc = "0.2.153"
# external deps
rand = "0.8.5"
tokio = { version = "1.37.0", features = ["test-util"] }
skytable = { git = "https://github.com/skytable/client-rust.git" }
skytable = { git = "https://github.com/skytable/client-rust.git", branch = "feature/pipeline-batch" }

[features]
nightly = []
Expand Down
4 changes: 3 additions & 1 deletion server/src/engine/net/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ async fn exec_simple<S: Socket>(
/*
pipeline
---
malformed packets
notes:
- executed without lookahead
- hence, malformed packets will need a special escape
*/

const ILLEGAL_PACKET_ESCAPE: u8 = 0xFF;
Expand Down
54 changes: 54 additions & 0 deletions server/src/engine/tests/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,57 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

use skytable::{
query,
query::Pipeline,
response::{Response, Value},
};

#[sky_macros::dbtest]
fn pipe() {
let mut db = db!();
let mut pipe = Pipeline::new();
for _ in 0..100 {
pipe.push(&query!("sysctl report status"));
}
assert_eq!(
db.execute_pipeline(&pipe).unwrap(),
vec![Response::Empty; 100]
);
}

#[sky_macros::dbtest]
fn pipe_params() {
let mut db = db!();
let pipe = Pipeline::new()
.add(&query!("create space pipe_params"))
.add(&query!(
"create model pipe_params.pipe_model(username: string, pipes_per_day: uint64)"
))
.add(&query!(
"insert into pipe_params.pipe_model(?,?)",
"sayan",
0u64
))
.add(&query!(
"select * from pipe_params.pipe_model where username = ?",
"sayan"
))
.add(&query!("drop space allow not empty pipe_params"));
let result = db.execute_pipeline(&pipe).unwrap();
assert_eq!(
&result[..3],
vec![Response::Empty, Response::Empty, Response::Empty]
);
match &result[3] {
Response::Row(r) => {
assert_eq!(
r.values(),
[Value::String("sayan".into()), Value::UInt64(0)]
)
}
unknown => panic!("expected row, got {unknown:?}"),
}
assert_eq!(result[4], Response::Empty);
}

0 comments on commit 337ea9e

Please sign in to comment.