Skip to content

Commit ecc3310

Browse files
authored
Merge pull request #292 from muzarski/use-nts-by-default
integration: use NTS by default
2 parents 9ff131d + 5287fa4 commit ecc3310

File tree

9 files changed

+80
-18
lines changed

9 files changed

+80
-18
lines changed

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ SPACE := ${EMPTY} ${EMPTY}
44
ifndef SCYLLA_TEST_FILTER
55
SCYLLA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
66
:BasicsTests.*\
7+
:BasicsNoTabletsTests.*\
78
:ConfigTests.*\
89
:NullStringApiArgsTest.*\
910
:ConsistencyTwoNodeClusterTests.*\
@@ -17,7 +18,7 @@ SCYLLA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
1718
:BatchSingleNodeClusterTests*:BatchCounterSingleNodeClusterTests*:BatchCounterThreeNodeClusterTests*\
1819
:ErrorTests.*\
1920
:SslNoClusterTests*:SslNoSslOnClusterTests*\
20-
:SchemaMetadataTest.*KeyspaceMetadata:SchemaMetadataTest.*MetadataIterator:SchemaMetadataTest.*View*\
21+
:SchemaMetadataTest.*\
2122
:TracingTests.*\
2223
:ByNameTests.*\
2324
:CompressionTests.*\
@@ -38,6 +39,8 @@ SCYLLA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
3839
:ExecutionProfileTest.Integration_Cassandra_SerialConsistency\
3940
:ExecutionProfileTest.Integration_Cassandra_LatencyAwareRouting\
4041
:-PreparedTests.Integration_Cassandra_PreparedIDUnchangedDuringReprepare\
42+
:SchemaMetadataTest.Integration_Cassandra_RegularMetadataNotMarkedVirtual\
43+
:SchemaMetadataTest.Integration_Cassandra_VirtualMetadata\
4144
:HeartbeatTests.Integration_Cassandra_HeartbeatFailed\
4245
:TimestampTests.Integration_Cassandra_MonotonicTimestampGenerator\
4346
:ControlConnectionTests.Integration_Cassandra_TopologyChange\
@@ -58,6 +61,7 @@ endif
5861
ifndef CASSANDRA_TEST_FILTER
5962
CASSANDRA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
6063
:BasicsTests.*\
64+
:BasicsNoTabletsTests.*\
6165
:ConfigTests.*\
6266
:NullStringApiArgsTest.*\
6367
:ConsistencyTwoNodeClusterTests.*\
@@ -70,7 +74,7 @@ CASSANDRA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
7074
:ControlConnectionTests.*\
7175
:ErrorTests.*\
7276
:SslClientAuthenticationTests*:SslNoClusterTests*:SslNoSslOnClusterTests*:SslTests*\
73-
:SchemaMetadataTest.*KeyspaceMetadata:SchemaMetadataTest.*MetadataIterator:SchemaMetadataTest.*View*\
77+
:SchemaMetadataTest.*\
7478
:TracingTests.*\
7579
:ByNameTests.*\
7680
:CompressionTests.*\
@@ -92,6 +96,8 @@ CASSANDRA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
9296
:ExecutionProfileTest.Integration_Cassandra_LatencyAwareRouting\
9397
:-PreparedTests.Integration_Cassandra_PreparedIDUnchangedDuringReprepare\
9498
:PreparedTests.Integration_Cassandra_FailFastWhenPreparedIDChangesDuringReprepare\
99+
:SchemaMetadataTest.Integration_Cassandra_RegularMetadataNotMarkedVirtual\
100+
:SchemaMetadataTest.Integration_Cassandra_VirtualMetadata\
95101
:HeartbeatTests.Integration_Cassandra_HeartbeatFailed\
96102
:TimestampTests.Integration_Cassandra_MonotonicTimestampGenerator\
97103
:ControlConnectionTests.Integration_Cassandra_TopologyChange\

