Skip to content

Commit ab71c7a

Browse files
committed
session_test: add a SimpleStrategy test
Scylla is moving away from SimpleStrategy, in general users should use NetworkTopologyStrategy everywhere now. Still it's good to test that the driver works with a SimpleStrategy keyspace, it's still a case that is supported, even if it's slowly getting deprecated. This test runs a few queries in a SimpleStrategy keyspace. Signed-off-by: Jan Ciolek <[email protected]>
1 parent 9535a9b commit ab71c7a

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

scylla/src/transport/session_test.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2731,3 +2731,70 @@ async fn test_get_keyspace_name() {
27312731
.unwrap();
27322732
assert_eq!(*session.get_keyspace().unwrap(), ks);
27332733
}
2734+
2735+
/// It's recommended to use NetworkTopologyStrategy everywhere, so most tests use only NetworkTopologyStrategy.
2736+
/// We still support SimpleStrategy, so to make sure that SimpleStrategy works correctly this test runs
2737+
/// a few queries in a SimpleStrategy keyspace.
2738+
#[tokio::test]
2739+
async fn simple_strategy_test() {
2740+
let ks = unique_keyspace_name();
2741+
let session = create_new_session_builder().build().await.unwrap();
2742+
2743+
session
2744+
.query(
2745+
format!(
2746+
"CREATE KEYSPACE {} WITH REPLICATION = \
2747+
{{'class': 'SimpleStrategy', 'replication_factor': 1}}",
2748+
ks
2749+
),
2750+
(),
2751+
)
2752+
.await
2753+
.unwrap();
2754+
2755+
session
2756+
.query(
2757+
format!(
2758+
"CREATE TABLE {}.tab (p int, c int, r int, PRIMARY KEY (p, c, r))",
2759+
ks
2760+
),
2761+
(),
2762+
)
2763+
.await
2764+
.unwrap();
2765+
2766+
session
2767+
.query(
2768+
format!("INSERT INTO {}.tab (p, c, r) VALUES (1, 2, 3)", ks),
2769+
(),
2770+
)
2771+
.await
2772+
.unwrap();
2773+
2774+
session
2775+
.query(
2776+
format!("INSERT INTO {}.tab (p, c, r) VALUES (?, ?, ?)", ks),
2777+
(4, 5, 6),
2778+
)
2779+
.await
2780+
.unwrap();
2781+
2782+
let prepared = session
2783+
.prepare(format!("INSERT INTO {}.tab (p, c, r) VALUES (?, ?, ?)", ks))
2784+
.await
2785+
.unwrap();
2786+
2787+
session.execute(&prepared, (7, 8, 9)).await.unwrap();
2788+
2789+
let mut rows: Vec<(i32, i32, i32)> = session
2790+
.query(format!("SELECT p, c, r FROM {}.tab", ks), ())
2791+
.await
2792+
.unwrap()
2793+
.rows_typed::<(i32, i32, i32)>()
2794+
.unwrap()
2795+
.map(|r| r.unwrap())
2796+
.collect::<Vec<(i32, i32, i32)>>();
2797+
rows.sort();
2798+
2799+
assert_eq!(rows, vec![(1, 2, 3), (4, 5, 6), (7, 8, 9)]);
2800+
}

0 commit comments

Comments
 (0)