diff --git a/scylla/src/history.rs b/scylla/src/history.rs index 06334886d7..9ff22a6df2 100644 --- a/scylla/src/history.rs +++ b/scylla/src/history.rs @@ -467,7 +467,6 @@ mod tests { use crate::test_utils::create_new_session_builder; use assert_matches::assert_matches; use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc}; - use futures::StreamExt; use scylla_cql::{ errors::{DbError, QueryError}, Consistency, @@ -918,7 +917,7 @@ mod tests { #[tokio::test] async fn successful_query_history() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let mut query = Query::new("SELECT * FROM system.local"); let history_collector = Arc::new(HistoryCollector::new()); @@ -985,7 +984,7 @@ mod tests { #[tokio::test] async fn failed_query_history() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let mut query = Query::new("This isnt even CQL"); let history_collector = Arc::new(HistoryCollector::new()); @@ -1022,7 +1021,7 @@ mod tests { #[tokio::test] async fn iterator_query_history() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session .query_unpaged(format!("CREATE KEYSPACE {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]) diff --git a/scylla/src/transport/authenticate_test.rs b/scylla/src/transport/authenticate_test.rs index 75d628ce43..78e72dea40 100644 --- a/scylla/src/transport/authenticate_test.rs +++ b/scylla/src/transport/authenticate_test.rs @@ -16,7 +16,7 @@ async fn authenticate_superuser() { let session = crate::SessionBuilder::new() .known_node(uri) .user("cassandra", "cassandra") - .build_legacy() + .build() .await .unwrap(); let ks = unique_keyspace_name(); @@ -75,7 +75,7 @@ async fn custom_authentication() { let session = crate::SessionBuilder::new() .known_node(uri) .authenticator_provider(Arc::new(CustomAuthenticatorProvider)) - .build_legacy() + .build() .await .unwrap(); let ks = unique_keyspace_name(); diff --git a/scylla/src/transport/caching_session.rs b/scylla/src/transport/caching_session.rs index 83e543ab6b..3b7a422937 100644 --- a/scylla/src/transport/caching_session.rs +++ b/scylla/src/transport/caching_session.rs @@ -448,7 +448,12 @@ mod tests { .unwrap() .into_stream(); - let rows = iter.try_collect::>().await.unwrap().len(); + let rows = iter + .into_stream() + .try_collect::>() + .await + .unwrap() + .len(); assert_eq!(1, rows); assert_eq!(1, session.cache.len()); diff --git a/scylla/src/transport/connection.rs b/scylla/src/transport/connection.rs index 44f71dabf9..81795ce312 100644 --- a/scylla/src/transport/connection.rs +++ b/scylla/src/transport/connection.rs @@ -2258,7 +2258,7 @@ mod tests { // Preparation phase let session = SessionBuilder::new() .known_node_addr(addr) - .build_legacy() + .build() .await .unwrap(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks.clone()), &[]).await.unwrap(); @@ -2361,7 +2361,7 @@ mod tests { // Preparation phase let session = SessionBuilder::new() .known_node_addr(addr) - .build_legacy() + .build() .await .unwrap(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks.clone()), &[]).await.unwrap(); @@ -2438,9 +2438,7 @@ mod tests { .query_unpaged("SELECT p, v FROM t") .await .unwrap() - .into_legacy_result() - .unwrap() - .rows_typed::<(i32, Vec)>() + .rows::<(i32, Vec)>() .unwrap() .collect::, _>>() .unwrap(); diff --git a/scylla/src/transport/cql_collections_test.rs b/scylla/src/transport/cql_collections_test.rs index 6322e6e92c..23ac1d396d 100644 --- a/scylla/src/transport/cql_collections_test.rs +++ b/scylla/src/transport/cql_collections_test.rs @@ -1,12 +1,14 @@ -use crate::cql_to_rust::FromCqlVal; +use crate::transport::session::Session; +use scylla_cql::types::deserialize::value::DeserializeValue; + +use crate::frame::response::result::CqlValue; use crate::test_utils::{create_new_session_builder, setup_tracing}; use crate::utils::test_utils::unique_keyspace_name; -use crate::{frame::response::result::CqlValue, LegacySession}; use scylla_cql::types::serialize::value::SerializeValue; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; -async fn connect() -> LegacySession { - let session = create_new_session_builder().build_legacy().await.unwrap(); +async fn connect() -> Session { + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); session.use_keyspace(ks, false).await.unwrap(); @@ -14,7 +16,7 @@ async fn connect() -> LegacySession { session } -async fn create_table(session: &LegacySession, table_name: &str, value_type: &str) { +async fn create_table(session: &Session, table_name: &str, value_type: &str) { session .query_unpaged( format!( @@ -28,13 +30,13 @@ async fn create_table(session: &LegacySession, table_name: &str, value_type: &st } async fn insert_and_select( - session: &LegacySession, + session: &Session, table_name: &str, to_insert: &InsertT, expected: &SelectT, ) where InsertT: SerializeValue, - SelectT: FromCqlVal> + PartialEq + std::fmt::Debug, + SelectT: for<'r> DeserializeValue<'r> + PartialEq + std::fmt::Debug, { session .query_unpaged( @@ -48,7 +50,7 @@ async fn insert_and_select( .query_unpaged(format!("SELECT val FROM {} WHERE p = 0", table_name), ()) .await .unwrap() - .single_row_typed::<(SelectT,)>() + .single_row::<(SelectT,)>() .unwrap() .0; @@ -58,7 +60,7 @@ async fn insert_and_select( #[tokio::test] async fn test_cql_list() { setup_tracing(); - let session: LegacySession = connect().await; + let session: Session = connect().await; let table_name: &str = "test_cql_list_tab"; create_table(&session, table_name, "list").await; @@ -91,7 +93,7 @@ async fn test_cql_list() { #[tokio::test] async fn test_cql_set() { setup_tracing(); - let session: LegacySession = connect().await; + let session: Session = connect().await; let table_name: &str = "test_cql_set_tab"; create_table(&session, table_name, "set").await; @@ -155,7 +157,7 @@ async fn test_cql_set() { #[tokio::test] async fn test_cql_map() { setup_tracing(); - let session: LegacySession = connect().await; + let session: Session = connect().await; let table_name: &str = "test_cql_map_tab"; create_table(&session, table_name, "map").await; @@ -206,7 +208,7 @@ async fn test_cql_map() { #[tokio::test] async fn test_cql_tuple() { setup_tracing(); - let session: LegacySession = connect().await; + let session: Session = connect().await; let table_name: &str = "test_cql_tuple_tab"; create_table(&session, table_name, "tuple").await; diff --git a/scylla/src/transport/cql_types_test.rs b/scylla/src/transport/cql_types_test.rs index 4be1244eb1..6a7fdf40fc 100644 --- a/scylla/src/transport/cql_types_test.rs +++ b/scylla/src/transport/cql_types_test.rs @@ -1,17 +1,14 @@ use crate as scylla; -use crate::cql_to_rust::FromCqlVal; use crate::frame::response::result::CqlValue; use crate::frame::value::{Counter, CqlDate, CqlTime, CqlTimestamp}; -use crate::macros::FromUserType; -use crate::test_utils::{ - create_new_session_builder, scylla_supports_tablets_legacy, setup_tracing, -}; -use crate::transport::session::LegacySession; +use crate::test_utils::{create_new_session_builder, scylla_supports_tablets, setup_tracing}; +use crate::transport::session::Session; use crate::utils::test_utils::unique_keyspace_name; use itertools::Itertools; use scylla_cql::frame::value::{CqlTimeuuid, CqlVarint}; +use scylla_cql::types::deserialize::value::DeserializeValue; use scylla_cql::types::serialize::value::SerializeValue; -use scylla_macros::SerializeValue; +use scylla_macros::{DeserializeValue, SerializeValue}; use std::cmp::PartialEq; use std::fmt::Debug; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; @@ -24,8 +21,8 @@ async fn init_test_maybe_without_tablets( table_name: &str, type_name: &str, supports_tablets: bool, -) -> LegacySession { - let session: LegacySession = create_new_session_builder().build_legacy().await.unwrap(); +) -> Session { + let session: Session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); let mut create_ks = format!( @@ -34,7 +31,7 @@ async fn init_test_maybe_without_tablets( ks ); - if !supports_tablets && scylla_supports_tablets_legacy(&session).await { + if !supports_tablets && scylla_supports_tablets(&session).await { create_ks += " AND TABLETS = {'enabled': false}" } @@ -63,7 +60,7 @@ async fn init_test_maybe_without_tablets( // Used to prepare a table for test // Creates a new keyspace // Drops and creates table {table_name} (id int PRIMARY KEY, val {type_name}) -async fn init_test(table_name: &str, type_name: &str) -> LegacySession { +async fn init_test(table_name: &str, type_name: &str) -> Session { init_test_maybe_without_tablets(table_name, type_name, true).await } @@ -77,9 +74,9 @@ async fn init_test(table_name: &str, type_name: &str) -> LegacySession { // Expected values and bound values are computed using T::from_str async fn run_tests(tests: &[&str], type_name: &str) where - T: SerializeValue + FromCqlVal + FromStr + Debug + Clone + PartialEq, + T: SerializeValue + for<'r> DeserializeValue<'r> + FromStr + Debug + Clone + PartialEq, { - let session: LegacySession = init_test(type_name, type_name).await; + let session: Session = init_test(type_name, type_name).await; session.await_schema_agreement().await.unwrap(); for test in tests.iter() { @@ -102,7 +99,7 @@ where .query_unpaged(select_values, &[]) .await .unwrap() - .rows_typed::<(T,)>() + .rows::<(T,)>() .unwrap() .map(Result::unwrap) .map(|row| row.0) @@ -170,7 +167,7 @@ async fn test_cql_varint() { ]; let table_name = "cql_varint_tests"; - let session: LegacySession = create_new_session_builder().build_legacy().await.unwrap(); + let session: Session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session @@ -220,7 +217,7 @@ async fn test_cql_varint() { .execute_unpaged(&prepared_select, &[]) .await .unwrap() - .rows_typed::<(CqlVarint,)>() + .rows::<(CqlVarint,)>() .unwrap() .map(Result::unwrap) .map(|row| row.0) @@ -280,7 +277,7 @@ async fn test_counter() { // Can't use run_tests, because counters are special and can't be inserted let type_name = "counter"; - let session: LegacySession = init_test_maybe_without_tablets(type_name, type_name, false).await; + let session: Session = init_test_maybe_without_tablets(type_name, type_name, false).await; for (i, test) in tests.iter().enumerate() { let update_bound_value = format!("UPDATE {} SET val = val + ? WHERE id = ?", type_name); @@ -295,7 +292,7 @@ async fn test_counter() { .query_unpaged(select_values, (i as i32,)) .await .unwrap() - .rows_typed::<(Counter,)>() + .rows::<(Counter,)>() .unwrap() .map(Result::unwrap) .map(|row| row.0) @@ -313,7 +310,7 @@ async fn test_naive_date_04() { use chrono::Datelike; use chrono::NaiveDate; - let session: LegacySession = init_test("chrono_naive_date_tests", "date").await; + let session: Session = init_test("chrono_naive_date_tests", "date").await; let min_naive_date: NaiveDate = NaiveDate::MIN; let min_naive_date_string = min_naive_date.format("%Y-%m-%d").to_string(); @@ -371,7 +368,7 @@ async fn test_naive_date_04() { .query_unpaged("SELECT val from chrono_naive_date_tests", &[]) .await .unwrap() - .rows_typed::<(NaiveDate,)>() + .rows::<(NaiveDate,)>() .unwrap() .next() .unwrap() @@ -394,7 +391,7 @@ async fn test_naive_date_04() { .query_unpaged("SELECT val from chrono_naive_date_tests", &[]) .await .unwrap() - .single_row_typed::<(NaiveDate,)>() + .single_row::<(NaiveDate,)>() .unwrap(); assert_eq!(read_date, *naive_date); } @@ -406,7 +403,7 @@ async fn test_cql_date() { setup_tracing(); // Tests value::Date which allows to insert dates outside NaiveDate range - let session: LegacySession = init_test("cql_date_tests", "date").await; + let session: Session = init_test("cql_date_tests", "date").await; let tests = [ ("1970-01-01", CqlDate(2_u32.pow(31))), @@ -429,15 +426,11 @@ async fn test_cql_date() { .await .unwrap(); - let read_date: CqlDate = session + let (read_date,): (CqlDate,) = session .query_unpaged("SELECT val from cql_date_tests", &[]) .await .unwrap() - .rows - .unwrap()[0] - .columns[0] - .as_ref() - .map(|cql_val| cql_val.as_cql_date().unwrap()) + .single_row::<(CqlDate,)>() .unwrap(); assert_eq!(read_date, *date); @@ -467,7 +460,7 @@ async fn test_date_03() { setup_tracing(); use time::{Date, Month::*}; - let session: LegacySession = init_test("time_date_tests", "date").await; + let session: Session = init_test("time_date_tests", "date").await; let tests = [ // Basic test values @@ -520,7 +513,7 @@ async fn test_date_03() { .query_unpaged("SELECT val from time_date_tests", &[]) .await .unwrap() - .first_row_typed::<(Date,)>() + .first_row::<(Date,)>() .ok() .map(|val| val.0); @@ -540,7 +533,7 @@ async fn test_date_03() { .query_unpaged("SELECT val from time_date_tests", &[]) .await .unwrap() - .first_row_typed::<(Date,)>() + .first_row::<(Date,)>() .unwrap(); assert_eq!(read_date, *date); } @@ -553,7 +546,7 @@ async fn test_cql_time() { // CqlTime is an i64 - nanoseconds since midnight // in range 0..=86399999999999 - let session: LegacySession = init_test("cql_time_tests", "time").await; + let session: Session = init_test("cql_time_tests", "time").await; let max_time: i64 = 24 * 60 * 60 * 1_000_000_000 - 1; assert_eq!(max_time, 86399999999999); @@ -583,7 +576,7 @@ async fn test_cql_time() { .query_unpaged("SELECT val from cql_time_tests", &[]) .await .unwrap() - .single_row_typed::<(CqlTime,)>() + .single_row::<(CqlTime,)>() .unwrap(); assert_eq!(read_time, *time_duration); @@ -601,7 +594,7 @@ async fn test_cql_time() { .query_unpaged("SELECT val from cql_time_tests", &[]) .await .unwrap() - .single_row_typed::<(CqlTime,)>() + .single_row::<(CqlTime,)>() .unwrap(); assert_eq!(read_time, *time_duration); @@ -679,7 +672,7 @@ async fn test_naive_time_04() { .query_unpaged("SELECT val from chrono_time_tests", &[]) .await .unwrap() - .first_row_typed::<(NaiveTime,)>() + .first_row::<(NaiveTime,)>() .unwrap(); assert_eq!(read_time, *time); @@ -697,7 +690,7 @@ async fn test_naive_time_04() { .query_unpaged("SELECT val from chrono_time_tests", &[]) .await .unwrap() - .first_row_typed::<(NaiveTime,)>() + .first_row::<(NaiveTime,)>() .unwrap(); assert_eq!(read_time, *time); } @@ -759,7 +752,7 @@ async fn test_time_03() { .query_unpaged("SELECT val from time_time_tests", &[]) .await .unwrap() - .first_row_typed::<(Time,)>() + .first_row::<(Time,)>() .unwrap(); assert_eq!(read_time, *time); @@ -777,7 +770,7 @@ async fn test_time_03() { .query_unpaged("SELECT val from time_time_tests", &[]) .await .unwrap() - .first_row_typed::<(Time,)>() + .first_row::<(Time,)>() .unwrap(); assert_eq!(read_time, *time); } @@ -786,7 +779,7 @@ async fn test_time_03() { #[tokio::test] async fn test_cql_timestamp() { setup_tracing(); - let session: LegacySession = init_test("cql_timestamp_tests", "timestamp").await; + let session: Session = init_test("cql_timestamp_tests", "timestamp").await; //let epoch_date = NaiveDate::from_ymd_opt(1970, 1, 1).unwrap(); @@ -830,7 +823,7 @@ async fn test_cql_timestamp() { .query_unpaged("SELECT val from cql_timestamp_tests", &[]) .await .unwrap() - .single_row_typed::<(CqlTimestamp,)>() + .single_row::<(CqlTimestamp,)>() .unwrap(); assert_eq!(read_timestamp, *timestamp_duration); @@ -848,7 +841,7 @@ async fn test_cql_timestamp() { .query_unpaged("SELECT val from cql_timestamp_tests", &[]) .await .unwrap() - .single_row_typed::<(CqlTimestamp,)>() + .single_row::<(CqlTimestamp,)>() .unwrap(); assert_eq!(read_timestamp, *timestamp_duration); @@ -925,7 +918,7 @@ async fn test_date_time_04() { .query_unpaged("SELECT val from chrono_datetime_tests", &[]) .await .unwrap() - .first_row_typed::<(DateTime,)>() + .first_row::<(DateTime,)>() .unwrap(); assert_eq!(read_datetime, *datetime); @@ -943,7 +936,7 @@ async fn test_date_time_04() { .query_unpaged("SELECT val from chrono_datetime_tests", &[]) .await .unwrap() - .first_row_typed::<(DateTime,)>() + .first_row::<(DateTime,)>() .unwrap(); assert_eq!(read_datetime, *datetime); } @@ -971,7 +964,7 @@ async fn test_date_time_04() { .query_unpaged("SELECT val from chrono_datetime_tests", &[]) .await .unwrap() - .first_row_typed::<(DateTime,)>() + .first_row::<(DateTime,)>() .unwrap(); assert_eq!(read_datetime, nanosecond_precision_1st_half_rounded); @@ -997,7 +990,7 @@ async fn test_date_time_04() { .query_unpaged("SELECT val from chrono_datetime_tests", &[]) .await .unwrap() - .first_row_typed::<(DateTime,)>() + .first_row::<(DateTime,)>() .unwrap(); assert_eq!(read_datetime, nanosecond_precision_2nd_half_rounded); @@ -1086,7 +1079,7 @@ async fn test_offset_date_time_03() { .query_unpaged("SELECT val from time_datetime_tests", &[]) .await .unwrap() - .first_row_typed::<(OffsetDateTime,)>() + .first_row::<(OffsetDateTime,)>() .unwrap(); assert_eq!(read_datetime, *datetime); @@ -1104,7 +1097,7 @@ async fn test_offset_date_time_03() { .query_unpaged("SELECT val from time_datetime_tests", &[]) .await .unwrap() - .first_row_typed::<(OffsetDateTime,)>() + .first_row::<(OffsetDateTime,)>() .unwrap(); assert_eq!(read_datetime, *datetime); } @@ -1132,7 +1125,7 @@ async fn test_offset_date_time_03() { .query_unpaged("SELECT val from time_datetime_tests", &[]) .await .unwrap() - .first_row_typed::<(OffsetDateTime,)>() + .first_row::<(OffsetDateTime,)>() .unwrap(); assert_eq!(read_datetime, nanosecond_precision_1st_half_rounded); @@ -1158,7 +1151,7 @@ async fn test_offset_date_time_03() { .query_unpaged("SELECT val from time_datetime_tests", &[]) .await .unwrap() - .first_row_typed::<(OffsetDateTime,)>() + .first_row::<(OffsetDateTime,)>() .unwrap(); assert_eq!(read_datetime, nanosecond_precision_2nd_half_rounded); } @@ -1166,7 +1159,7 @@ async fn test_offset_date_time_03() { #[tokio::test] async fn test_timeuuid() { setup_tracing(); - let session: LegacySession = init_test("timeuuid_tests", "timeuuid").await; + let session: Session = init_test("timeuuid_tests", "timeuuid").await; // A few random timeuuids generated manually let tests = [ @@ -1207,7 +1200,7 @@ async fn test_timeuuid() { .query_unpaged("SELECT val from timeuuid_tests", &[]) .await .unwrap() - .single_row_typed::<(CqlTimeuuid,)>() + .single_row::<(CqlTimeuuid,)>() .unwrap(); assert_eq!(read_timeuuid.as_bytes(), timeuuid_bytes); @@ -1226,7 +1219,7 @@ async fn test_timeuuid() { .query_unpaged("SELECT val from timeuuid_tests", &[]) .await .unwrap() - .single_row_typed::<(CqlTimeuuid,)>() + .single_row::<(CqlTimeuuid,)>() .unwrap(); assert_eq!(read_timeuuid.as_bytes(), timeuuid_bytes); @@ -1236,7 +1229,7 @@ async fn test_timeuuid() { #[tokio::test] async fn test_timeuuid_ordering() { setup_tracing(); - let session: LegacySession = create_new_session_builder().build_legacy().await.unwrap(); + let session: Session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session @@ -1295,7 +1288,7 @@ async fn test_timeuuid_ordering() { .query_unpaged("SELECT t FROM tab WHERE p = 0", ()) .await .unwrap() - .rows_typed::<(CqlTimeuuid,)>() + .rows::<(CqlTimeuuid,)>() .unwrap() .map(|r| r.unwrap().0) .collect(); @@ -1318,7 +1311,7 @@ async fn test_timeuuid_ordering() { #[tokio::test] async fn test_inet() { setup_tracing(); - let session: LegacySession = init_test("inet_tests", "inet").await; + let session: Session = init_test("inet_tests", "inet").await; let tests = [ ("0.0.0.0", IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))), @@ -1374,7 +1367,7 @@ async fn test_inet() { .query_unpaged("SELECT val from inet_tests WHERE id = 0", &[]) .await .unwrap() - .single_row_typed::<(IpAddr,)>() + .single_row::<(IpAddr,)>() .unwrap(); assert_eq!(read_inet, *inet); @@ -1389,7 +1382,7 @@ async fn test_inet() { .query_unpaged("SELECT val from inet_tests WHERE id = 0", &[]) .await .unwrap() - .single_row_typed::<(IpAddr,)>() + .single_row::<(IpAddr,)>() .unwrap(); assert_eq!(read_inet, *inet); @@ -1399,7 +1392,7 @@ async fn test_inet() { #[tokio::test] async fn test_blob() { setup_tracing(); - let session: LegacySession = init_test("blob_tests", "blob").await; + let session: Session = init_test("blob_tests", "blob").await; let long_blob: Vec = vec![0x11; 1234]; let mut long_blob_str: String = "0x".to_string(); @@ -1440,7 +1433,7 @@ async fn test_blob() { .query_unpaged("SELECT val from blob_tests WHERE id = 0", &[]) .await .unwrap() - .single_row_typed::<(Vec,)>() + .single_row::<(Vec,)>() .unwrap(); assert_eq!(read_blob, *blob); @@ -1455,7 +1448,7 @@ async fn test_blob() { .query_unpaged("SELECT val from blob_tests WHERE id = 0", &[]) .await .unwrap() - .single_row_typed::<(Vec,)>() + .single_row::<(Vec,)>() .unwrap(); assert_eq!(read_blob, *blob); @@ -1468,7 +1461,7 @@ async fn test_udt_after_schema_update() { let table_name = "udt_tests"; let type_name = "usertype1"; - let session: LegacySession = create_new_session_builder().build_legacy().await.unwrap(); + let session: Session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session @@ -1516,7 +1509,7 @@ async fn test_udt_after_schema_update() { .await .unwrap(); - #[derive(SerializeValue, FromUserType, Debug, PartialEq)] + #[derive(SerializeValue, DeserializeValue, Debug, PartialEq)] #[scylla(crate = crate)] struct UdtV1 { first: i32, @@ -1543,7 +1536,7 @@ async fn test_udt_after_schema_update() { .query_unpaged(format!("SELECT val from {} WHERE id = 0", table_name), &[]) .await .unwrap() - .single_row_typed::<(UdtV1,)>() + .single_row::<(UdtV1,)>() .unwrap(); assert_eq!(read_udt, v1); @@ -1560,7 +1553,7 @@ async fn test_udt_after_schema_update() { .query_unpaged(format!("SELECT val from {} WHERE id = 0", table_name), &[]) .await .unwrap() - .single_row_typed::<(UdtV1,)>() + .single_row::<(UdtV1,)>() .unwrap(); assert_eq!(read_udt, v1); @@ -1570,7 +1563,7 @@ async fn test_udt_after_schema_update() { .await .unwrap(); - #[derive(FromUserType, Debug, PartialEq)] + #[derive(DeserializeValue, Debug, PartialEq)] struct UdtV2 { first: i32, second: bool, @@ -1581,7 +1574,7 @@ async fn test_udt_after_schema_update() { .query_unpaged(format!("SELECT val from {} WHERE id = 0", table_name), &[]) .await .unwrap() - .single_row_typed::<(UdtV2,)>() + .single_row::<(UdtV2,)>() .unwrap(); assert_eq!( @@ -1597,7 +1590,7 @@ async fn test_udt_after_schema_update() { #[tokio::test] async fn test_empty() { setup_tracing(); - let session: LegacySession = init_test("empty_tests", "int").await; + let session: Session = init_test("empty_tests", "int").await; session .query_unpaged( @@ -1611,7 +1604,7 @@ async fn test_empty() { .query_unpaged("SELECT val FROM empty_tests WHERE id = 0", ()) .await .unwrap() - .first_row_typed::<(CqlValue,)>() + .first_row::<(CqlValue,)>() .unwrap(); assert_eq!(empty, CqlValue::Empty); @@ -1628,7 +1621,7 @@ async fn test_empty() { .query_unpaged("SELECT val FROM empty_tests WHERE id = 1", ()) .await .unwrap() - .first_row_typed::<(CqlValue,)>() + .first_row::<(CqlValue,)>() .unwrap(); assert_eq!(empty, CqlValue::Empty); @@ -1640,7 +1633,7 @@ async fn test_udt_with_missing_field() { let table_name = "udt_tests"; let type_name = "usertype1"; - let session: LegacySession = create_new_session_builder().build_legacy().await.unwrap(); + let session: Session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session @@ -1691,14 +1684,14 @@ async fn test_udt_with_missing_field() { let mut id = 0; async fn verify_insert_select_identity( - session: &LegacySession, + session: &Session, table_name: &str, id: i32, element: TQ, expected: TR, ) where TQ: SerializeValue, - TR: FromCqlVal + PartialEq + Debug, + TR: for<'r> DeserializeValue<'r> + PartialEq + Debug, { session .query_unpaged( @@ -1714,13 +1707,13 @@ async fn test_udt_with_missing_field() { ) .await .unwrap() - .single_row_typed::<(TR,)>() + .single_row::<(TR,)>() .unwrap() .0; assert_eq!(expected, result); } - #[derive(FromUserType, Debug, PartialEq)] + #[derive(DeserializeValue, Debug, PartialEq)] struct UdtFull { first: i32, second: bool, diff --git a/scylla/src/transport/cql_value_test.rs b/scylla/src/transport/cql_value_test.rs index d3d2d18e48..912e5ce796 100644 --- a/scylla/src/transport/cql_value_test.rs +++ b/scylla/src/transport/cql_value_test.rs @@ -1,13 +1,14 @@ -use crate::frame::{response::result::CqlValue, value::CqlDuration}; +use crate::frame::response::result::{CqlValue, Row}; +use crate::frame::value::CqlDuration; use crate::test_utils::{create_new_session_builder, setup_tracing}; use crate::utils::test_utils::unique_keyspace_name; -use crate::LegacySession; +use crate::Session; #[tokio::test] async fn test_cqlvalue_udt() { setup_tracing(); - let session: LegacySession = create_new_session_builder().build_legacy().await.unwrap(); + let session: Session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session .query_unpaged( @@ -58,7 +59,9 @@ async fn test_cqlvalue_udt() { .query_unpaged("SELECT my FROM cqlvalue_udt_test", &[]) .await .unwrap() - .rows + .rows::() + .unwrap() + .collect::, _>>() .unwrap(); assert_eq!(rows.len(), 1); @@ -72,7 +75,7 @@ async fn test_cqlvalue_udt() { #[tokio::test] async fn test_cqlvalue_duration() { setup_tracing(); - let session: LegacySession = create_new_session_builder().build_legacy().await.unwrap(); + let session: Session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session @@ -113,7 +116,9 @@ async fn test_cqlvalue_duration() { ) .await .unwrap() - .rows + .rows::() + .unwrap() + .collect::, _>>() .unwrap(); assert_eq!(rows.len(), 4); diff --git a/scylla/src/transport/large_batch_statements_test.rs b/scylla/src/transport/large_batch_statements_test.rs index d63c22a169..5c59adb723 100644 --- a/scylla/src/transport/large_batch_statements_test.rs +++ b/scylla/src/transport/large_batch_statements_test.rs @@ -8,13 +8,13 @@ use crate::test_utils::setup_tracing; use crate::{ batch::Batch, test_utils::{create_new_session_builder, unique_keyspace_name}, - LegacyQueryResult, LegacySession, + QueryResult, Session, }; #[tokio::test] async fn test_large_batch_statements() { setup_tracing(); - let mut session = create_new_session_builder().build_legacy().await.unwrap(); + let mut session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session = create_test_session(session, &ks).await; @@ -32,7 +32,7 @@ async fn test_large_batch_statements() { ) } -async fn create_test_session(session: LegacySession, ks: &String) -> LegacySession { +async fn create_test_session(session: Session, ks: &String) -> Session { session .query_unpaged( format!("CREATE KEYSPACE {} WITH REPLICATION = {{ 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 }}",ks), @@ -52,11 +52,7 @@ async fn create_test_session(session: LegacySession, ks: &String) -> LegacySessi session } -async fn write_batch( - session: &LegacySession, - n: usize, - ks: &String, -) -> Result { +async fn write_batch(session: &Session, n: usize, ks: &String) -> Result { let mut batch_query = Batch::new(BatchType::Unlogged); let mut batch_values = Vec::new(); let query = format!("INSERT INTO {}.pairs (dummy, k, v) VALUES (0, ?, ?)", ks); diff --git a/scylla/src/transport/load_balancing/default.rs b/scylla/src/transport/load_balancing/default.rs index 2867053fa9..962cbd2440 100644 --- a/scylla/src/transport/load_balancing/default.rs +++ b/scylla/src/transport/load_balancing/default.rs @@ -3853,7 +3853,7 @@ mod latency_awareness { let session = create_new_session_builder() .default_execution_profile_handle(handle) - .build_legacy() + .build() .await .unwrap(); diff --git a/scylla/src/transport/session_test.rs b/scylla/src/transport/session_test.rs index 746b3d03c1..066ec671d9 100644 --- a/scylla/src/transport/session_test.rs +++ b/scylla/src/transport/session_test.rs @@ -1,18 +1,17 @@ -use crate as scylla; use crate::batch::{Batch, BatchStatement}; -use crate::frame::response::result::Row; use crate::prepared_statement::PreparedStatement; use crate::query::Query; use crate::retry_policy::{QueryInfo, RetryDecision, RetryPolicy, RetrySession}; use crate::routing::Token; use crate::statement::Consistency; -use crate::test_utils::{scylla_supports_tablets_legacy, setup_tracing}; +use crate::test_utils::{scylla_supports_tablets, setup_tracing}; use crate::tracing::TracingInfo; use crate::transport::cluster::Datacenter; use crate::transport::errors::{BadKeyspaceName, BadQuery, DbError, QueryError}; use crate::transport::partitioner::{ calculate_token_for_partition_key, Murmur3Partitioner, Partitioner, PartitionerName, }; +use crate::transport::session::Session; use crate::transport::topology::Strategy::NetworkTopologyStrategy; use crate::transport::topology::{ CollectionType, ColumnKind, CqlType, NativeType, UserDefinedType, @@ -21,14 +20,14 @@ use crate::utils::test_utils::{ create_new_session_builder, supports_feature, unique_keyspace_name, }; use crate::ExecutionProfile; -use crate::LegacyCachingSession; -use crate::LegacyQueryResult; -use crate::{LegacySession, SessionBuilder}; +use crate::{self as scylla, QueryResult}; +use crate::{CachingSession, SessionBuilder}; use assert_matches::assert_matches; -use futures::{FutureExt, StreamExt, TryStreamExt}; +use futures::{FutureExt, TryStreamExt}; use itertools::Itertools; use scylla_cql::frame::request::query::{PagingState, PagingStateResponse}; use scylla_cql::frame::response::result::ColumnType; +use scylla_cql::frame::response::result::Row; use scylla_cql::types::serialize::row::{SerializeRow, SerializedValues}; use scylla_cql::types::serialize::value::SerializeValue; use std::collections::BTreeSet; @@ -56,10 +55,7 @@ async fn test_connection_failure() { .remote_handle(); tokio::spawn(fut); - let res = SessionBuilder::new() - .known_node_addr(addr) - .build_legacy() - .await; + let res = SessionBuilder::new().known_node_addr(addr).build().await; match res { Ok(_) => panic!("Unexpected success"), Err(err) => println!("Connection error (it was expected): {:?}", err), @@ -69,7 +65,7 @@ async fn test_connection_failure() { #[tokio::test] async fn test_unprepared_statement() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -111,42 +107,38 @@ async fn test_unprepared_statement() { .await .unwrap(); - let (a_idx, _) = query_result.get_column_spec("a").unwrap(); - let (b_idx, _) = query_result.get_column_spec("b").unwrap(); - let (c_idx, _) = query_result.get_column_spec("c").unwrap(); - assert!(query_result.get_column_spec("d").is_none()); + let col_specs = query_result.column_specs().unwrap(); + assert_eq!(col_specs.get_by_name("a").unwrap().0, 0); + assert_eq!(col_specs.get_by_name("b").unwrap().0, 1); + assert_eq!(col_specs.get_by_name("c").unwrap().0, 2); + assert!(col_specs.get_by_name("d").is_none()); - let rs = query_result.rows.unwrap(); + let mut results = query_result + .rows::<(i32, i32, String)>() + .unwrap() + .collect::, _>>() + .unwrap(); - let mut results: Vec<(i32, i32, &String)> = rs - .iter() - .map(|r| { - let a = r.columns[a_idx].as_ref().unwrap().as_int().unwrap(); - let b = r.columns[b_idx].as_ref().unwrap().as_int().unwrap(); - let c = r.columns[c_idx].as_ref().unwrap().as_text().unwrap(); - (a, b, c) - }) - .collect(); results.sort(); assert_eq!( results, vec![ - (1, 2, &String::from("abc")), - (1, 4, &String::from("hello")), - (7, 11, &String::from("")) + (1, 2, String::from("abc")), + (1, 4, String::from("hello")), + (7, 11, String::from("")) ] ); let query_result = session .query_iter(format!("SELECT a, b, c FROM {}.t", ks), &[]) .await .unwrap(); - let specs = query_result.get_column_specs(); + let specs = query_result.column_specs(); assert_eq!(specs.len(), 3); for (spec, name) in specs.iter().zip(["a", "b", "c"]) { - assert_eq!(spec.name, name); // Check column name. - assert_eq!(spec.table_spec.ks_name(), ks); + assert_eq!(spec.name(), name); // Check column name. + assert_eq!(spec.table_spec().ks_name(), ks); } - let mut results_from_manual_paging: Vec = vec![]; + let mut results_from_manual_paging = vec![]; let query = Query::new(format!("SELECT a, b, c FROM {}.t", ks)).with_page_size(1); let mut paging_state = PagingState::start(); let mut watchdog = 0; @@ -155,7 +147,12 @@ async fn test_unprepared_statement() { .query_single_page(query.clone(), &[], paging_state) .await .unwrap(); - results_from_manual_paging.append(&mut rs_manual.rows.unwrap()); + let mut page_results = rs_manual + .rows::<(i32, i32, String)>() + .unwrap() + .collect::, _>>() + .unwrap(); + results_from_manual_paging.append(&mut page_results); match paging_state_response { PagingStateResponse::HasMorePages { state } => { paging_state = state; @@ -165,13 +162,13 @@ async fn test_unprepared_statement() { } watchdog += 1; } - assert_eq!(results_from_manual_paging, rs); + assert_eq!(results_from_manual_paging, results); } #[tokio::test] async fn test_prepared_statement() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -199,11 +196,11 @@ async fn test_prepared_statement() { .await .unwrap(); let query_result = session.execute_iter(prepared_statement, &[]).await.unwrap(); - let specs = query_result.get_column_specs(); + let specs = query_result.column_specs(); assert_eq!(specs.len(), 3); for (spec, name) in specs.iter().zip(["a", "b", "c"]) { - assert_eq!(spec.name, name); // Check column name. - assert_eq!(spec.table_spec.ks_name(), ks); + assert_eq!(spec.name(), name); // Check column name. + assert_eq!(spec.table_spec().ks_name(), ks); } let prepared_statement = session @@ -238,7 +235,7 @@ async fn test_prepared_statement() { .query_unpaged(format!("SELECT token(a) FROM {}.t2", ks), &[]) .await .unwrap() - .single_row_typed() + .single_row::<(i64,)>() .unwrap(); let token = Token::new(value); let prepared_token = Murmur3Partitioner @@ -257,7 +254,7 @@ async fn test_prepared_statement() { .query_unpaged(format!("SELECT token(a,b,c) FROM {}.complex_pk", ks), &[]) .await .unwrap() - .single_row_typed() + .single_row::<(i64,)>() .unwrap(); let token = Token::new(value); let prepared_token = Murmur3Partitioner.hash_one( @@ -279,15 +276,14 @@ async fn test_prepared_statement() { .query_unpaged(format!("SELECT a,b,c FROM {}.t2", ks), &[]) .await .unwrap() - .rows + .rows::<(i32, i32, String)>() + .unwrap() + .collect::, _>>() .unwrap(); - let r = rs.first().unwrap(); - let a = r.columns[0].as_ref().unwrap().as_int().unwrap(); - let b = r.columns[1].as_ref().unwrap().as_int().unwrap(); - let c = r.columns[2].as_ref().unwrap().as_text().unwrap(); - assert_eq!((a, b, c), (17, 16, &String::from("I'm prepared!!!"))); + let r = &rs[0]; + assert_eq!(r, &(17, 16, String::from("I'm prepared!!!"))); - let mut results_from_manual_paging: Vec = vec![]; + let mut results_from_manual_paging = vec![]; let query = Query::new(format!("SELECT a, b, c FROM {}.t2", ks)).with_page_size(1); let prepared_paged = session.prepare(query).await.unwrap(); let mut paging_state = PagingState::start(); @@ -297,7 +293,12 @@ async fn test_prepared_statement() { .execute_single_page(&prepared_paged, &[], paging_state) .await .unwrap(); - results_from_manual_paging.append(&mut rs_manual.rows.unwrap()); + let mut page_results = rs_manual + .rows::<(i32, i32, String)>() + .unwrap() + .collect::, _>>() + .unwrap(); + results_from_manual_paging.append(&mut page_results); match paging_state_response { PagingStateResponse::HasMorePages { state } => { paging_state = state; @@ -314,7 +315,7 @@ async fn test_prepared_statement() { .query_unpaged(format!("SELECT a,b,c,d,e FROM {}.complex_pk", ks), &[]) .await .unwrap() - .single_row_typed() + .single_row::<(i32, i32, String, i32, Option)>() .unwrap(); assert!(e.is_none()); assert_eq!( @@ -322,9 +323,9 @@ async fn test_prepared_statement() { (17, 16, "I'm prepared!!!", 7, None) ); } - // Check that SerializeRow macro works + // Check that SerializeRow and DeserializeRow macros work { - #[derive(scylla::SerializeRow, scylla::FromRow, PartialEq, Debug, Clone)] + #[derive(scylla::SerializeRow, scylla::DeserializeRow, PartialEq, Debug, Clone)] #[scylla(crate = crate)] struct ComplexPk { a: i32, @@ -360,7 +361,7 @@ async fn test_prepared_statement() { ) .await .unwrap() - .single_row_typed() + .single_row() .unwrap(); assert_eq!(input, output) } @@ -372,13 +373,13 @@ async fn test_counter_batch() { use scylla_cql::frame::request::batch::BatchType; setup_tracing(); - let session = Arc::new(create_new_session_builder().build_legacy().await.unwrap()); + let session = Arc::new(create_new_session_builder().build().await.unwrap()); let ks = unique_keyspace_name(); // Need to disable tablets in this test because they don't support counters yet. // (https://github.com/scylladb/scylladb/commit/c70f321c6f581357afdf3fd8b4fe8e5c5bb9736e). let mut create_ks = format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks); - if scylla_supports_tablets_legacy(&session).await { + if scylla_supports_tablets(&session).await { create_ks += " AND TABLETS = {'enabled': false}" } @@ -427,7 +428,7 @@ async fn test_counter_batch() { #[tokio::test] async fn test_batch() { setup_tracing(); - let session = Arc::new(create_new_session_builder().build_legacy().await.unwrap()); + let session = Arc::new(create_new_session_builder().build().await.unwrap()); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -481,7 +482,7 @@ async fn test_batch() { .query_unpaged(format!("SELECT a, b, c FROM {}.t_batch", ks), &[]) .await .unwrap() - .rows_typed() + .rows::<(i32, i32, String)>() .unwrap() .collect::>() .unwrap(); @@ -518,7 +519,7 @@ async fn test_batch() { ) .await .unwrap() - .rows_typed() + .rows::<(i32, i32, String)>() .unwrap() .collect::>() .unwrap(); @@ -529,7 +530,7 @@ async fn test_batch() { #[tokio::test] async fn test_token_calculation() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -571,7 +572,7 @@ async fn test_token_calculation() { ) .await .unwrap() - .single_row_typed() + .single_row::<(i64,)>() .unwrap(); let token = Token::new(value); let prepared_token = Murmur3Partitioner @@ -588,7 +589,7 @@ async fn test_token_calculation() { #[tokio::test] async fn test_token_awareness() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); // Need to disable tablets in this test because they make token routing @@ -597,7 +598,7 @@ async fn test_token_awareness() { let mut create_ks = format!( "CREATE KEYSPACE IF NOT EXISTS {ks} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}" ); - if scylla_supports_tablets_legacy(&session).await { + if scylla_supports_tablets(&session).await { create_ks += " AND TABLETS = {'enabled': false}" } @@ -627,7 +628,7 @@ async fn test_token_awareness() { .await .unwrap(); let tracing_info = session - .get_tracing_info(res.tracing_id.as_ref().unwrap()) + .get_tracing_info(res.tracing_id().as_ref().unwrap()) .await .unwrap(); @@ -639,7 +640,7 @@ async fn test_token_awareness() { .execute_iter(prepared_statement.clone(), values) .await .unwrap(); - let tracing_id = iter.get_tracing_ids()[0]; + let tracing_id = iter.tracing_ids()[0]; let tracing_info = session.get_tracing_info(&tracing_id).await.unwrap(); // Again, verify that only one node was involved @@ -650,7 +651,7 @@ async fn test_token_awareness() { #[tokio::test] async fn test_use_keyspace() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -679,7 +680,7 @@ async fn test_use_keyspace() { .query_unpaged("SELECT * FROM tab", &[]) .await .unwrap() - .rows_typed::<(String,)>() + .rows::<(String,)>() .unwrap() .map(|res| res.unwrap().0) .collect(); @@ -718,9 +719,9 @@ async fn test_use_keyspace() { )); // Make sure that use_keyspace on SessionBuiler works - let session2: LegacySession = create_new_session_builder() + let session2: Session = create_new_session_builder() .use_keyspace(ks.clone(), false) - .build_legacy() + .build() .await .unwrap(); @@ -728,7 +729,7 @@ async fn test_use_keyspace() { .query_unpaged("SELECT * FROM tab", &[]) .await .unwrap() - .rows_typed::<(String,)>() + .rows::<(String,)>() .unwrap() .map(|res| res.unwrap().0) .collect(); @@ -741,7 +742,7 @@ async fn test_use_keyspace() { #[tokio::test] async fn test_use_keyspace_case_sensitivity() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks_lower = unique_keyspace_name().to_lowercase(); let ks_upper = ks_lower.to_uppercase(); @@ -788,7 +789,7 @@ async fn test_use_keyspace_case_sensitivity() { .query_unpaged("SELECT * from tab", &[]) .await .unwrap() - .rows_typed::<(String,)>() + .rows::<(String,)>() .unwrap() .map(|row| row.unwrap().0) .collect(); @@ -803,7 +804,7 @@ async fn test_use_keyspace_case_sensitivity() { .query_unpaged("SELECT * from tab", &[]) .await .unwrap() - .rows_typed::<(String,)>() + .rows::<(String,)>() .unwrap() .map(|row| row.unwrap().0) .collect(); @@ -814,7 +815,7 @@ async fn test_use_keyspace_case_sensitivity() { #[tokio::test] async fn test_raw_use_keyspace() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -844,7 +845,7 @@ async fn test_raw_use_keyspace() { .query_unpaged("SELECT * FROM tab", &[]) .await .unwrap() - .rows_typed::<(String,)>() + .rows::<(String,)>() .unwrap() .map(|res| res.unwrap().0) .collect(); @@ -866,7 +867,7 @@ async fn test_raw_use_keyspace() { #[tokio::test] async fn test_fetch_system_keyspace() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let prepared_statement = session .prepare("SELECT * FROM system_schema.keyspaces") @@ -883,7 +884,7 @@ async fn test_fetch_system_keyspace() { #[tokio::test] async fn test_db_errors() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); // SyntaxError on bad query @@ -938,7 +939,7 @@ async fn test_db_errors() { #[tokio::test] async fn test_tracing() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -960,39 +961,38 @@ async fn test_tracing() { test_tracing_batch(&session, ks.clone()).await; } -async fn test_tracing_query(session: &LegacySession, ks: String) { +async fn test_tracing_query(session: &Session, ks: String) { // A query without tracing enabled has no tracing uuid in result let untraced_query: Query = Query::new(format!("SELECT * FROM {}.tab", ks)); - let untraced_query_result: LegacyQueryResult = + let untraced_query_result: QueryResult = session.query_unpaged(untraced_query, &[]).await.unwrap(); - assert!(untraced_query_result.tracing_id.is_none()); + assert!(untraced_query_result.tracing_id().is_none()); // A query with tracing enabled has a tracing uuid in result let mut traced_query: Query = Query::new(format!("SELECT * FROM {}.tab", ks)); traced_query.config.tracing = true; - let traced_query_result: LegacyQueryResult = - session.query_unpaged(traced_query, &[]).await.unwrap(); - assert!(traced_query_result.tracing_id.is_some()); + let traced_query_result: QueryResult = session.query_unpaged(traced_query, &[]).await.unwrap(); + assert!(traced_query_result.tracing_id().is_some()); // Querying this uuid from tracing table gives some results - assert_in_tracing_table(session, traced_query_result.tracing_id.unwrap()).await; + assert_in_tracing_table(session, traced_query_result.tracing_id().unwrap()).await; } -async fn test_tracing_execute(session: &LegacySession, ks: String) { +async fn test_tracing_execute(session: &Session, ks: String) { // Executing a prepared statement without tracing enabled has no tracing uuid in result let untraced_prepared = session .prepare(format!("SELECT * FROM {}.tab", ks)) .await .unwrap(); - let untraced_prepared_result: LegacyQueryResult = session + let untraced_prepared_result: QueryResult = session .execute_unpaged(&untraced_prepared, &[]) .await .unwrap(); - assert!(untraced_prepared_result.tracing_id.is_none()); + assert!(untraced_prepared_result.tracing_id().is_none()); // Executing a prepared statement with tracing enabled has a tracing uuid in result let mut traced_prepared = session @@ -1002,17 +1002,17 @@ async fn test_tracing_execute(session: &LegacySession, ks: String) { traced_prepared.config.tracing = true; - let traced_prepared_result: LegacyQueryResult = session + let traced_prepared_result: QueryResult = session .execute_unpaged(&traced_prepared, &[]) .await .unwrap(); - assert!(traced_prepared_result.tracing_id.is_some()); + assert!(traced_prepared_result.tracing_id().is_some()); // Querying this uuid from tracing table gives some results - assert_in_tracing_table(session, traced_prepared_result.tracing_id.unwrap()).await; + assert_in_tracing_table(session, traced_prepared_result.tracing_id().unwrap()).await; } -async fn test_tracing_prepare(session: &LegacySession, ks: String) { +async fn test_tracing_prepare(session: &Session, ks: String) { // Preparing a statement without tracing enabled has no tracing uuids in result let untraced_prepared = session .prepare(format!("SELECT * FROM {}.tab", ks)) @@ -1034,14 +1034,13 @@ async fn test_tracing_prepare(session: &LegacySession, ks: String) { } } -async fn test_get_tracing_info(session: &LegacySession, ks: String) { +async fn test_get_tracing_info(session: &Session, ks: String) { // A query with tracing enabled has a tracing uuid in result let mut traced_query: Query = Query::new(format!("SELECT * FROM {}.tab", ks)); traced_query.config.tracing = true; - let traced_query_result: LegacyQueryResult = - session.query_unpaged(traced_query, &[]).await.unwrap(); - let tracing_id: Uuid = traced_query_result.tracing_id.unwrap(); + let traced_query_result: QueryResult = session.query_unpaged(traced_query, &[]).await.unwrap(); + let tracing_id: Uuid = traced_query_result.tracing_id().unwrap(); // Getting tracing info from session using this uuid works let tracing_info: TracingInfo = session.get_tracing_info(&tracing_id).await.unwrap(); @@ -1049,7 +1048,7 @@ async fn test_get_tracing_info(session: &LegacySession, ks: String) { assert!(!tracing_info.nodes().is_empty()); } -async fn test_tracing_query_iter(session: &LegacySession, ks: String) { +async fn test_tracing_query_iter(session: &Session, ks: String) { // A query without tracing enabled has no tracing ids let untraced_query: Query = Query::new(format!("SELECT * FROM {}.tab", ks)); @@ -1058,11 +1057,11 @@ async fn test_tracing_query_iter(session: &LegacySession, ks: String) { // Receive rows } - assert!(untraced_row_iter.get_tracing_ids().is_empty()); + assert!(untraced_row_iter.tracing_ids().is_empty()); // The same is true for TypedRowIter - let untraced_typed_row_iter = untraced_row_iter.into_typed::<(String,)>(); - assert!(untraced_typed_row_iter.get_tracing_ids().is_empty()); + let untraced_typed_row_iter = untraced_row_iter.into_typed::<(&str,)>().unwrap(); + assert!(untraced_typed_row_iter.tracing_ids().is_empty()); // A query with tracing enabled has a tracing ids in result let mut traced_query: Query = Query::new(format!("SELECT * FROM {}.tab", ks)); @@ -1073,18 +1072,18 @@ async fn test_tracing_query_iter(session: &LegacySession, ks: String) { // Receive rows } - assert!(!traced_row_iter.get_tracing_ids().is_empty()); + assert!(!traced_row_iter.tracing_ids().is_empty()); // The same is true for TypedRowIter - let traced_typed_row_iter = traced_row_iter.into_typed::<(String,)>(); - assert!(!traced_typed_row_iter.get_tracing_ids().is_empty()); + let traced_typed_row_iter = traced_row_iter.into_typed::<(&str,)>().unwrap(); + assert!(!traced_typed_row_iter.tracing_ids().is_empty()); - for tracing_id in traced_typed_row_iter.get_tracing_ids() { + for tracing_id in traced_typed_row_iter.tracing_ids() { assert_in_tracing_table(session, *tracing_id).await; } } -async fn test_tracing_execute_iter(session: &LegacySession, ks: String) { +async fn test_tracing_execute_iter(session: &Session, ks: String) { // A prepared statement without tracing enabled has no tracing ids let untraced_prepared = session .prepare(format!("SELECT * FROM {}.tab", ks)) @@ -1096,11 +1095,11 @@ async fn test_tracing_execute_iter(session: &LegacySession, ks: String) { // Receive rows } - assert!(untraced_row_iter.get_tracing_ids().is_empty()); + assert!(untraced_row_iter.tracing_ids().is_empty()); // The same is true for TypedRowIter - let untraced_typed_row_iter = untraced_row_iter.into_typed::<(String,)>(); - assert!(untraced_typed_row_iter.get_tracing_ids().is_empty()); + let untraced_typed_row_iter = untraced_row_iter.into_typed::<(&str,)>().unwrap(); + assert!(untraced_typed_row_iter.tracing_ids().is_empty()); // A prepared statement with tracing enabled has a tracing ids in result let mut traced_prepared = session @@ -1114,38 +1113,37 @@ async fn test_tracing_execute_iter(session: &LegacySession, ks: String) { // Receive rows } - assert!(!traced_row_iter.get_tracing_ids().is_empty()); + assert!(!traced_row_iter.tracing_ids().is_empty()); // The same is true for TypedRowIter - let traced_typed_row_iter = traced_row_iter.into_typed::<(String,)>(); - assert!(!traced_typed_row_iter.get_tracing_ids().is_empty()); + let traced_typed_row_iter = traced_row_iter.into_typed::<(&str,)>().unwrap(); + assert!(!traced_typed_row_iter.tracing_ids().is_empty()); - for tracing_id in traced_typed_row_iter.get_tracing_ids() { + for tracing_id in traced_typed_row_iter.tracing_ids() { assert_in_tracing_table(session, *tracing_id).await; } } -async fn test_tracing_batch(session: &LegacySession, ks: String) { +async fn test_tracing_batch(session: &Session, ks: String) { // A batch without tracing enabled has no tracing id let mut untraced_batch: Batch = Default::default(); untraced_batch.append_statement(&format!("INSERT INTO {}.tab (a) VALUES('a')", ks)[..]); - let untraced_batch_result: LegacyQueryResult = - session.batch(&untraced_batch, ((),)).await.unwrap(); - assert!(untraced_batch_result.tracing_id.is_none()); + let untraced_batch_result: QueryResult = session.batch(&untraced_batch, ((),)).await.unwrap(); + assert!(untraced_batch_result.tracing_id().is_none()); // Batch with tracing enabled has a tracing uuid in result let mut traced_batch: Batch = Default::default(); traced_batch.append_statement(&format!("INSERT INTO {}.tab (a) VALUES('a')", ks)[..]); traced_batch.config.tracing = true; - let traced_batch_result: LegacyQueryResult = session.batch(&traced_batch, ((),)).await.unwrap(); - assert!(traced_batch_result.tracing_id.is_some()); + let traced_batch_result: QueryResult = session.batch(&traced_batch, ((),)).await.unwrap(); + assert!(traced_batch_result.tracing_id().is_some()); - assert_in_tracing_table(session, traced_batch_result.tracing_id.unwrap()).await; + assert_in_tracing_table(session, traced_batch_result.tracing_id().unwrap()).await; } -async fn assert_in_tracing_table(session: &LegacySession, tracing_uuid: Uuid) { +async fn assert_in_tracing_table(session: &Session, tracing_uuid: Uuid) { let mut traces_query = Query::new("SELECT * FROM system_traces.sessions WHERE session_id = ?"); traces_query.config.consistency = Some(Consistency::One); @@ -1180,14 +1178,14 @@ async fn assert_in_tracing_table(session: &LegacySession, tracing_uuid: Uuid) { #[tokio::test] async fn test_await_schema_agreement() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let _schema_version = session.await_schema_agreement().await.unwrap(); } #[tokio::test] async fn test_timestamp() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -1275,7 +1273,7 @@ async fn test_timestamp() { ) .await .unwrap() - .rows_typed::<(String, String, i64)>() + .rows::<(String, String, i64)>() .unwrap() .map(Result::unwrap) .collect::>(); @@ -1306,7 +1304,7 @@ async fn test_request_timeout() { .into_handle(); { - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let mut query: Query = Query::new("SELECT * FROM system_schema.tables"); query.set_request_timeout(Some(Duration::from_millis(1))); @@ -1329,7 +1327,7 @@ async fn test_request_timeout() { { let timeouting_session = create_new_session_builder() .default_execution_profile_handle(fast_timeouting_profile_handle) - .build_legacy() + .build() .await .unwrap(); @@ -1365,7 +1363,7 @@ async fn test_request_timeout() { #[tokio::test] async fn test_prepared_config() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let mut query = Query::new("SELECT * FROM system_schema.tables"); query.set_is_idempotent(true); @@ -1452,7 +1450,7 @@ fn udt_type_c_def(ks: &str) -> Arc { #[tokio::test] async fn test_schema_types_in_metadata() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session @@ -1611,7 +1609,7 @@ async fn test_schema_types_in_metadata() { #[tokio::test] async fn test_user_defined_types_in_metadata() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session @@ -1675,7 +1673,7 @@ async fn test_user_defined_types_in_metadata() { #[tokio::test] async fn test_column_kinds_in_metadata() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session @@ -1721,7 +1719,7 @@ async fn test_column_kinds_in_metadata() { #[tokio::test] async fn test_primary_key_ordering_in_metadata() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session @@ -1770,14 +1768,14 @@ async fn test_table_partitioner_in_metadata() { return; } - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); // This test uses CDC which is not yet compatible with Scylla's tablets. let mut create_ks = format!( "CREATE KEYSPACE {ks} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}" ); - if scylla_supports_tablets_legacy(&session).await { + if scylla_supports_tablets(&session).await { create_ks += " AND TABLETS = {'enabled': false}"; } @@ -1816,7 +1814,7 @@ async fn test_turning_off_schema_fetching() { setup_tracing(); let session = create_new_session_builder() .fetch_schema_metadata(false) - .build_legacy() + .build() .await .unwrap(); let ks = unique_keyspace_name(); @@ -1891,7 +1889,7 @@ async fn test_turning_off_schema_fetching() { #[tokio::test] async fn test_named_bind_markers() { - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session @@ -1928,7 +1926,7 @@ async fn test_named_bind_markers() { .query_unpaged("SELECT pk, ck, v FROM t", &[]) .await .unwrap() - .rows_typed::<(i32, i32, i32)>() + .rows::<(i32, i32, i32)>() .unwrap() .map(|res| res.unwrap()) .collect(); @@ -1948,13 +1946,13 @@ async fn test_named_bind_markers() { #[tokio::test] async fn test_prepared_partitioner() { - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); // This test uses CDC which is not yet compatible with Scylla's tablets. let mut create_ks = format!( "CREATE KEYSPACE IF NOT EXISTS {ks} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}"); - if scylla_supports_tablets_legacy(&session).await { + if scylla_supports_tablets(&session).await { create_ks += " AND TABLETS = {'enabled': false}" } @@ -2005,14 +2003,14 @@ async fn test_prepared_partitioner() { ); } -async fn rename(session: &LegacySession, rename_str: &str) { +async fn rename(session: &Session, rename_str: &str) { session .query_unpaged(format!("ALTER TABLE tab RENAME {}", rename_str), ()) .await .unwrap(); } -async fn rename_caching(session: &LegacyCachingSession, rename_str: &str) { +async fn rename_caching(session: &CachingSession, rename_str: &str) { session .execute_unpaged(format!("ALTER TABLE tab RENAME {}", rename_str), &()) .await @@ -2030,7 +2028,7 @@ async fn rename_caching(session: &LegacyCachingSession, rename_str: &str) { async fn test_unprepared_reprepare_in_execute() { let _ = tracing_subscriber::fmt::try_init(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -2079,7 +2077,7 @@ async fn test_unprepared_reprepare_in_execute() { .query_unpaged("SELECT a, b, c FROM tab", ()) .await .unwrap() - .rows_typed::<(i32, i32, i32)>() + .rows::<(i32, i32, i32)>() .unwrap() .map(|r| r.unwrap()) .collect(); @@ -2091,7 +2089,7 @@ async fn test_unprepared_reprepare_in_execute() { async fn test_unusual_valuelists() { let _ = tracing_subscriber::fmt::try_init(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -2134,7 +2132,7 @@ async fn test_unusual_valuelists() { .query_unpaged("SELECT a, b, c FROM tab", ()) .await .unwrap() - .rows_typed::<(i32, i32, String)>() + .rows::<(i32, i32, String)>() .unwrap() .map(|r| r.unwrap()) .collect(); @@ -2159,7 +2157,7 @@ async fn test_unusual_valuelists() { async fn test_unprepared_reprepare_in_batch() { let _ = tracing_subscriber::fmt::try_init(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -2205,7 +2203,7 @@ async fn test_unprepared_reprepare_in_batch() { .query_unpaged("SELECT a, b, c FROM tab", ()) .await .unwrap() - .rows_typed::<(i32, i32, i32)>() + .rows::<(i32, i32, i32)>() .unwrap() .map(|r| r.unwrap()) .collect(); @@ -2224,13 +2222,13 @@ async fn test_unprepared_reprepare_in_batch() { async fn test_unprepared_reprepare_in_caching_session_execute() { let _ = tracing_subscriber::fmt::try_init(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); session.use_keyspace(ks, false).await.unwrap(); - let caching_session: LegacyCachingSession = LegacyCachingSession::from(session, 64); + let caching_session: CachingSession = CachingSession::from(session, 64); caching_session .execute_unpaged( @@ -2272,7 +2270,7 @@ async fn test_unprepared_reprepare_in_caching_session_execute() { .execute_unpaged("SELECT a, b, c FROM tab", &()) .await .unwrap() - .rows_typed::<(i32, i32, i32)>() + .rows::<(i32, i32, i32)>() .unwrap() .map(|r| r.unwrap()) .collect(); @@ -2284,7 +2282,7 @@ async fn test_unprepared_reprepare_in_caching_session_execute() { async fn test_views_in_schema_info() { let _ = tracing_subscriber::fmt::try_init(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -2334,12 +2332,12 @@ async fn test_views_in_schema_info() { ) } -async fn assert_test_batch_table_rows_contain(sess: &LegacySession, expected_rows: &[(i32, i32)]) { +async fn assert_test_batch_table_rows_contain(sess: &Session, expected_rows: &[(i32, i32)]) { let selected_rows: BTreeSet<(i32, i32)> = sess .query_unpaged("SELECT a, b FROM test_batch_table", ()) .await .unwrap() - .rows_typed::<(i32, i32)>() + .rows::<(i32, i32)>() .unwrap() .map(|r| r.unwrap()) .collect(); @@ -2355,7 +2353,7 @@ async fn assert_test_batch_table_rows_contain(sess: &LegacySession, expected_row #[tokio::test] async fn test_prepare_batch() { - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -2452,7 +2450,7 @@ async fn test_prepare_batch() { #[tokio::test] async fn test_refresh_metadata_after_schema_agreement() { - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -2490,7 +2488,7 @@ async fn test_refresh_metadata_after_schema_agreement() { #[tokio::test] async fn test_rate_limit_exceeded_exception() { - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); // Typed errors in RPC were introduced along with per-partition rate limiting. // There is no dedicated feature for per-partition rate limiting, so we are @@ -2538,11 +2536,11 @@ async fn test_rate_limit_exceeded_exception() { // Batches containing LWT queries (IF col = som) return rows with information whether the queries were applied. #[tokio::test] async fn test_batch_lwts() { - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); let mut create_ks = format!("CREATE KEYSPACE {} WITH REPLICATION = {{'class': 'NetworkTopologyStrategy', 'replication_factor': 1}}", ks); - if scylla_supports_tablets_legacy(&session).await { + if scylla_supports_tablets(&session).await { create_ks += " and TABLETS = { 'enabled': false}"; } session.query_unpaged(create_ks, &[]).await.unwrap(); @@ -2566,10 +2564,10 @@ async fn test_batch_lwts() { batch.append_statement("INSERT INTO tab (p1, c1, r1, r2) VALUES (0, 123, 321, 312)"); batch.append_statement("UPDATE tab SET r1 = 1 WHERE p1 = 0 AND c1 = 0 IF r2 = 0"); - let batch_res: LegacyQueryResult = session.batch(&batch, ((), (), ())).await.unwrap(); + let batch_res: QueryResult = session.batch(&batch, ((), (), ())).await.unwrap(); // Scylla returns 5 columns, but Cassandra returns only 1 - let is_scylla: bool = batch_res.col_specs().len() == 5; + let is_scylla: bool = batch_res.column_specs().unwrap().len() == 5; if is_scylla { test_batch_lwts_for_scylla(&session, &batch, batch_res).await; @@ -2578,21 +2576,14 @@ async fn test_batch_lwts() { } } -async fn test_batch_lwts_for_scylla( - session: &LegacySession, - batch: &Batch, - batch_res: LegacyQueryResult, -) { +async fn test_batch_lwts_for_scylla(session: &Session, batch: &Batch, batch_res: QueryResult) { // Alias required by clippy type IntOrNull = Option; // Returned columns are: // [applied], p1, c1, r1, r2 - let batch_res_rows: Vec<(bool, IntOrNull, IntOrNull, IntOrNull, IntOrNull)> = batch_res - .rows_typed() - .unwrap() - .map(|r| r.unwrap()) - .collect(); + let batch_res_rows: Vec<(bool, IntOrNull, IntOrNull, IntOrNull, IntOrNull)> = + batch_res.rows().unwrap().map(|r| r.unwrap()).collect(); let expected_batch_res_rows = vec![ (true, Some(0), Some(0), Some(0), Some(0)), @@ -2603,12 +2594,12 @@ async fn test_batch_lwts_for_scylla( assert_eq!(batch_res_rows, expected_batch_res_rows); let prepared_batch: Batch = session.prepare_batch(batch).await.unwrap(); - let prepared_batch_res: LegacyQueryResult = + let prepared_batch_res: QueryResult = session.batch(&prepared_batch, ((), (), ())).await.unwrap(); let prepared_batch_res_rows: Vec<(bool, IntOrNull, IntOrNull, IntOrNull, IntOrNull)> = prepared_batch_res - .rows_typed() + .rows() .unwrap() .map(|r| r.unwrap()) .collect(); @@ -2622,35 +2613,27 @@ async fn test_batch_lwts_for_scylla( assert_eq!(prepared_batch_res_rows, expected_prepared_batch_res_rows); } -async fn test_batch_lwts_for_cassandra( - session: &LegacySession, - batch: &Batch, - batch_res: LegacyQueryResult, -) { +async fn test_batch_lwts_for_cassandra(session: &Session, batch: &Batch, batch_res: QueryResult) { // Alias required by clippy type IntOrNull = Option; // Returned columns are: // [applied] - let batch_res_rows: Vec<(bool,)> = batch_res - .rows_typed() - .unwrap() - .map(|r| r.unwrap()) - .collect(); + let batch_res_rows: Vec<(bool,)> = batch_res.rows().unwrap().map(|r| r.unwrap()).collect(); let expected_batch_res_rows = vec![(true,)]; assert_eq!(batch_res_rows, expected_batch_res_rows); let prepared_batch: Batch = session.prepare_batch(batch).await.unwrap(); - let prepared_batch_res: LegacyQueryResult = + let prepared_batch_res: QueryResult = session.batch(&prepared_batch, ((), (), ())).await.unwrap(); // Returned columns are: // [applied], p1, c1, r1, r2 let prepared_batch_res_rows: Vec<(bool, IntOrNull, IntOrNull, IntOrNull, IntOrNull)> = prepared_batch_res - .rows_typed() + .rows() .unwrap() .map(|r| r.unwrap()) .collect(); @@ -2665,7 +2648,7 @@ async fn test_keyspaces_to_fetch() { let ks1 = unique_keyspace_name(); let ks2 = unique_keyspace_name(); - let session_default = create_new_session_builder().build_legacy().await.unwrap(); + let session_default = create_new_session_builder().build().await.unwrap(); for ks in [&ks1, &ks2] { session_default .query_unpaged(format!("CREATE KEYSPACE {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]) @@ -2684,7 +2667,7 @@ async fn test_keyspaces_to_fetch() { let session1 = create_new_session_builder() .keyspaces_to_fetch([&ks1]) - .build_legacy() + .build() .await .unwrap(); assert!(session1.get_cluster_data().keyspaces.contains_key(&ks1)); @@ -2692,7 +2675,7 @@ async fn test_keyspaces_to_fetch() { let session_all = create_new_session_builder() .keyspaces_to_fetch([] as [String; 0]) - .build_legacy() + .build() .await .unwrap(); assert!(session_all.get_cluster_data().keyspaces.contains_key(&ks1)); @@ -2737,7 +2720,7 @@ async fn test_iter_works_when_retry_policy_returns_ignore_write_error() { let session = create_new_session_builder() .default_execution_profile_handle(handle) - .build_legacy() + .build() .await .unwrap(); @@ -2745,7 +2728,7 @@ async fn test_iter_works_when_retry_policy_returns_ignore_write_error() { let cluster_size = session.get_cluster_data().get_nodes_info().len(); let ks = unique_keyspace_name(); let mut create_ks = format!("CREATE KEYSPACE {} WITH REPLICATION = {{'class': 'NetworkTopologyStrategy', 'replication_factor': {}}}", ks, cluster_size + 1); - if scylla_supports_tablets_legacy(&session).await { + if scylla_supports_tablets(&session).await { create_ks += " and TABLETS = { 'enabled': false}"; } session.query_unpaged(create_ks, ()).await.unwrap(); @@ -2761,7 +2744,10 @@ async fn test_iter_works_when_retry_policy_returns_ignore_write_error() { let mut iter = session .query_iter("INSERT INTO t (pk v) VALUES (1, 2)", ()) .await - .unwrap(); + .unwrap() + .into_typed::() + .unwrap() + .into_stream(); assert!(retried_flag.load(Ordering::Relaxed)); while iter.try_next().await.unwrap().is_some() {} @@ -2772,7 +2758,13 @@ async fn test_iter_works_when_retry_policy_returns_ignore_write_error() { .prepare("INSERT INTO t (pk, v) VALUES (?, ?)") .await .unwrap(); - let mut iter = session.execute_iter(p, (1, 2)).await.unwrap(); + let mut iter = session + .execute_iter(p, (1, 2)) + .await + .unwrap() + .into_typed::() + .unwrap() + .into_stream(); assert!(retried_flag.load(Ordering::Relaxed)); while iter.try_next().await.unwrap().is_some() {} @@ -2780,7 +2772,7 @@ async fn test_iter_works_when_retry_policy_returns_ignore_write_error() { #[tokio::test] async fn test_iter_methods_with_modification_statements() { - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -2802,7 +2794,7 @@ async fn test_iter_methods_with_modification_statements() { query.set_tracing(true); let mut row_iterator = session.query_iter(query, &[]).await.unwrap(); row_iterator.next().await.ok_or(()).unwrap_err(); // assert empty - assert!(!row_iterator.get_tracing_ids().is_empty()); + assert!(!row_iterator.tracing_ids().is_empty()); let prepared_statement = session .prepare(format!("INSERT INTO {}.t (a, b, c) VALUES (?, ?, ?)", ks)) @@ -2821,7 +2813,7 @@ async fn test_get_keyspace_name() { // Create the keyspace // No keyspace is set in config, so get_keyspace() should return None. - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); assert_eq!(session.get_keyspace(), None); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); assert_eq!(session.get_keyspace(), None); @@ -2846,7 +2838,7 @@ async fn test_get_keyspace_name() { #[tokio::test] async fn simple_strategy_test() { let ks = unique_keyspace_name(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); session .query_unpaged( @@ -2898,7 +2890,7 @@ async fn simple_strategy_test() { .query_unpaged(format!("SELECT p, c, r FROM {}.tab", ks), ()) .await .unwrap() - .rows_typed::<(i32, i32, i32)>() + .rows::<(i32, i32, i32)>() .unwrap() .map(|r| r.unwrap()) .collect::>(); @@ -2911,12 +2903,12 @@ async fn simple_strategy_test() { async fn test_manual_primary_key_computation() { // Setup session let ks = unique_keyspace_name(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); session.use_keyspace(&ks, true).await.unwrap(); async fn assert_tokens_equal( - session: &LegacySession, + session: &Session, prepared: &PreparedStatement, serialized_pk_values_in_pk_order: &SerializedValues, all_values_in_query_order: impl SerializeRow, diff --git a/scylla/src/transport/silent_prepare_batch_test.rs b/scylla/src/transport/silent_prepare_batch_test.rs index c7ae8e83d7..3b14d1f3d5 100644 --- a/scylla/src/transport/silent_prepare_batch_test.rs +++ b/scylla/src/transport/silent_prepare_batch_test.rs @@ -2,14 +2,14 @@ use crate::{ batch::Batch, prepared_statement::PreparedStatement, test_utils::{create_new_session_builder, setup_tracing, unique_keyspace_name}, - LegacySession, + Session, }; use std::collections::BTreeSet; #[tokio::test] async fn test_quietly_prepare_batch() { setup_tracing(); - let session = create_new_session_builder().build_legacy().await.unwrap(); + let session = create_new_session_builder().build().await.unwrap(); let ks = unique_keyspace_name(); session.query_unpaged(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks), &[]).await.unwrap(); @@ -91,12 +91,12 @@ async fn test_quietly_prepare_batch() { } } -async fn assert_test_batch_table_rows_contain(sess: &LegacySession, expected_rows: &[(i32, i32)]) { +async fn assert_test_batch_table_rows_contain(sess: &Session, expected_rows: &[(i32, i32)]) { let selected_rows: BTreeSet<(i32, i32)> = sess .query_unpaged("SELECT a, b FROM test_batch_table", ()) .await .unwrap() - .rows_typed::<(i32, i32)>() + .rows::<(i32, i32)>() .unwrap() .map(|r| r.unwrap()) .collect(); diff --git a/scylla/src/utils/test_utils.rs b/scylla/src/utils/test_utils.rs index 5b041f730d..00015b8f43 100644 --- a/scylla/src/utils/test_utils.rs +++ b/scylla/src/utils/test_utils.rs @@ -2,7 +2,7 @@ use scylla_cql::frame::response::result::Row; #[cfg(test)] use crate::transport::session_builder::{GenericSessionBuilder, SessionBuilderKind}; -use crate::{LegacySession, Session}; +use crate::Session; #[cfg(test)] use std::{num::NonZeroU32, time::Duration}; use std::{ @@ -27,7 +27,7 @@ pub fn unique_keyspace_name() -> String { } #[cfg(test)] -pub(crate) async fn supports_feature(session: &LegacySession, feature: &str) -> bool { +pub(crate) async fn supports_feature(session: &Session, feature: &str) -> bool { // Cassandra doesn't have a concept of features, so first detect // if there is the `supported_features` column in system.local @@ -48,7 +48,7 @@ pub(crate) async fn supports_feature(session: &LegacySession, feature: &str) -> .query_unpaged("SELECT supported_features FROM system.local", ()) .await .unwrap() - .single_row_typed() + .single_row() .unwrap(); features @@ -94,20 +94,6 @@ pub fn create_new_session_builder() -> GenericSessionBuilder bool { - let result = session - .query_unpaged( - "select column_name from system_schema.columns where - keyspace_name = 'system_schema' - and table_name = 'scylla_keyspaces' - and column_name = 'initial_tablets'", - &[], - ) - .await - .unwrap(); - result.single_row().is_ok() -} - pub async fn scylla_supports_tablets(session: &Session) -> bool { let result = session .query_unpaged( diff --git a/scylla/tests/integration/consistency.rs b/scylla/tests/integration/consistency.rs index 643969d462..88debe2e53 100644 --- a/scylla/tests/integration/consistency.rs +++ b/scylla/tests/integration/consistency.rs @@ -6,8 +6,8 @@ use scylla::prepared_statement::PreparedStatement; use scylla::retry_policy::FallthroughRetryPolicy; use scylla::routing::{Shard, Token}; use scylla::test_utils::unique_keyspace_name; -use scylla::transport::session::LegacySession; use scylla::transport::NodeRef; +use scylla::Session; use scylla_cql::frame::response::result::TableSpec; use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender}; @@ -59,7 +59,7 @@ fn pairs_of_all_consistencies() -> impl Iterator, @@ -81,7 +81,7 @@ async fn query_consistency_set_directly( } async fn execute_consistency_set_directly( - session: &LegacySession, + session: &Session, prepared: &PreparedStatement, c: Consistency, sc: Option, @@ -94,7 +94,7 @@ async fn execute_consistency_set_directly( } async fn batch_consistency_set_directly( - session: &LegacySession, + session: &Session, batch: &Batch, c: Consistency, sc: Option, @@ -107,7 +107,7 @@ async fn batch_consistency_set_directly( // The following functions perform a request with consistencies set on a per-statement execution profile. async fn query_consistency_set_on_exec_profile( - session: &LegacySession, + session: &Session, query: &Query, profile: ExecutionProfileHandle, ) { @@ -118,7 +118,7 @@ async fn query_consistency_set_on_exec_profile( } async fn execute_consistency_set_on_exec_profile( - session: &LegacySession, + session: &Session, prepared: &PreparedStatement, profile: ExecutionProfileHandle, ) { @@ -129,7 +129,7 @@ async fn execute_consistency_set_on_exec_profile( } async fn batch_consistency_set_on_exec_profile( - session: &LegacySession, + session: &Session, batch: &Batch, profile: ExecutionProfileHandle, ) { @@ -159,7 +159,7 @@ async fn check_for_all_consistencies_and_setting_options< let session = session_builder .clone() .default_execution_profile_handle(base_for_every_profile.clone().build().into_handle()) - .build_legacy() + .build() .await .unwrap(); create_schema(&session, ks).await; @@ -212,7 +212,7 @@ async fn check_for_all_consistencies_and_setting_options< let session_with_consistencies = session_builder .clone() .default_execution_profile_handle(handle) - .build_legacy() + .build() .await .unwrap(); session_with_consistencies @@ -473,7 +473,7 @@ async fn consistency_allows_for_paxos_selects() { let session = SessionBuilder::new() .known_node(uri.as_str()) - .build_legacy() + .build() .await .unwrap(); diff --git a/scylla/tests/integration/execution_profiles.rs b/scylla/tests/integration/execution_profiles.rs index cf89a0a93c..cc571ef71b 100644 --- a/scylla/tests/integration/execution_profiles.rs +++ b/scylla/tests/integration/execution_profiles.rs @@ -163,7 +163,7 @@ async fn test_execution_profiles() { .known_node(proxy_uris[0].as_str()) .address_translator(Arc::new(translation_map)) .default_execution_profile_handle(profile1.into_handle()) - .build_legacy() + .build() .await .unwrap(); let ks = unique_keyspace_name(); diff --git a/scylla/tests/integration/lwt_optimisation.rs b/scylla/tests/integration/lwt_optimisation.rs index e2c3eb2949..689a352b39 100644 --- a/scylla/tests/integration/lwt_optimisation.rs +++ b/scylla/tests/integration/lwt_optimisation.rs @@ -1,8 +1,8 @@ use crate::utils::{setup_tracing, test_with_3_node_cluster}; use scylla::retry_policy::FallthroughRetryPolicy; -use scylla::test_utils::scylla_supports_tablets_legacy; +use scylla::test_utils::scylla_supports_tablets; use scylla::test_utils::unique_keyspace_name; -use scylla::transport::session::LegacySession; +use scylla::transport::session::Session; use scylla::{ExecutionProfile, SessionBuilder}; use scylla_cql::frame::protocol_features::ProtocolFeatures; use scylla_cql::frame::types; @@ -52,11 +52,11 @@ async fn if_lwt_optimisation_mark_offered_then_negotiatied_and_lwt_routed_optima .into_handle(); // DB preparation phase - let session: LegacySession = SessionBuilder::new() + let session: Session = SessionBuilder::new() .known_node(proxy_uris[0].as_str()) .default_execution_profile_handle(handle) .address_translator(Arc::new(translation_map)) - .build_legacy() + .build() .await .unwrap(); @@ -70,7 +70,7 @@ async fn if_lwt_optimisation_mark_offered_then_negotiatied_and_lwt_routed_optima // Create schema let ks = unique_keyspace_name(); let mut create_ks = format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 3}}", ks); - if scylla_supports_tablets_legacy(&session).await { + if scylla_supports_tablets(&session).await { create_ks += " and TABLETS = { 'enabled': false}"; } session.query_unpaged(create_ks, &[]).await.unwrap(); diff --git a/scylla/tests/integration/new_session.rs b/scylla/tests/integration/new_session.rs index b212c87cd0..2f41c39e32 100644 --- a/scylla/tests/integration/new_session.rs +++ b/scylla/tests/integration/new_session.rs @@ -16,7 +16,7 @@ async fn proceed_if_only_some_hostnames_are_invalid() { let session = SessionBuilder::new() .known_nodes([uri1, uri2, uri3]) - .build_legacy() + .build() .await .unwrap(); session diff --git a/scylla/tests/integration/retries.rs b/scylla/tests/integration/retries.rs index d2a1f2fb15..92bf1613c7 100644 --- a/scylla/tests/integration/retries.rs +++ b/scylla/tests/integration/retries.rs @@ -1,7 +1,7 @@ use crate::utils::{setup_tracing, test_with_3_node_cluster}; use scylla::retry_policy::FallthroughRetryPolicy; use scylla::speculative_execution::SimpleSpeculativeExecutionPolicy; -use scylla::transport::session::LegacySession; +use scylla::transport::session::Session; use scylla::ExecutionProfile; use scylla::SessionBuilder; use scylla::{query::Query, test_utils::unique_keyspace_name}; @@ -27,11 +27,11 @@ async fn speculative_execution_is_fired() { max_retry_count: 2, retry_interval: Duration::from_millis(10), }))).retry_policy(Box::new(FallthroughRetryPolicy)).build(); - let session: LegacySession = SessionBuilder::new() + let session: Session = SessionBuilder::new() .known_node(proxy_uris[0].as_str()) .default_execution_profile_handle(simple_speculative_no_retry_profile.into_handle()) .address_translator(Arc::new(translation_map)) - .build_legacy() + .build() .await .unwrap(); @@ -104,10 +104,10 @@ async fn retries_occur() { let res = test_with_3_node_cluster(ShardAwareness::QueryNode, |proxy_uris, translation_map, mut running_proxy| async move { // DB preparation phase - let session: LegacySession = SessionBuilder::new() + let session: Session = SessionBuilder::new() .known_node(proxy_uris[0].as_str()) .address_translator(Arc::new(translation_map)) - .build_legacy() + .build() .await .unwrap(); diff --git a/scylla/tests/integration/self_identity.rs b/scylla/tests/integration/self_identity.rs index e7378c6e2c..cba46f7171 100644 --- a/scylla/tests/integration/self_identity.rs +++ b/scylla/tests/integration/self_identity.rs @@ -1,5 +1,5 @@ use crate::utils::{setup_tracing, test_with_3_node_cluster}; -use scylla::{LegacySession, SessionBuilder}; +use scylla::{Session, SessionBuilder}; use scylla_cql::frame::request::options; use scylla_cql::frame::types; use std::sync::Arc; @@ -50,11 +50,11 @@ async fn test_given_self_identity(self_identity: SelfIdentity<'static>) { )])); // DB preparation phase - let _session: LegacySession = SessionBuilder::new() + let _session: Session = SessionBuilder::new() .known_node(proxy_uris[0].as_str()) .address_translator(Arc::new(translation_map)) .custom_identity(self_identity.clone()) - .build_legacy() + .build() .await .unwrap(); diff --git a/scylla/tests/integration/shards.rs b/scylla/tests/integration/shards.rs index c3db91ca28..b22cfc397b 100644 --- a/scylla/tests/integration/shards.rs +++ b/scylla/tests/integration/shards.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use crate::utils::{setup_tracing, test_with_3_node_cluster}; -use scylla::test_utils::scylla_supports_tablets_legacy; +use scylla::test_utils::scylla_supports_tablets; use scylla::{test_utils::unique_keyspace_name, SessionBuilder}; use tokio::sync::mpsc; @@ -32,14 +32,14 @@ async fn test_consistent_shard_awareness() { let session = SessionBuilder::new() .known_node(proxy_uris[0].as_str()) .address_translator(Arc::new(translation_map)) - .build_legacy() + .build() .await .unwrap(); let ks = unique_keyspace_name(); /* Prepare schema */ let mut create_ks = format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 3}}", ks); - if scylla_supports_tablets_legacy(&session).await { + if scylla_supports_tablets(&session).await { create_ks += " and TABLETS = { 'enabled': false}"; } session.query_unpaged(create_ks, &[]).await.unwrap(); diff --git a/scylla/tests/integration/silent_prepare_query.rs b/scylla/tests/integration/silent_prepare_query.rs index 64da404069..93950206a5 100644 --- a/scylla/tests/integration/silent_prepare_query.rs +++ b/scylla/tests/integration/silent_prepare_query.rs @@ -1,5 +1,5 @@ use crate::utils::{setup_tracing, test_with_3_node_cluster}; -use scylla::transport::session::LegacySession; +use scylla::Session; use scylla::SessionBuilder; use scylla::{query::Query, test_utils::unique_keyspace_name}; use scylla_proxy::{ @@ -19,10 +19,10 @@ async fn test_prepare_query_with_values() { let res = test_with_3_node_cluster(ShardAwareness::QueryNode, |proxy_uris, translation_map, mut running_proxy| async move { // DB preparation phase - let session: LegacySession = SessionBuilder::new() + let session: Session = SessionBuilder::new() .known_node(proxy_uris[0].as_str()) .address_translator(Arc::new(translation_map)) - .build_legacy() + .build() .await .unwrap(); @@ -70,10 +70,10 @@ async fn test_query_with_no_values() { let res = test_with_3_node_cluster(ShardAwareness::QueryNode, |proxy_uris, translation_map, mut running_proxy| async move { // DB preparation phase - let session: LegacySession = SessionBuilder::new() + let session: Session = SessionBuilder::new() .known_node(proxy_uris[0].as_str()) .address_translator(Arc::new(translation_map)) - .build_legacy() + .build() .await .unwrap(); diff --git a/scylla/tests/integration/skip_metadata_optimization.rs b/scylla/tests/integration/skip_metadata_optimization.rs index a50e33b8ba..1f885bc5a3 100644 --- a/scylla/tests/integration/skip_metadata_optimization.rs +++ b/scylla/tests/integration/skip_metadata_optimization.rs @@ -1,7 +1,6 @@ use crate::utils::{setup_tracing, test_with_3_node_cluster}; -use scylla::transport::session::LegacySession; -use scylla::SessionBuilder; use scylla::{prepared_statement::PreparedStatement, test_utils::unique_keyspace_name}; +use scylla::{Session, SessionBuilder}; use scylla_cql::frame::request::query::{PagingState, PagingStateResponse}; use scylla_cql::frame::types; use scylla_proxy::{ @@ -20,10 +19,10 @@ async fn test_skip_result_metadata() { let res = test_with_3_node_cluster(ShardAwareness::QueryNode, |proxy_uris, translation_map, mut running_proxy| async move { // DB preparation phase - let session: LegacySession = SessionBuilder::new() + let session: Session = SessionBuilder::new() .known_node(proxy_uris[0].as_str()) .address_translator(Arc::new(translation_map)) - .build_legacy() + .build() .await .unwrap(); @@ -51,7 +50,7 @@ async fn test_skip_result_metadata() { } async fn test_with_flags_predicate( - session: &LegacySession, + session: &Session, prepared: &PreparedStatement, rx: &mut tokio::sync::mpsc::UnboundedReceiver<(ResponseFrame, Option)>, predicate: impl FnOnce(i32) -> bool @@ -114,7 +113,7 @@ async fn test_skip_result_metadata() { .query_unpaged(select_query, ()) .await .unwrap() - .rows_typed::() + .rows::() .unwrap() .collect::, _>>() .unwrap(); @@ -131,7 +130,7 @@ async fn test_skip_result_metadata() { .await .unwrap(); results_from_manual_paging - .extend(rs_manual.rows_typed::().unwrap().map(Result::unwrap)); + .extend(rs_manual.rows::().unwrap().map(Result::unwrap)); match paging_state_response { PagingStateResponse::HasMorePages { state } => { diff --git a/scylla/tests/integration/tablets.rs b/scylla/tests/integration/tablets.rs index d9c82c02d7..060c4220d5 100644 --- a/scylla/tests/integration/tablets.rs +++ b/scylla/tests/integration/tablets.rs @@ -16,7 +16,7 @@ use scylla::test_utils::unique_keyspace_name; use scylla::transport::ClusterData; use scylla::transport::Node; use scylla::transport::NodeRef; -use scylla::{ExecutionProfile, LegacyQueryResult, LegacySession}; +use scylla::{ExecutionProfile, QueryResult, Session}; use scylla_cql::errors::QueryError; use scylla_proxy::{ @@ -28,7 +28,7 @@ use tokio::sync::mpsc; use tracing::info; use uuid::Uuid; -#[derive(scylla::FromRow)] +#[derive(scylla::DeserializeRow)] struct SelectedTablet { last_token: i64, replicas: Vec<(Uuid, i32)>, @@ -40,7 +40,7 @@ struct Tablet { replicas: Vec<(Arc, i32)>, } -async fn get_tablets(session: &LegacySession, ks: &str, table: &str) -> Vec { +async fn get_tablets(session: &Session, ks: &str, table: &str) -> Vec { let cluster_data = session.get_cluster_data(); let endpoints = cluster_data.get_nodes_info(); for endpoint in endpoints.iter() { @@ -55,8 +55,10 @@ async fn get_tablets(session: &LegacySession, ks: &str, table: &str) -> Vec = selected_tablets_response .into_typed::() + .unwrap() + .into_stream() .try_collect::>() .await .unwrap(); @@ -179,11 +181,11 @@ impl LoadBalancingPolicy for SingleTargetLBP { } async fn send_statement_everywhere( - session: &LegacySession, + session: &Session, cluster: &ClusterData, statement: &PreparedStatement, values: &dyn SerializeRow, -) -> Result, QueryError> { +) -> Result, QueryError> { let tasks = cluster.get_nodes_info().iter().flat_map(|node| { let shard_count: u16 = node.sharder().unwrap().nr_shards.into(); (0..shard_count).map(|shard| { @@ -205,10 +207,10 @@ async fn send_statement_everywhere( } async fn send_unprepared_query_everywhere( - session: &LegacySession, + session: &Session, cluster: &ClusterData, query: &Query, -) -> Result, QueryError> { +) -> Result, QueryError> { let tasks = cluster.get_nodes_info().iter().flat_map(|node| { let shard_count: u16 = node.sharder().unwrap().nr_shards.into(); (0..shard_count).map(|shard| { @@ -247,7 +249,7 @@ fn count_tablet_feedbacks( .count() } -async fn prepare_schema(session: &LegacySession, ks: &str, table: &str, tablet_count: usize) { +async fn prepare_schema(session: &Session, ks: &str, table: &str, tablet_count: usize) { session .query_unpaged( format!( @@ -294,11 +296,11 @@ async fn test_default_policy_is_tablet_aware() { let session = scylla::SessionBuilder::new() .known_node(proxy_uris[0].as_str()) .address_translator(Arc::new(translation_map)) - .build_legacy() + .build() .await .unwrap(); - if !scylla::test_utils::scylla_supports_tablets_legacy(&session).await { + if !scylla::test_utils::scylla_supports_tablets(&session).await { tracing::warn!("Skipping test because this Scylla version doesn't support tablets"); return running_proxy; } @@ -416,6 +418,8 @@ async fn test_default_policy_is_tablet_aware() { #[tokio::test] #[ntest::timeout(30000)] async fn test_tablet_feedback_not_sent_for_unprepared_queries() { + use scylla::test_utils::scylla_supports_tablets; + setup_tracing(); const TABLET_COUNT: usize = 16; @@ -425,11 +429,11 @@ async fn test_tablet_feedback_not_sent_for_unprepared_queries() { let session = scylla::SessionBuilder::new() .known_node(proxy_uris[0].as_str()) .address_translator(Arc::new(translation_map)) - .build_legacy() + .build() .await .unwrap(); - if !scylla::test_utils::scylla_supports_tablets_legacy(&session).await { + if !scylla_supports_tablets(&session).await { tracing::warn!("Skipping test because this Scylla version doesn't support tablets"); return running_proxy; } @@ -488,6 +492,8 @@ async fn test_tablet_feedback_not_sent_for_unprepared_queries() { #[ntest::timeout(30000)] #[ignore] async fn test_lwt_optimization_works_with_tablets() { + use scylla::test_utils::scylla_supports_tablets; + setup_tracing(); const TABLET_COUNT: usize = 16; @@ -497,11 +503,11 @@ async fn test_lwt_optimization_works_with_tablets() { let session = scylla::SessionBuilder::new() .known_node(proxy_uris[0].as_str()) .address_translator(Arc::new(translation_map)) - .build_legacy() + .build() .await .unwrap(); - if !scylla::test_utils::scylla_supports_tablets_legacy(&session).await { + if !scylla_supports_tablets(&session).await { tracing::warn!("Skipping test because this Scylla version doesn't support tablets"); return running_proxy; }