Skip to content
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

integration: fix SerialConsistencyTests #186

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SCYLLA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
:ConfigTests.*\
:ConsistencyTwoNodeClusterTests.*\
:ConsistencyThreeNodeClusterTests.*\
:SerialConsistencyTests.*\
:PreparedTests.*\
:CassandraTypes/CassandraTypesTests/*.Integration_Cassandra_*\
:BatchSingleNodeClusterTests*:BatchCounterSingleNodeClusterTests*:BatchCounterThreeNodeClusterTests*\
Expand All @@ -32,6 +33,7 @@ CASSANDRA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
:ConfigTests.*\
:ConsistencyTwoNodeClusterTests.*\
:ConsistencyThreeNodeClusterTests.*\
:SerialConsistencyTests.*\
:PreparedTests.*\
:CassandraTypes/CassandraTypesTests/*.Integration_Cassandra_*\
:ErrorTests.*\
Expand Down
16 changes: 14 additions & 2 deletions tests/src/integration/tests/test_consistency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
limitations under the License.
*/

#include "cassandra.h"
#include "integration.hpp"
#include "options.hpp"

Expand Down Expand Up @@ -425,6 +426,17 @@ CASSANDRA_INTEGRATION_TEST_F(SerialConsistencyTests, Simple) {
CASSANDRA_INTEGRATION_TEST_F(SerialConsistencyTests, Invalid) {
CHECK_FAILURE;

Result result = insert_if_not_exists(CASS_CONSISTENCY_ONE); // Invalid serial consistency
EXPECT_EQ(CASS_ERROR_SERVER_INVALID_QUERY, result.error_code());
// Original cpp-driver allows user to SET the invalid serial consistency.
// Then, the request is sent with an invalid serial consistency, resulting in a server error.
// However, rust-driver comes with a type safety in this matter, disallowing
// the user to set invalid serial consistency, thus we are not able to mimic this behaviour in cpp-rust-driver.
// We need to adjust this test, and assert that setting the invalid serial consistency fails with an error.
// Original test case logic:
//// Result result = insert_if_not_exists(CASS_CONSISTENCY_ONE); // Invalid serial consistency
//// EXPECT_EQ(CASS_ERROR_SERVER_INVALID_QUERY, result.error_code());

Statement statement(format_string("INSERT INTO %s (key, value) VALUES (1, 99) IF NOT EXISTS",
table_name_.c_str()));
CassError result = cass_statement_set_serial_consistency(statement.get(), CASS_CONSISTENCY_ONE);
ASSERT_EQ(CASS_ERROR_LIB_BAD_PARAMS, result);
}