Skip to content

Commit

Permalink
review feedback: add request timeout to execution profile to enable t…
Browse files Browse the repository at this point in the history
…hat writes complete during cassandra tests
  • Loading branch information
samuelorji committed Oct 10, 2023
1 parent efb96fc commit 5ce661c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions scylla/src/transport/large_batch_statements_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,34 @@ use crate::query::Query;
use crate::{
batch::Batch,
test_utils::{create_new_session_builder, unique_keyspace_name},
QueryResult, Session,
ExecutionProfile, QueryResult, Session,
};
use assert_matches::assert_matches;
use scylla_cql::errors::{BadQuery, DbError, QueryError};
use scylla_cql::errors::{BadQuery, QueryError};
use std::time::Duration;

#[tokio::test]
async fn test_large_batch_statements() {
let mut session = create_new_session_builder().build().await.unwrap();
let profile = ExecutionProfile::builder()
// set a 1 minute request timeout which should be enough to write this batch statement
.request_timeout(Some(Duration::from_secs(60)))
.build();

let handle = profile.into_handle();
let mut session = create_new_session_builder()
.default_execution_profile_handle(handle)
.build()
.await
.unwrap();

let ks = unique_keyspace_name();
session = create_test_session(session, &ks).await;

// Add batch
let max_number_of_queries = u16::MAX as usize;
let batch_result = write_batch(&session, max_number_of_queries, &ks).await;

if batch_result.is_err() {
assert_matches!(
batch_result.unwrap_err(),
QueryError::DbError(DbError::WriteTimeout { .. }, _)
)
}
assert!(batch_result.is_ok());

// Now try with too many queries
let too_many_queries = u16::MAX as usize + 1;
Expand Down

0 comments on commit 5ce661c

Please sign in to comment.