Skip to content

Commit 51bf09c

Browse files
Michael Feromikefero
authored andcommitted
test: Correcting test failures
* Updated log messages * Ensured valid Cassandra version is supported for test
1 parent aee5670 commit 51bf09c

4 files changed

Lines changed: 26 additions & 23 deletions

File tree

gtests/src/integration/tests/test_auth.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@
2121
*/
2222
class AuthenticationTests : public Integration {
2323
public:
24-
AuthenticationTests()
25-
: starting_protocol_version_(1) {
26-
// Determine starting protocol version (based on server version used)
27-
if (server_version_ >= "2.2.0") {
28-
// Handle deprecated and removed protocol versions [CASSANDRA-10146]
29-
starting_protocol_version_ = 3;
30-
}
31-
}
32-
3324
void SetUp() {
3425
// Call the parent setup function (override startup and session connection)
3526
is_ccm_start_requested_ = false;
@@ -44,11 +35,6 @@ class AuthenticationTests : public Integration {
4435
}
4536

4637
protected:
47-
/**
48-
* Starting protocol version to use for most tests
49-
*/
50-
int starting_protocol_version_;
51-
5238
/**
5339
* Establish a connection with the given protocol version and credentials
5440
*
@@ -94,7 +80,7 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, ProtocolVersions) {
9480
CHECK_FAILURE;
9581

9682
// Iterate over all known/supported protocol versions
97-
for (int i = starting_protocol_version_;
83+
for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION;
9884
i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; ++i) {
9985
// Establish a connection using the protocol version
10086
Session session = connect_using_credentials(i, "cassandra", "cassandra");
@@ -125,7 +111,7 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, InvalidEmptyCredentials) {
125111

126112
// Iterate over all known/supported protocol versions
127113
logger_.add_critera("Key may not be empty");
128-
for (int i = starting_protocol_version_;
114+
for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION;
129115
i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; ++i) {
130116
/*
131117
* This is a case that could be guarded in the API entry point, or error out
@@ -156,7 +142,7 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, InvalidNullUsernameCredentials
156142

157143
// Iterate over all known/supported protocol versions
158144
logger_.add_critera("Key may not be empty");
159-
for (int i = starting_protocol_version_;
145+
for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION;
160146
i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; ++i) {
161147
/*
162148
* This is a case that could be guarded in the API entry point, or error out
@@ -187,7 +173,7 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, InvalidNullPasswordCredentials
187173

188174
// Iterate over all known/supported protocol versions
189175
logger_.add_critera("and/or password are incorrect");
190-
for (int i = starting_protocol_version_;
176+
for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION;
191177
i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; ++i) {
192178
/*
193179
* This is a case that could be guarded in the API entry point, or error out
@@ -224,7 +210,7 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, BadCredentials) {
224210
}
225211

226212
// Iterate over all known/supported protocol versions
227-
for (int i = starting_protocol_version_;
213+
for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION;
228214
i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; ++i) {
229215
/*
230216
* This is a case that could be guarded in the API entry point, or error out

gtests/src/integration/tests/test_control_connection.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ CASSANDRA_INTEGRATION_TEST_F(ControlConnectionTests,
266266
// but invalid remote address. The specified remote is not routable
267267
// from the specified local.
268268
logger_.add_critera("Unable to establish a control connection to host " \
269-
"1.1.1.1 because of the following error: " \
270-
"Connect error 'operation not permitted'");
269+
"1.1.1.1 because of the following error:");
271270
Cluster cluster = Cluster::build().with_contact_points("1.1.1.1")
272271
.with_local_address("127.0.0.1");
273272
try {
@@ -355,6 +354,7 @@ CASSANDRA_INTEGRATION_TEST_F(ControlConnectionTests, TopologyChange) {
355354

356355
// Bootstrap a second node and ensure all hosts are actively used
357356
unsigned int node_2 = ccm_->bootstrap_node(); // Triggers a `NEW_NODE` event
357+
msleep(3000); //TODO: Remove static sleep and check driver logs for reduced wait
358358
std::set<unsigned short> expected_nodes;
359359
expected_nodes.insert(1);
360360
expected_nodes.insert(node_2);
@@ -614,6 +614,7 @@ CASSANDRA_INTEGRATION_TEST_F(ControlConnectionTests,
614614
// Restart the cluster and wait for the nodes to reconnect
615615
ccm_->start_cluster();
616616
ASSERT_TRUE(wait_for_logger(nodes.size()));
617+
msleep(3000); //TODO: Remove static sleep and check driver logs for reduced wait
617618

618619
// Ensure all nodes are actively used
619620
std::set<unsigned short> expected_nodes;
@@ -743,8 +744,10 @@ CASSANDRA_INTEGRATION_TEST_F(ControlConnectionSingleNodeDataCentersClusterTests,
743744
FAIL() << "Connection was established using invalid data center";
744745
} catch (Session::Exception& se) {
745746
ASSERT_EQ(CASS_ERROR_LIB_NO_HOSTS_AVAILABLE, se.error_code());
746-
ASSERT_STREQ("No hosts available for connection using the current load " \
747-
"balancing policy(s)", se.error_message().c_str());
747+
ASSERT_STREQ("No hosts available for the control connection using the " \
748+
"DC-aware load balancing policy. Check to see if the " \
749+
"configured local datacenter is valid",
750+
se.error_message().c_str());
748751
}
749752
}
750753

gtests/src/integration/tests/test_null_string_params.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class NullStringApiArgsTest : public Integration {
6060
class SchemaNullStringApiArgsTest : public NullStringApiArgsTest {
6161
public:
6262
void SetUp() {
63+
CHECK_VERSION(2.2.0);
6364
NullStringApiArgsTest::SetUp();
6465
populateSchema();
6566
schema_meta_ = session_.schema();
@@ -227,6 +228,7 @@ CASSANDRA_INTEGRATION_TEST_F(NullStringApiArgsTest, PrepareNullQuery) {
227228
* @expected_result Null for each lookup, since no object has a null name.
228229
*/
229230
CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, KeyspaceMetaFunctions) {
231+
CHECK_VERSION(2.2.0);
230232
const CassTableMeta* table_meta =
231233
cass_keyspace_meta_table_by_name(keyspace_meta_.get(), NULL);
232234
EXPECT_EQ(NULL, table_meta);
@@ -271,6 +273,7 @@ CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, KeyspaceMetaFunctions)
271273
* @expected_result Null for each lookup, since no object has a null name.
272274
*/
273275
CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, TableMetaFunctions) {
276+
CHECK_VERSION(2.2.0);
274277
const CassColumnMeta* column_meta =
275278
cass_table_meta_column_by_name(table_meta_.get(), NULL);
276279
EXPECT_EQ(NULL, column_meta);
@@ -331,6 +334,7 @@ CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, MaterializedViewMetaFu
331334
* @expected_result Null for each lookup, since no object has a null name.
332335
*/
333336
CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, FunctionAndAggregateMetaFunctions) {
337+
CHECK_VERSION(2.2.0);
334338
// C* 3.x and later annotate collection columns as frozen.
335339
const CassFunctionMeta* function_meta = (schema_meta_.version().major_version >= 3) ?
336340
cass_keyspace_meta_function_by_name(keyspace_meta_.get(), "avg_final",
@@ -361,6 +365,7 @@ CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, FunctionAndAggregateMe
361365
* @expected_result Error out appropriately for invalid queries, succeed otherwise.
362366
*/
363367
CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, StatementFunctions) {
368+
CHECK_VERSION(2.2.0);
364369
Statement statement(NULL);
365370

366371
statement = cass_statement_new(NULL, 0);
@@ -517,6 +522,7 @@ CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, StatementFunctions) {
517522
* @expected_result Null because no parameter in the statement has a null name.
518523
*/
519524
CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, PreparedFunctions) {
525+
CHECK_VERSION(2.2.0);
520526
Prepared prepared =
521527
session_.prepare(format_string("INSERT INTO %s (key, value) "
522528
"VALUES ('42', :v)", table_name_.c_str()));
@@ -537,6 +543,7 @@ CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, PreparedFunctions) {
537543
* null).
538544
*/
539545
CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, DataTypeFunctions) {
546+
CHECK_VERSION(2.2.0);
540547
CassDataType* udt = cass_data_type_new(CASS_VALUE_TYPE_UDT);
541548
EXPECT_EQ(CASS_OK, cass_data_type_set_type_name(udt, NULL));
542549
EXPECT_EQ(NULL, cass_data_type_sub_data_type_by_name(udt, NULL));
@@ -560,6 +567,7 @@ CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, DataTypeFunctions) {
560567
* @expected_result Success; null strings are added/encoded in collections fine.
561568
*/
562569
CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, CollectionFunctions) {
570+
CHECK_VERSION(2.2.0);
563571
CassCollection* collection = cass_collection_new(CASS_COLLECTION_TYPE_SET, 2);
564572
EXPECT_EQ(CASS_OK, cass_collection_append_string(collection, NULL));
565573
EXPECT_EQ(CASS_OK, cass_collection_append_custom(collection, NULL,
@@ -582,6 +590,7 @@ CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, CollectionFunctions) {
582590
* However, succeed in storing a null value in a udt field.
583591
*/
584592
CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, UserTypeFunctions) {
593+
CHECK_VERSION(2.2.0);
585594
const CassDataType *udt_address =
586595
cass_keyspace_meta_user_type_by_name(keyspace_meta_.get(), "address");
587596
ASSERT_NE(static_cast<CassDataType *>(NULL), udt_address);
@@ -662,6 +671,7 @@ CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, UserTypeFunctions) {
662671
* though it will certainly fail when processing on a node.
663672
*/
664673
CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, MiscellaneousFunctions) {
674+
CHECK_VERSION(2.2.0);
665675
cass::ResultResponse response;
666676
cass::Row r(&response);
667677
CassRow* row = CassRow::to(&r);

gtests/src/integration/tests/test_schema_metadata.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class SchemaMetadataTest : public Integration {
2727
}
2828

2929
void SetUp() {
30+
CHECK_VERSION(2.2.0);
3031
Integration::SetUp();
3132
populateSchema();
3233
schema_meta_ = session_.schema();
@@ -84,6 +85,7 @@ class SchemaMetadataTest : public Integration {
8485
};
8586

8687
CASSANDRA_INTEGRATION_TEST_F(SchemaMetadataTest, Views) {
88+
CHECK_VERSION(3.0.0);
8789
Keyspace keyspace_meta = schema_meta_.keyspace(keyspace_name_);
8890
Table table_meta = keyspace_meta.table(table_name_);
8991

@@ -116,6 +118,7 @@ CASSANDRA_INTEGRATION_TEST_F(SchemaMetadataTest, Views) {
116118
}
117119

118120
CASSANDRA_INTEGRATION_TEST_F(SchemaMetadataTest, DropView) {
121+
CHECK_VERSION(3.0.0);
119122
Table table_meta = schema_meta_.keyspace(keyspace_name_).table(table_name_);
120123

121124
// Verify that the table contains the view
@@ -134,6 +137,7 @@ CASSANDRA_INTEGRATION_TEST_F(SchemaMetadataTest, DropView) {
134137
}
135138

136139
CASSANDRA_INTEGRATION_TEST_F(SchemaMetadataTest, RegularMetadataNotMarkedVirtual) {
140+
CHECK_VERSION(2.2.0);
137141
// Check non-virtual keyspace/table is correctly not set
138142
Keyspace keyspace_meta = schema_meta_.keyspace("system");
139143
ASSERT_TRUE(keyspace_meta);

0 commit comments

Comments
 (0)