-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integration test: Regression test for #1114
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
use scylla::batch::Batch; | ||
use scylla::batch::BatchType; | ||
use scylla::frame::frame_errors::BatchSerializationError; | ||
use scylla::frame::frame_errors::CqlRequestSerializationError; | ||
use scylla::query::Query; | ||
use scylla::transport::errors::QueryError; | ||
|
||
use crate::utils::create_new_session_builder; | ||
use crate::utils::setup_tracing; | ||
use crate::utils::unique_keyspace_name; | ||
use crate::utils::PerformDDL; | ||
|
||
use assert_matches::assert_matches; | ||
|
||
#[tokio::test] | ||
#[ntest::timeout(60000)] | ||
async fn batch_statements_and_values_mismatch_detected() { | ||
setup_tracing(); | ||
let session = create_new_session_builder().build().await.unwrap(); | ||
let ks = unique_keyspace_name(); | ||
session.ddl(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks)).await.unwrap(); | ||
session.use_keyspace(ks, false).await.unwrap(); | ||
session | ||
.ddl("CREATE TABLE IF NOT EXISTS batch_serialization_test (p int PRIMARY KEY, val int)") | ||
.await | ||
.unwrap(); | ||
|
||
let mut batch = Batch::new(BatchType::Logged); | ||
let stmt = session | ||
.prepare("INSERT INTO batch_serialization_test (p, val) VALUES (?, ?)") | ||
.await | ||
.unwrap(); | ||
batch.append_statement(stmt.clone()); | ||
batch.append_statement(Query::new( | ||
"INSERT INTO batch_serialization_test (p, val) VALUES (3, 4)", | ||
)); | ||
batch.append_statement(stmt); | ||
|
||
// Subtest 1: counts are correct | ||
{ | ||
session.batch(&batch, &((1, 2), (), (5, 6))).await.unwrap(); | ||
} | ||
|
||
// Subtest 2: not enough values | ||
{ | ||
let err = session.batch(&batch, &((1, 2), ())).await.unwrap_err(); | ||
assert_matches!( | ||
err, | ||
QueryError::CqlRequestSerialization(CqlRequestSerializationError::BatchSerialization( | ||
BatchSerializationError::ValuesAndStatementsLengthMismatch { | ||
n_value_lists: 2, | ||
n_statements: 3 | ||
} | ||
)) | ||
) | ||
} | ||
|
||
// Subtest 3: too many values | ||
{ | ||
let err = session | ||
.batch(&batch, &((1, 2), (), (5, 6), (7, 8))) | ||
.await | ||
.unwrap_err(); | ||
assert_matches!( | ||
err, | ||
QueryError::CqlRequestSerialization(CqlRequestSerializationError::BatchSerialization( | ||
BatchSerializationError::ValuesAndStatementsLengthMismatch { | ||
n_value_lists: 4, | ||
n_statements: 3 | ||
} | ||
)) | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod authenticate; | ||
mod batch; | ||
mod consistency; | ||
mod cql_collections; | ||
mod cql_types; | ||
|