Skip to content

integration: use NTS by default #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 7, 2025
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SPACE := ${EMPTY} ${EMPTY}
ifndef SCYLLA_TEST_FILTER
SCYLLA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
:BasicsTests.*\
:BasicsNoTabletsTests.*\
:ConfigTests.*\
:NullStringApiArgsTest.*\
:ConsistencyTwoNodeClusterTests.*\
Expand All @@ -17,7 +18,7 @@ SCYLLA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
:BatchSingleNodeClusterTests*:BatchCounterSingleNodeClusterTests*:BatchCounterThreeNodeClusterTests*\
:ErrorTests.*\
:SslNoClusterTests*:SslNoSslOnClusterTests*\
:SchemaMetadataTest.*KeyspaceMetadata:SchemaMetadataTest.*MetadataIterator:SchemaMetadataTest.*View*\
:SchemaMetadataTest.*\
:TracingTests.*\
:ByNameTests.*\
:CompressionTests.*\
Expand All @@ -37,6 +38,8 @@ SCYLLA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
:ExecutionProfileTest.Integration_Cassandra_SerialConsistency\
:ExecutionProfileTest.Integration_Cassandra_LatencyAwareRouting\
:-PreparedTests.Integration_Cassandra_PreparedIDUnchangedDuringReprepare\
:SchemaMetadataTest.Integration_Cassandra_RegularMetadataNotMarkedVirtual\
:SchemaMetadataTest.Integration_Cassandra_VirtualMetadata\
:HeartbeatTests.Integration_Cassandra_HeartbeatFailed\
:ControlConnectionTests.Integration_Cassandra_TopologyChange\
:ControlConnectionTests.Integration_Cassandra_FullOutage\
Expand All @@ -56,6 +59,7 @@ endif
ifndef CASSANDRA_TEST_FILTER
CASSANDRA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
:BasicsTests.*\
:BasicsNoTabletsTests.*\
:ConfigTests.*\
:NullStringApiArgsTest.*\
:ConsistencyTwoNodeClusterTests.*\
Expand All @@ -68,7 +72,7 @@ CASSANDRA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
:ControlConnectionTests.*\
:ErrorTests.*\
:SslClientAuthenticationTests*:SslNoClusterTests*:SslNoSslOnClusterTests*:SslTests*\
:SchemaMetadataTest.*KeyspaceMetadata:SchemaMetadataTest.*MetadataIterator:SchemaMetadataTest.*View*\
:SchemaMetadataTest.*\
:TracingTests.*\
:ByNameTests.*\
:CompressionTests.*\
Expand All @@ -89,6 +93,8 @@ CASSANDRA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
:ExecutionProfileTest.Integration_Cassandra_LatencyAwareRouting\
:-PreparedTests.Integration_Cassandra_PreparedIDUnchangedDuringReprepare\
:PreparedTests.Integration_Cassandra_FailFastWhenPreparedIDChangesDuringReprepare\
:SchemaMetadataTest.Integration_Cassandra_RegularMetadataNotMarkedVirtual\
:SchemaMetadataTest.Integration_Cassandra_VirtualMetadata\
:HeartbeatTests.Integration_Cassandra_HeartbeatFailed\
:ControlConnectionTests.Integration_Cassandra_TopologyChange\
:ControlConnectionTests.Integration_Cassandra_FullOutage\
Expand Down
23 changes: 22 additions & 1 deletion tests/src/integration/integration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Integration::Integration()
, is_keyspace_change_requested_(true)
, is_test_chaotic_(false)
, is_beta_protocol_(Options::is_beta_protocol())
, disable_tablets_(false)
, protocol_version_(CASS_PROTOCOL_VERSION_V4)
, create_keyspace_query_("")
, start_time_(0ull) {
Expand Down Expand Up @@ -267,7 +268,7 @@ std::string Integration::default_replication_strategy() {
replication_strategy_s << "'NetworkTopologyStrategy', 'dc1': " << number_dc1_nodes_ << ", "
<< "'dc2': " << number_dc2_nodes_;
} else {
replication_strategy_s << "'SimpleStrategy', 'replication_factor': ";
replication_strategy_s << "'NetworkTopologyStrategy', 'dc1': ";

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

// Check if scylla supports TABLETS feature. If so, and test
// does not work with tablets (e.g. it uses LWT), disable the tablets
// for test keyspace.
if (disable_tablets_ && scylla_supports_feature("TABLETS")) {
create_keyspace_query_ = create_keyspace_query_ + " AND TABLETS = { 'enabled': false }";
}

// Create the keyspace for the integration test
session_.execute(create_keyspace_query_);
CHECK_FAILURE;
Expand Down Expand Up @@ -474,6 +482,19 @@ std::string Integration::generate_contact_points(const std::string& ip_prefix,
return implode(contact_points, ',');
}

bool Integration::scylla_supports_feature(const std::string& feature) {
if (!Options::is_scylla()) {
return false;
}

Result res = session_.execute("SELECT supported_features FROM system.local WHERE key='local'");
Text supported_features = res.first_row().column_by_name<Text>("supported_features");
if (supported_features.is_null()) {
return false;
}
return supported_features.value().find(feature) != std::string::npos;
}

std::string Integration::format_string(const char* format, ...) const {
// Create a buffer for the formatting of the string
char buffer[FORMAT_BUFFER_SIZE] = { '\0' };
Expand Down
14 changes: 14 additions & 0 deletions tests/src/integration/integration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ class Integration : public testing::Test {
* (DEFAULT: true)
*/
bool is_beta_protocol_;
/** Flag to indicate if tablets should be disabled for Scylla keyspace.
* There are some cases where the test logic will fail for tablets keyspace
* (e.g. when test uses LWT statements).
* (DEFAULT: false)
*/
bool disable_tablets_;
/**
* Workload to apply to the cluster
*/
Expand Down Expand Up @@ -508,6 +514,14 @@ class Integration : public testing::Test {
*/
std::string generate_contact_points(const std::string& ip_prefix, size_t number_of_nodes);

/**
* Check if Scylla supports a specific feature.
*
* @param feature Feature to check if supported by Scylla
* @return True if Scylla supports the feature; false otherwise
*/
bool scylla_supports_feature(const std::string& feature);

/**
* Variable argument string formatter
*
Expand Down
2 changes: 2 additions & 0 deletions tests/src/integration/tests/test_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
class AsyncTests : public Integration {
public:
AsyncTests() { disable_tablets_ = true; }

void SetUp() {
// Call the parent setup function
Integration::SetUp();
Expand Down
7 changes: 6 additions & 1 deletion tests/src/integration/tests/test_basics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
*/
class BasicsTests : public Integration {};

class BasicsNoTabletsTests : public BasicsTests {
public:
BasicsNoTabletsTests() { disable_tablets_ = true; }
};

/**
* Perform inserts and validate the timestamps from the server
*
Expand Down Expand Up @@ -81,7 +86,7 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, Timestamps) {
* @since core:1.0.0
* @expected_result Cassandra values are inserted and counters are validated
*/
CASSANDRA_INTEGRATION_TEST_F(BasicsTests, Counters) {
CASSANDRA_INTEGRATION_TEST_F(BasicsNoTabletsTests, Counters) {
CHECK_FAILURE;

// Create the table and update/upsert queries for the test
Expand Down
6 changes: 5 additions & 1 deletion tests/src/integration/tests/test_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ class BatchSingleNodeClusterTests : public Integration {
*/
class BatchCounterSingleNodeClusterTests : public BatchSingleNodeClusterTests {
public:
BatchCounterSingleNodeClusterTests() { value_cql_data_type_ = "counter"; }
BatchCounterSingleNodeClusterTests() {
value_cql_data_type_ = "counter";
// Counter type is not supported with tablets.
disable_tablets_ = true;
}

/**
* Validate the result for the text data type
Expand Down
28 changes: 16 additions & 12 deletions tests/src/integration/tests/test_consistency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ class ConsistencyThreeNodeClusterTests : public ConsistencyTwoNodeClusterTests {
*/
class SerialConsistencyTests : public Integration {
public:
SerialConsistencyTests() { number_dc1_nodes_ = 1; }
SerialConsistencyTests() {
number_dc1_nodes_ = 1;
// LWTs do not work with tablets.
disable_tablets_ = true;
}

virtual void SetUp() {
// Call the parent setup function
Expand Down Expand Up @@ -240,18 +244,18 @@ CASSANDRA_INTEGRATION_TEST_F(ConsistencyTwoNodeClusterTests, SimpleEachQuorum) {

/**
* Perform multiple inserts and selects using different consistencies against a
* cluster with a single decommissioned node
* cluster with a single stopped node
*
* This test will perform insert and select operations using a simple statement
* while validating the operation were successful or failed against a three
* three node cluster with a decommissioned node.
* three node cluster with a stopped node.
*
* @test_category consistency
* @since core:1.0.0
* @expected_result Successful insert and select using multiple consistencies:
* `ALL`, `ONE`, `TWO`, and `QUORUM`
* Failed insert and select using multiple consistencies:
* `ALL` (after decommission) and `THREE`
* `ALL` (after stopping) and `THREE`
*/
CASSANDRA_INTEGRATION_TEST_F(ConsistencyThreeNodeClusterTests, OneNodeDecommissioned) {
CHECK_FAILURE;
Expand All @@ -262,8 +266,8 @@ CASSANDRA_INTEGRATION_TEST_F(ConsistencyThreeNodeClusterTests, OneNodeDecommissi
session_.execute(insert_);
session_.execute(select_);

// Decommission node two
decommission_node(2);
// Stop node two
stop_node(2);

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

/**
* Perform multiple inserts and selects using different consistencies against a
* cluster with a two decommissioned nodes
* cluster with two stopped nodes
*
* This test will perform insert and select operations using a simple statement
* while validating the operation were successful or failed against a three
* node cluster with two decommissioned nodes.
* node cluster with two stopped nodes.
*
* @test_category consistency
* @since core:1.0.0
* @expected_result Successful insert and select using multiple consistencies:
* `ALL`, and `ONE`
* Failed insert and select using multiple consistencies:
* `ALL` (after decommission), `QUORUM`, `TWO`, and `THREE`
* `ALL` (after stopped), `QUORUM`, `TWO`, and `THREE`
*/
CASSANDRA_INTEGRATION_TEST_F(ConsistencyThreeNodeClusterTests, TwoNodesDecommissioned) {
CHECK_FAILURE;
Expand All @@ -320,9 +324,9 @@ CASSANDRA_INTEGRATION_TEST_F(ConsistencyThreeNodeClusterTests, TwoNodesDecommiss
session_.execute(insert_);
session_.execute(select_);

// Decommission node two and three
decommission_node(2);
decommission_node(3);
// Stop node two and three
stop_node(2);
stop_node(3);

// Perform a check using consistency `ONE` (N=1, RF=3)
insert_.set_consistency(CASS_CONSISTENCY_ONE);
Expand Down
2 changes: 2 additions & 0 deletions tests/src/integration/tests/test_exec_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class ExecutionProfileTest : public Integration {
// We do not implement logging retry policy in cpp-rust-driver
// , logging_retry_policy_(child_retry_policy_)
, skip_base_execution_profile_(false) {
// LWTs do not work with tablets.
disable_tablets_ = true;
replication_factor_ = 2;
number_dc1_nodes_ = 2;
is_beta_protocol_ = false; // Issue with beta protocol v5 and functions on Cassandra v3.10.0+
Expand Down
6 changes: 5 additions & 1 deletion tests/src/integration/tests/test_schema_metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@

class SchemaMetadataTest : public Integration {
public:
SchemaMetadataTest() { is_schema_metadata_ = true; }
SchemaMetadataTest() {
is_schema_metadata_ = true;
// Materialized views do not work with tablets.
disable_tablets_ = true;
}

void SetUp() {
SKIP_IF_CASSANDRA_VERSION_LT(2.2.0);
Expand Down