Skip to content

Commit 7916cc0

Browse files
authored
Merge pull request #255 from muzarski/control-connection-it
Adjust and enable some `ControlConnection` integration tests
2 parents 1e45b74 + 5baa5d3 commit 7916cc0

File tree

3 files changed

+52
-15
lines changed

3 files changed

+52
-15
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ SCYLLA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
1313
:PreparedTests.*\
1414
:NamedParametersTests.*\
1515
:CassandraTypes/CassandraTypesTests/*.Integration_Cassandra_*\
16+
:ControlConnectionTests.*\
1617
:BatchSingleNodeClusterTests*:BatchCounterSingleNodeClusterTests*:BatchCounterThreeNodeClusterTests*\
1718
:ErrorTests.*\
1819
:SslNoClusterTests*:SslNoSslOnClusterTests*\
@@ -26,6 +27,9 @@ SCYLLA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
2627
:UseKeyspaceCaseSensitiveTests.*\
2728
:-PreparedTests.Integration_Cassandra_PreparedIDUnchangedDuringReprepare\
2829
:HeartbeatTests.Integration_Cassandra_HeartbeatFailed\
30+
:ControlConnectionTests.Integration_Cassandra_TopologyChange\
31+
:ControlConnectionTests.Integration_Cassandra_FullOutage\
32+
:ControlConnectionTests.Integration_Cassandra_TerminatedUsingMultipleIoThreadsWithError\
2933
:ExecutionProfileTest.InvalidName\
3034
:*NoCompactEnabledConnection\
3135
:PreparedMetadataTests.Integration_Cassandra_AlterProperlyUpdatesColumnCount\
@@ -44,6 +48,7 @@ CASSANDRA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
4448
:PreparedTests.*\
4549
:NamedParametersTests.*\
4650
:CassandraTypes/CassandraTypesTests/*.Integration_Cassandra_*\
51+
:ControlConnectionTests.*\
4752
:ErrorTests.*\
4853
:SslClientAuthenticationTests*:SslNoClusterTests*:SslNoSslOnClusterTests*:SslTests*\
4954
:SchemaMetadataTest.*KeyspaceMetadata:SchemaMetadataTest.*MetadataIterator:SchemaMetadataTest.*View*\
@@ -57,6 +62,9 @@ CASSANDRA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
5762
:-PreparedTests.Integration_Cassandra_PreparedIDUnchangedDuringReprepare\
5863
:PreparedTests.Integration_Cassandra_FailFastWhenPreparedIDChangesDuringReprepare\
5964
:HeartbeatTests.Integration_Cassandra_HeartbeatFailed\
65+
:ControlConnectionTests.Integration_Cassandra_TopologyChange\
66+
:ControlConnectionTests.Integration_Cassandra_FullOutage\
67+
:ControlConnectionTests.Integration_Cassandra_TerminatedUsingMultipleIoThreadsWithError\
6068
:SslTests.Integration_Cassandra_ReconnectAfterClusterCrashAndRestart\
6169
:ExecutionProfileTest.InvalidName\
6270
:*NoCompactEnabledConnection\

scylla-rust-wrapper/src/cass_error.rs

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl ToCassError for ExecutionError {
3333
ExecutionError::BadQuery(bad_query) => bad_query.to_cass_error(),
3434
ExecutionError::RequestTimeout(_) => CassError::CASS_ERROR_LIB_REQUEST_TIMED_OUT,
3535
ExecutionError::EmptyPlan => CassError::CASS_ERROR_LIB_INVALID_STATE,
36-
ExecutionError::MetadataError(_) => CassError::CASS_ERROR_LIB_INVALID_STATE,
36+
ExecutionError::MetadataError(e) => e.to_cass_error(),
3737
ExecutionError::ConnectionPoolError(e) => e.to_cass_error(),
3838
ExecutionError::PrepareError(e) => e.to_cass_error(),
3939
ExecutionError::LastAttemptError(e) => e.to_cass_error(),
@@ -47,11 +47,7 @@ impl ToCassError for ExecutionError {
4747

4848
impl ToCassError for ConnectionPoolError {
4949
fn to_cass_error(&self) -> CassError {
50-
// I know that TranslationError (corresponding to CASS_ERROR_LIB_HOST_RESOLUTION)
51-
// is hidden under the ConnectionPoolError.
52-
// However, we still have a lot work to do when it comes to error conversion.
53-
// I will address it, once we start resolving all issues related to error conversion.
54-
CassError::CASS_ERROR_LIB_UNABLE_TO_CONNECT
50+
CassError::CASS_ERROR_LIB_NO_HOSTS_AVAILABLE
5551
}
5652
}
5753

@@ -79,7 +75,7 @@ impl ToCassError for RequestAttemptError {
7975
}
8076
RequestAttemptError::UnableToAllocStreamId => CassError::CASS_ERROR_LIB_NO_STREAMS,
8177
RequestAttemptError::BrokenConnectionError(_) => {
82-
CassError::CASS_ERROR_LIB_UNABLE_TO_CONNECT
78+
CassError::CASS_ERROR_LIB_NO_HOSTS_AVAILABLE
8379
}
8480
RequestAttemptError::BodyExtensionsParseError(_) => {
8581
CassError::CASS_ERROR_LIB_MESSAGE_ENCODE
@@ -164,7 +160,7 @@ impl ToCassError for NewSessionError {
164160
CassError::CASS_ERROR_LIB_NO_HOSTS_AVAILABLE
165161
}
166162
NewSessionError::EmptyKnownNodesList => CassError::CASS_ERROR_LIB_NO_HOSTS_AVAILABLE,
167-
NewSessionError::MetadataError(_) => CassError::CASS_ERROR_LIB_INVALID_STATE,
163+
NewSessionError::MetadataError(e) => e.to_cass_error(),
168164
NewSessionError::UseKeyspaceError(_) => {
169165
CassError::CASS_ERROR_LIB_UNABLE_TO_SET_KEYSPACE
170166
}
@@ -174,6 +170,36 @@ impl ToCassError for NewSessionError {
174170
}
175171
}
176172

173+
impl ToCassError for MetadataError {
174+
fn to_cass_error(&self) -> CassError {
175+
match self {
176+
MetadataError::ConnectionPoolError(e) => e.to_cass_error(),
177+
MetadataError::FetchError(e) => match &e.error {
178+
// Server bug - invalid CQL type in system table.
179+
MetadataFetchErrorKind::InvalidColumnType(_) => {
180+
CassError::CASS_ERROR_LIB_UNEXPECTED_RESPONSE
181+
}
182+
MetadataFetchErrorKind::PrepareError(e) => e.to_cass_error(),
183+
MetadataFetchErrorKind::SerializationError(e) => e.to_cass_error(),
184+
MetadataFetchErrorKind::NextRowError(_) => {
185+
CassError::CASS_ERROR_LIB_UNEXPECTED_RESPONSE
186+
}
187+
188+
// non_exhaustive
189+
_ => CassError::CASS_ERROR_LAST_ENTRY,
190+
},
191+
// Remaining errors indicate a serious server bug - e.g. all peers have empty token lists.
192+
MetadataError::Keyspaces(_)
193+
| MetadataError::Peers(_)
194+
| MetadataError::Tables(_)
195+
| MetadataError::Udts(_) => CassError::CASS_ERROR_LIB_UNEXPECTED_RESPONSE,
196+
197+
// non_exhaustive
198+
_ => CassError::CASS_ERROR_LAST_ENTRY,
199+
}
200+
}
201+
}
202+
177203
impl ToCassError for BadKeyspaceName {
178204
fn to_cass_error(&self) -> CassError {
179205
match self {

tests/src/integration/tests/test_control_connection.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ CASSANDRA_INTEGRATION_TEST_F(ControlConnectionTests, ConnectUsingInvalidIpAddres
132132
CHECK_FAILURE;
133133

134134
// Attempt to connect to the server using an invalid IP address
135-
logger_.add_critera("Unable to establish a control connection to host "
136-
"1.1.1.1 because of the following error: Underlying "
137-
"connection error: Connection timeout");
135+
logger_.add_critera("Could not fetch metadata, error: "
136+
"Control connection pool error: The pool is broken; "
137+
"Last connection failed with: Connect timeout elapsed");
138138
Cluster cluster = Cluster::build().with_contact_points("1.1.1.1");
139139
try {
140140
cluster.connect();
@@ -185,7 +185,7 @@ CASSANDRA_INTEGRATION_TEST_F(ControlConnectionTests, ConnectUsingUnresolvableLoc
185185

186186
// Attempt to connect to the server using an unresolvable local IP address
187187
Cluster cluster = default_cluster();
188-
EXPECT_EQ(CASS_ERROR_LIB_HOST_RESOLUTION,
188+
EXPECT_EQ(CASS_ERROR_LIB_BAD_PARAMS,
189189
cass_cluster_set_local_address(cluster.get(), "unknown.invalid"));
190190
}
191191

@@ -204,7 +204,9 @@ CASSANDRA_INTEGRATION_TEST_F(ControlConnectionTests, ConnectUsingUnbindableLocal
204204
CHECK_FAILURE;
205205

206206
// Attempt to connect to the server using an unbindable local IP address
207-
logger_.add_critera("Unable to bind local address: address not available");
207+
logger_.add_critera("Could not fetch metadata, error: "
208+
"Control connection pool error: The pool is broken; "
209+
"Last connection failed with: Cannot assign requested address");
208210
Cluster cluster = default_cluster().with_local_address("1.1.1.1");
209211
try {
210212
cluster.connect();
@@ -234,8 +236,9 @@ CASSANDRA_INTEGRATION_TEST_F(ControlConnectionTests,
234236
// Attempt to connect to the server using an valid local IP address
235237
// but invalid remote address. The specified remote is not routable
236238
// from the specified local.
237-
logger_.add_critera("Unable to establish a control connection to host "
238-
"1.1.1.1 because of the following error:");
239+
logger_.add_critera("Could not fetch metadata, error: "
240+
"Control connection pool error: The pool is broken; "
241+
"Last connection failed with: Invalid argument");
239242
Cluster cluster = Cluster::build().with_contact_points("1.1.1.1").with_local_address("127.0.0.1");
240243
try {
241244
cluster.connect();

0 commit comments

Comments
 (0)