Skip to content

Commit 36518fc

Browse files
feature(structre): extract utils into seperate common module
Since there will be more folders in scylla/tests, not just integration tests, then we'll need to extract common logic need by all tests folders into seperate module (`common`) before moving forward. Signed-off-by: Dusan Malusev <[email protected]>
1 parent 86efc40 commit 36518fc

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#[path = "../common/mod.rs"]
2+
mod common;

scylla/tests/common/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub(crate) mod utils;

scylla/tests/integration/utils.rs renamed to scylla/tests/common/utils.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@ use tracing::{error, warn};
2222

2323
use scylla_proxy::{Node, Proxy, ProxyError, RunningProxy, ShardAwareness};
2424

25+
#[allow(dead_code)]
2526
pub(crate) fn setup_tracing() {
2627
let _ = tracing_subscriber::fmt::fmt()
2728
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
2829
.with_writer(tracing_subscriber::fmt::TestWriter::new())
2930
.try_init();
3031
}
3132

33+
#[allow(dead_code)]
3234
static UNIQUE_COUNTER: AtomicUsize = AtomicUsize::new(0);
3335

36+
#[allow(dead_code)]
3437
pub(crate) fn unique_keyspace_name() -> String {
3538
let cnt = UNIQUE_COUNTER.fetch_add(1, Ordering::SeqCst);
3639
let name = format!(
@@ -45,6 +48,7 @@ pub(crate) fn unique_keyspace_name() -> String {
4548
name
4649
}
4750

51+
#[allow(dead_code)]
4852
pub(crate) async fn test_with_3_node_cluster<F, Fut>(
4953
shard_awareness: ShardAwareness,
5054
test: F,
@@ -95,6 +99,7 @@ where
9599
running_proxy.finish().await
96100
}
97101

102+
#[allow(dead_code)]
98103
pub(crate) async fn supports_feature(session: &Session, feature: &str) -> bool {
99104
// Cassandra doesn't have a concept of features, so first detect
100105
// if there is the `supported_features` column in system.local
@@ -127,13 +132,15 @@ pub(crate) async fn supports_feature(session: &Session, feature: &str) -> bool {
127132
.any(|f| f == feature)
128133
}
129134

135+
#[allow(dead_code)]
130136
pub(crate) async fn scylla_supports_tablets(session: &Session) -> bool {
131137
supports_feature(session, "TABLETS").await
132138
}
133139

134140
// Creates a generic session builder based on conditional compilation configuration
135141
// For SessionBuilder of DefaultMode type, adds localhost to known hosts, as all of the tests
136142
// connect to localhost.
143+
#[allow(dead_code)]
137144
pub(crate) fn create_new_session_builder() -> GenericSessionBuilder<impl SessionBuilderKind> {
138145
let session_builder = {
139146
#[cfg(not(scylla_cloud_tests))]
@@ -168,6 +175,7 @@ pub(crate) fn create_new_session_builder() -> GenericSessionBuilder<impl Session
168175

169176
// Shorthands for better readability.
170177
// Copied from Scylla because we don't want to make it public there.
178+
#[allow(dead_code)]
171179
pub(crate) trait DeserializeOwnedValue:
172180
for<'frame, 'metadata> DeserializeValue<'frame, 'metadata>
173181
{
@@ -182,6 +190,7 @@ impl<T> DeserializeOwnedValue for T where
182190
// This is to make sure that all DDL queries land on the same node,
183191
// to prevent errors from concurrent DDL queries executed on different nodes.
184192
#[derive(Debug)]
193+
#[allow(dead_code)]
185194
struct SchemaQueriesLBP;
186195

187196
impl LoadBalancingPolicy for SchemaQueriesLBP {
@@ -210,6 +219,7 @@ impl LoadBalancingPolicy for SchemaQueriesLBP {
210219
}
211220

212221
#[derive(Debug, Default)]
222+
#[allow(dead_code)]
213223
struct SchemaQueriesRetrySession {
214224
count: usize,
215225
}
@@ -242,14 +252,16 @@ impl RetrySession for SchemaQueriesRetrySession {
242252
}
243253

244254
#[derive(Debug)]
255+
#[allow(dead_code)]
245256
struct SchemaQueriesRetryPolicy;
246257

247258
impl RetryPolicy for SchemaQueriesRetryPolicy {
248259
fn new_session(&self) -> Box<dyn RetrySession> {
249-
Box::new(SchemaQueriesRetrySession::default())
260+
Box::<SchemaQueriesRetrySession>::default()
250261
}
251262
}
252263

264+
#[allow(dead_code)]
253265
fn apply_ddl_lbp(query: &mut Query) {
254266
let policy = query
255267
.get_execution_profile_handle()
@@ -265,6 +277,7 @@ fn apply_ddl_lbp(query: &mut Query) {
265277
// we'll be able to do session.ddl(...) instead of perform_ddl(&session, ...)
266278
// or something like that.
267279
#[async_trait::async_trait]
280+
#[allow(dead_code)]
268281
pub(crate) trait PerformDDL {
269282
async fn ddl(&self, query: impl Into<Query> + Send) -> Result<(), ExecutionError>;
270283
}

scylla/tests/integration/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ mod silent_prepare_batch;
1818
mod silent_prepare_query;
1919
mod skip_metadata_optimization;
2020
mod tablets;
21-
pub(crate) mod utils;
21+
#[path = "../common/utils.rs"]
22+
mod utils;

0 commit comments

Comments
 (0)