From fa09638f223bce5b12cd2425784bc48c454fe276 Mon Sep 17 00:00:00 2001 From: Bret McGuire Date: Thu, 27 Jul 2023 10:28:17 -0500 Subject: [PATCH] Implement support for single version check across multiple major.minors with checking for patch levels within the matching major.minor only. Also generalized the code (and the messaging) somewhat. --- tests/src/integration/integration.hpp | 39 +++++++++++++++++-- tests/src/integration/tests/test_prepared.cpp | 1 + 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/tests/src/integration/integration.hpp b/tests/src/integration/integration.hpp index 16fa06c9e..825ff4536 100644 --- a/tests/src/integration/integration.hpp +++ b/tests/src/integration/integration.hpp @@ -79,9 +79,13 @@ return; \ } -#define SKIP_TEST_VERSION(server_version_string, version_string) \ - SKIP_TEST("Unsupported for Apache Cassandra Version " \ - << server_version_string << ": Server version " << version_string << "+ is required") +#define SKIP_TEST_MESSAGE(server_version_string, comparison, version_string) \ + "Unsupported for Apache Cassandra Version " << server_version_string << ": Server version is " \ + << comparison << " the specified version " << version_string + +/* Maintain existing behaviour; default message indicates server < specified */ +#define SKIP_TEST_VERSION(server_version_string, version_string) \ + SKIP_TEST(SKIP_TEST_MESSAGE(server_version_string, '<', version_string)) #define CHECK_VERSION(version) \ do { \ @@ -94,6 +98,35 @@ } \ } while (0) +/* CPP-967 Skip test iff server version matches major.minor of specified version but + patch version is >= the specified patch level of the specified version. This + enables the concise expression of a single constraint based on multiple Cassandra + server versions. + + Also note that the sense of the comaprison is inverted from what we get in + CHECK_VERSION. There we want to make sure we have a version greater than what's + specified in the constraint. Here we want to make sure we have something less than + what's specified (since the behaviour under test is fixed in later versions of + Cassandra) */ +#define CHECK_VERSIONS(version_string) \ + do { \ + CCM::CassVersion cass_version = this->server_version_; \ + if (!Options::is_cassandra()) { \ + cass_version = static_cast(cass_version).get_cass_version(); \ + } \ + std::vector versions = Utils::explode(version_string,','); \ + for (unsigned int i = 0; i < versions.size(); i++) { \ + CCM::CassVersion version = CCM::CassVersion(versions[i]); \ + if (cass_version.major_version == version.major_version && \ + cass_version.minor_version == version.minor_version && \ + cass_version.patch_version >= version.patch_version) { \ + SKIP_TEST( \ + SKIP_TEST_MESSAGE( \ + cass_version.to_string(), ">=", version.to_string())) \ + } \ + } \ + } while (0) + #define CHECK_PROTOCOL_VERSION(version) \ do { \ int proto_version = this->protocol_version_; \ diff --git a/tests/src/integration/tests/test_prepared.cpp b/tests/src/integration/tests/test_prepared.cpp index 7351cdf90..ede9ceebe 100644 --- a/tests/src/integration/tests/test_prepared.cpp +++ b/tests/src/integration/tests/test_prepared.cpp @@ -45,6 +45,7 @@ class PreparedTests : public Integration { */ CASSANDRA_INTEGRATION_TEST_F(PreparedTests, FailFastWhenPreparedIDChangesDuringReprepare) { CHECK_FAILURE; + CHECK_VERSIONS("4.0.2,3.11.12,3.0.26"); // Create the table and initial prepared statement session_.execute(format_string(CASSANDRA_KEY_VALUE_QUALIFIED_TABLE_FORMAT, keyspace_name_.c_str(),