From f445558605fdd26aae32f7d6d459b19d82a749e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Uzarski?= Date: Wed, 9 Oct 2024 09:34:52 +0200 Subject: [PATCH 1/2] integration: fix SerialConsistencyTests 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 the integration test, and assert that setting the invalid serial consistency fails with an error. --- tests/src/integration/tests/test_consistency.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/src/integration/tests/test_consistency.cpp b/tests/src/integration/tests/test_consistency.cpp index 9de1fb62..6a50daf1 100644 --- a/tests/src/integration/tests/test_consistency.cpp +++ b/tests/src/integration/tests/test_consistency.cpp @@ -14,6 +14,7 @@ limitations under the License. */ +#include "cassandra.h" #include "integration.hpp" #include "options.hpp" @@ -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); } From 4c7af17d59730cb4660b6e446f4cb58e40603656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Uzarski?= Date: Wed, 9 Oct 2024 09:36:45 +0200 Subject: [PATCH 2/2] ci: enable SerialConsistencyTests We adjusted the test in the previous commit, so now it should be passing during CI. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 1f700b8a..38df3318 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ SCYLLA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\ :ConfigTests.*\ :ConsistencyTwoNodeClusterTests.*\ :ConsistencyThreeNodeClusterTests.*\ +:SerialConsistencyTests.*\ :PreparedTests.*\ :CassandraTypes/CassandraTypesTests/*.Integration_Cassandra_*\ :BatchSingleNodeClusterTests*:BatchCounterSingleNodeClusterTests*:BatchCounterThreeNodeClusterTests*\ @@ -32,6 +33,7 @@ CASSANDRA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\ :ConfigTests.*\ :ConsistencyTwoNodeClusterTests.*\ :ConsistencyThreeNodeClusterTests.*\ +:SerialConsistencyTests.*\ :PreparedTests.*\ :CassandraTypes/CassandraTypesTests/*.Integration_Cassandra_*\ :ErrorTests.*\