tests/src/integration/integration.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Integration::Integration()
6666
, is_keyspace_change_requested_(true)
6767
, is_test_chaotic_(false)
6868
, is_beta_protocol_(Options::is_beta_protocol())
69+
, disable_tablets_(false)
6970
, protocol_version_(CASS_PROTOCOL_VERSION_V4)
7071
, create_keyspace_query_("")
7172
, start_time_(0ull) {
@@ -267,7 +268,7 @@ std::string Integration::default_replication_strategy() {
267268
replication_strategy_s << "'NetworkTopologyStrategy', 'dc1': " << number_dc1_nodes_ << ", "
268269
<< "'dc2': " << number_dc2_nodes_;
269270
} else {
270-
replication_strategy_s << "'SimpleStrategy', 'replication_factor': ";
271+
replication_strategy_s << "'NetworkTopologyStrategy', 'dc1': ";
271272

272273
// Ensure the replication factor has not been overridden or already set
273274
if (replication_factor_ == 0) {
@@ -349,6 +350,13 @@ void Integration::connect(Cluster cluster) {
349350
<< server_version_.to_string());
350351
}
351352

353+
// Check if scylla supports TABLETS feature. If so, and test
354+
// does not work with tablets (e.g. it uses LWT), disable the tablets
355+
// for test keyspace.
356+
if (disable_tablets_ && scylla_supports_feature("TABLETS")) {
357+
create_keyspace_query_ = create_keyspace_query_ + " AND TABLETS = { 'enabled': false }";
358+
}
359+
352360
// Create the keyspace for the integration test
353361
session_.execute(create_keyspace_query_);
354362
CHECK_FAILURE;
@@ -474,6 +482,19 @@ std::string Integration::generate_contact_points(const std::string& ip_prefix,
474482
return implode(contact_points, ',');
475483
}
476484

485+
bool Integration::scylla_supports_feature(const std::string& feature) {
486+
if (!Options::is_scylla()) {
487+
return false;
488+
}
489+
490+
Result res = session_.execute("SELECT supported_features FROM system.local WHERE key='local'");
491+
Text supported_features = res.first_row().column_by_name<Text>("supported_features");
492+
if (supported_features.is_null()) {
493+
return false;
494+
}
495+
return supported_features.value().find(feature) != std::string::npos;
496+
}
497+
477498
std::string Integration::format_string(const char* format, ...) const {
478499
// Create a buffer for the formatting of the string
479500
char buffer[FORMAT_BUFFER_SIZE] = { '\0' };

tests/src/integration/integration.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ class Integration : public testing::Test {
309309
* (DEFAULT: true)
310310
*/
311311
bool is_beta_protocol_;
312+
/** Flag to indicate if tablets should be disabled for Scylla keyspace.
313+
* There are some cases where the test logic will fail for tablets keyspace
314+
* (e.g. when test uses LWT statements).
315+
* (DEFAULT: false)
316+
*/
317+
bool disable_tablets_;
312318
/**
313319
* Workload to apply to the cluster
314320
*/
@@ -508,6 +514,14 @@ class Integration : public testing::Test {
508514
*/
509515
std::string generate_contact_points(const std::string& ip_prefix, size_t number_of_nodes);
510516

517+
/**
518+
* Check if Scylla supports a specific feature.
519+
*
520+
* @param feature Feature to check if supported by Scylla
521+
* @return True if Scylla supports the feature; false otherwise
522+
*/
523+
bool scylla_supports_feature(const std::string& feature);
524+
511525
/**
512526
* Variable argument string formatter
513527
*

tests/src/integration/tests/test_async.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
class AsyncTests : public Integration {
2525
public:
26+
AsyncTests() { disable_tablets_ = true; }
27+
2628
void SetUp() {
2729
// Call the parent setup function
2830
Integration::SetUp();

tests/src/integration/tests/test_basics.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
*/
2222
class BasicsTests : public Integration {};
2323

24+
class BasicsNoTabletsTests : public BasicsTests {
25+
public:
26+
BasicsNoTabletsTests() { disable_tablets_ = true; }
27+
};
28+
2429
/**
2530
* Perform inserts and validate the timestamps from the server
2631
*
@@ -81,7 +86,7 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, Timestamps) {
8186
* @since core:1.0.0
8287
* @expected_result Cassandra values are inserted and counters are validated
8388
*/
84-
CASSANDRA_INTEGRATION_TEST_F(BasicsTests, Counters) {
89+
CASSANDRA_INTEGRATION_TEST_F(BasicsNoTabletsTests, Counters) {
8590
CHECK_FAILURE;
8691

8792
// Create the table and update/upsert queries for the test

tests/src/integration/tests/test_batch.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ class BatchSingleNodeClusterTests : public Integration {
105105
*/
106106
class BatchCounterSingleNodeClusterTests : public BatchSingleNodeClusterTests {
107107
public:
108-
BatchCounterSingleNodeClusterTests() { value_cql_data_type_ = "counter"; }
108+
BatchCounterSingleNodeClusterTests() {
109+
value_cql_data_type_ = "counter";
110+
// Counter type is not supported with tablets.
111+
disable_tablets_ = true;
112+
}
109113

110114
/**
111115
* Validate the result for the text data type

tests/src/integration/tests/test_consistency.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ class ConsistencyThreeNodeClusterTests : public ConsistencyTwoNodeClusterTests {
6767
*/
6868
class SerialConsistencyTests : public Integration {
6969
public:
70-
SerialConsistencyTests() { number_dc1_nodes_ = 1; }
70+
SerialConsistencyTests() {
71+
number_dc1_nodes_ = 1;
72+
// LWTs do not work with tablets.
73+
disable_tablets_ = true;
74+
}
7175

7276
virtual void SetUp() {
7377
// Call the parent setup function
@@ -240,18 +244,18 @@ CASSANDRA_INTEGRATION_TEST_F(ConsistencyTwoNodeClusterTests, SimpleEachQuorum) {
240244

241245
/**
242246
* Perform multiple inserts and selects using different consistencies against a
243-
* cluster with a single decommissioned node
247+
* cluster with a single stopped node
244248
*
245249
* This test will perform insert and select operations using a simple statement
246250
* while validating the operation were successful or failed against a three
247-
* three node cluster with a decommissioned node.
251+
* three node cluster with a stopped node.
248252
*
249253
* @test_category consistency
250254
* @since core:1.0.0
251255
* @expected_result Successful insert and select using multiple consistencies:
252256
* `ALL`, `ONE`, `TWO`, and `QUORUM`
253257
* Failed insert and select using multiple consistencies:
254-
* `ALL` (after decommission) and `THREE`
258+
* `ALL` (after stopping) and `THREE`
255259
*/
256260
CASSANDRA_INTEGRATION_TEST_F(ConsistencyThreeNodeClusterTests, OneNodeDecommissioned) {
257261
CHECK_FAILURE;
@@ -262,8 +266,8 @@ CASSANDRA_INTEGRATION_TEST_F(ConsistencyThreeNodeClusterTests, OneNodeDecommissi
262266
session_.execute(insert_);
263267
session_.execute(select_);
264268

265-
// Decommission node two
266-
decommission_node(2);
269+
// Stop node two
270+
stop_node(2);
267271

268272
// Perform a check using consistency `QUORUM` (N=2, RF=3)
269273
insert_.set_consistency(CASS_CONSISTENCY_QUORUM);
@@ -298,18 +302,18 @@ CASSANDRA_INTEGRATION_TEST_F(ConsistencyThreeNodeClusterTests, OneNodeDecommissi
298302

299303
/**
300304
* Perform multiple inserts and selects using different consistencies against a
301-
* cluster with a two decommissioned nodes
305+
* cluster with two stopped nodes
302306
*
303307
* This test will perform insert and select operations using a simple statement
304308
* while validating the operation were successful or failed against a three
305-
* node cluster with two decommissioned nodes.
309+
* node cluster with two stopped nodes.
306310
*
307311
* @test_category consistency
308312
* @since core:1.0.0
309313
* @expected_result Successful insert and select using multiple consistencies:
310314
* `ALL`, and `ONE`
311315
* Failed insert and select using multiple consistencies:
312-
* `ALL` (after decommission), `QUORUM`, `TWO`, and `THREE`
316+
* `ALL` (after stopped), `QUORUM`, `TWO`, and `THREE`
313317
*/
314318
CASSANDRA_INTEGRATION_TEST_F(ConsistencyThreeNodeClusterTests, TwoNodesDecommissioned) {
315319
CHECK_FAILURE;
@@ -320,9 +324,9 @@ CASSANDRA_INTEGRATION_TEST_F(ConsistencyThreeNodeClusterTests, TwoNodesDecommiss
320324
session_.execute(insert_);
321325
session_.execute(select_);
322326

323-
// Decommission node two and three
324-
decommission_node(2);
325-
decommission_node(3);
327+
// Stop node two and three
328+
stop_node(2);
329+
stop_node(3);
326330

327331
// Perform a check using consistency `ONE` (N=1, RF=3)
328332
insert_.set_consistency(CASS_CONSISTENCY_ONE);

tests/src/integration/tests/test_exec_profile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class ExecutionProfileTest : public Integration {
3030
// We do not implement logging retry policy in cpp-rust-driver
3131
// , logging_retry_policy_(child_retry_policy_)
3232
, skip_base_execution_profile_(false) {
33+
// LWTs do not work with tablets.
34+
disable_tablets_ = true;
3335
replication_factor_ = 2;
3436
number_dc1_nodes_ = 2;
3537
is_beta_protocol_ = false; // Issue with beta protocol v5 and functions on Cassandra v3.10.0+

tests/src/integration/tests/test_schema_metadata.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222

2323
class SchemaMetadataTest : public Integration {
2424
public:
25-
SchemaMetadataTest() { is_schema_metadata_ = true; }
25+
SchemaMetadataTest() {
26+
is_schema_metadata_ = true;
27+
// Materialized views do not work with tablets.
28+
disable_tablets_ = true;
29+
}
2630

2731
void SetUp() {
2832
SKIP_IF_CASSANDRA_VERSION_LT(2.2.0);

0 commit comments

Comments
 (0)