You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test: introduce new tests for balanced query routing
The new tests that DefaultPolicy was as expected for LWT and regular queries for tablets and vnodes.
The different configurations will be tested here.
For current stage were added 3 tests for next configurations:
- tablets ON; token_awere policy; node preferences None; permit falover ON
- tablets ON; token_awere policy; node preferences None; permit falover OFF
- tablets ON; token_awere policy; node preferences DC; permit falover ON
More tests will be added later
// running_nodes_amount: cluster state - how much alive nodes (maximum is 3)
45
+
46
+
setup_tracing();
47
+
48
+
// This is just to increase the likelihood that only intended prepared statements (which contain this mark) are captured by the proxy.
49
+
constMAGIC_MARK:i32 = 123;
50
+
let cluster = cluster.lock().await;
51
+
52
+
let handle = ExecutionProfile::builder()
53
+
.load_balancing_policy(policy.clone())
54
+
.retry_policy(Arc::new(FallthroughRetryPolicy))
55
+
.build()
56
+
.into_handle();
57
+
58
+
let history_listener = Arc::new(HistoryCollector::new());
59
+
60
+
// DB preparation phase
61
+
let session:Session = cluster.make_session_builder()
62
+
.await
63
+
.default_execution_profile_handle(handle)
64
+
.build()
65
+
.await
66
+
.unwrap();
67
+
68
+
// let (supported_frame, _shard) = supported_rx.recv().await.unwrap();
69
+
// let supported_options = types::read_string_multimap(&mut &*supported_frame.body).unwrap();
70
+
// let supported_features = ProtocolFeatures::parse_from_supported(&supported_options);
71
+
72
+
// This will branch our test for cases both when cluster supports the optimisations and when it does not.
73
+
// let supports_optimisation_mark = supported_features.lwt_optimization_meta_bit_mask.is_some();
74
+
75
+
// Create schema
76
+
let ks = unique_keyspace_name();
77
+
78
+
// Enable or disable tablets for the keyspace
79
+
letmut tablets_clause = "";
80
+
ifscylla_supports_tablets(&session).await{
81
+
if tablets_enabled{
82
+
tablets_clause = " AND tablets = {'enabled': true}";
83
+
}else{
84
+
tablets_clause = " AND tablets = {'enabled': false}";
85
+
}
86
+
}
87
+
88
+
let create_ks = format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 3}}{}", ks, tablets_clause);
89
+
90
+
session.ddl(create_ks).await.unwrap();
91
+
session.use_keyspace(ks,false).await.unwrap();
92
+
93
+
session
94
+
.ddl("CREATE TABLE t (a int primary key, b int)")
95
+
.await
96
+
.unwrap();
97
+
98
+
letmut non_lwt_query:Query = Query::new("INSERT INTO t (a, b) VALUES (?, 1)");
99
+
letmut lwt_query:Query = Query::new("UPDATE t SET b=3 WHERE a=? IF b=2");
0 commit comments