Skip to content

Commit c5b1e4e

Browse files
absurdfarceWei Deng
authored andcommitted
CPP-967 PreparedTests.Integration_Cassandra_FailFastWhenPreparedIDChangesDuringReprepare fails with some versions of Cassandra (#549)
1 parent 16ff0e6 commit c5b1e4e

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

tests/src/integration/integration.hpp

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@
7979
return; \
8080
}
8181

82-
#define SKIP_TEST_VERSION(server_version_string, version_string) \
83-
SKIP_TEST("Unsupported for Apache Cassandra Version " \
84-
<< server_version_string << ": Server version " << version_string << "+ is required")
82+
#define SKIP_TEST_MESSAGE(server_version_string, comparison, version_string) \
83+
"Unsupported for Apache Cassandra Version " << server_version_string << ": Server version is " \
84+
<< comparison << " the specified version " << version_string
85+
86+
/* Maintain existing behaviour; default message indicates server < specified */
87+
#define SKIP_TEST_VERSION(server_version_string, version_string) \
88+
SKIP_TEST(SKIP_TEST_MESSAGE(server_version_string, '<', version_string))
8589

8690
#define CHECK_VERSION(version) \
8791
do { \
@@ -94,6 +98,35 @@
9498
} \
9599
} while (0)
96100

101+
/* CPP-967 Skip test iff server version matches major.minor of specified version but
102+
patch version is >= the specified patch level of the specified version. This
103+
enables the concise expression of a single constraint based on multiple Cassandra
104+
server versions.
105+
106+
Also note that the sense of the comaprison is inverted from what we get in
107+
CHECK_VERSION. There we want to make sure we have a version greater than what's
108+
specified in the constraint. Here we want to make sure we have something less than
109+
what's specified (since the behaviour under test is fixed in later versions of
110+
Cassandra) */
111+
#define CHECK_VERSIONS(version_string) \
112+
do { \
113+
CCM::CassVersion cass_version = this->server_version_; \
114+
if (!Options::is_cassandra()) { \
115+
cass_version = static_cast<CCM::DseVersion>(cass_version).get_cass_version(); \
116+
} \
117+
std::vector<std::string> versions = Utils::explode(version_string,','); \
118+
for (unsigned int i = 0; i < versions.size(); i++) { \
119+
CCM::CassVersion version = CCM::CassVersion(versions[i]); \
120+
if (cass_version.major_version == version.major_version && \
121+
cass_version.minor_version == version.minor_version && \
122+
cass_version.patch_version >= version.patch_version) { \
123+
SKIP_TEST( \
124+
SKIP_TEST_MESSAGE( \
125+
cass_version.to_string(), ">=", version.to_string())) \
126+
} \
127+
} \
128+
} while (0)
129+
97130
#define CHECK_PROTOCOL_VERSION(version) \
98131
do { \
99132
int proto_version = this->protocol_version_; \

tests/src/integration/tests/test_prepared.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class PreparedTests : public Integration {
4545
*/
4646
CASSANDRA_INTEGRATION_TEST_F(PreparedTests, FailFastWhenPreparedIDChangesDuringReprepare) {
4747
CHECK_FAILURE;
48+
CHECK_VERSIONS("4.0.2,3.11.12,3.0.26");
4849

4950
// Create the table and initial prepared statement
5051
session_.execute(format_string(CASSANDRA_KEY_VALUE_QUALIFIED_TABLE_FORMAT, keyspace_name_.c_str(),

0 commit comments

Comments
 (0)