Skip to content

Commit 2655098

Browse files
author
Michael Fero
committed
test: Allow beta protocol to be disabled by default
* For gtests use: `--disable-beta-protocol` * For boost tests set environment variable `BETA_PROTOCOL=false` Note: Certain tests may override this setting
1 parent 36811d6 commit 2655098

File tree

6 files changed

+41
-5
lines changed

6 files changed

+41
-5
lines changed

gtests/src/integration/integration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Integration::Integration()
5555
, is_ccm_start_node_individually_(false)
5656
, is_session_requested_(true)
5757
, is_test_chaotic_(false)
58-
, is_beta_protocol_(true)
58+
, is_beta_protocol_(Options::is_beta_protocol())
5959
, protocol_version_(CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION)
6060
, create_keyspace_query_("")
6161
, start_time_(0ull) {

gtests/src/integration/options.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ std::string Options::public_key_ = "public.key";
4848
std::string Options::private_key_ = "private.key";
4949
bool Options::is_verbose_ccm_ = false;
5050
bool Options::is_verbose_integration_ = false;
51+
bool Options::is_beta_protocol_ = true;
5152

5253
// Static initialization is not guaranteed for the following types
5354
CCM::DseCredentialsType Options::dse_credentials_type_;
@@ -181,6 +182,8 @@ bool Options::initialize(int argc, char* argv[]) {
181182
is_verbose_ccm_ = true;
182183
is_verbose_integration_ = true;
183184
}
185+
} else if (key == "--disable-beta-protocol") {
186+
is_beta_protocol_ = false;
184187
}
185188
#ifdef CASS_USE_LIBSSH2
186189
else if (key == "--authentication") {
@@ -355,6 +358,9 @@ void Options::print_help() {
355358
<< std::endl;
356359
std::cout << " --verbose(=ccm,integration)" << std::endl << " "
357360
<< "Enable verbose output for component(s)." << std::endl;
361+
std::cout << " --disable-beta-protocol" << std::endl << " "
362+
<< "Disable beta protocol use by default." << std::endl << " "
363+
<< "NOTE: Individual tests may override this setting." << std::endl;
358364
std::cout << std::endl;
359365
}
360366

@@ -533,6 +539,10 @@ bool Options::is_verbose_integration() {
533539
return is_verbose_integration_;
534540
}
535541

542+
bool Options::is_beta_protocol() {
543+
return is_beta_protocol_;
544+
}
545+
536546
Options::Options() {
537547
}
538548

gtests/src/integration/options.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ class Options {
208208
* otherwise
209209
*/
210210
static bool is_verbose_integration();
211+
/**
212+
* Flag to determine if beta protocol should be enabled or not; should only
213+
* pertain to the default setting.
214+
*
215+
* @return True if beta protocol should be enabled; false otherwise
216+
*/
217+
static bool is_beta_protocol();
211218
/**
212219
* Get a CCM instance based on the options
213220
*
@@ -325,6 +332,13 @@ class Options {
325332
* Flag to determine if verbose integration output should enabled
326333
*/
327334
static bool is_verbose_integration_;
335+
/**
336+
* Flag to determine if beta protocol should be enabled or not; should only
337+
* pertain to the default setting.
338+
*
339+
* NOTE: Individual tests can still override this.
340+
*/
341+
static bool is_beta_protocol_;
328342

329343
/**
330344
* Hidden default constructor

test/ccm_bridge/src/bridge.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
#define CCM_CONFIGURATION_KEY_USE_INSTALL_DIR "use_install_dir"
9393
#define CCM_CONFIGURATION_KEY_INSTALL_DIR "install_dir"
9494
#define CCM_CONFIGURATION_KEY_DEPLOYMENT_TYPE "deployment_type"
95-
#define CCM_CONFIGURATION_VERBOSE "verbose"
95+
#define CCM_CONFIGURATION_KEY_VERBOSE "verbose"
9696
#define CCM_CONFIGURATION_KEY_USE_DSE "use_dse"
9797
#define CCM_CONFIGURATION_KEY_DSE_VERSION "dse_version"
9898
#define CCM_CONFIGURATION_KEY_DSE_CREDENTIALS_TYPE "dse_credentials_type"
@@ -355,14 +355,14 @@ CCM::Bridge::Bridge(const std::string& configuration_file)
355355
} else if (key.compare(CCM_CONFIGURATION_KEY_SSH_PRIVATE_KEY) == 0) {
356356
private_key = value;
357357
#endif
358-
} else if (key.compare(CCM_CONFIGURATION_VERBOSE) == 0) {
358+
} else if (key.compare(CCM_CONFIGURATION_KEY_VERBOSE) == 0) {
359359
//Convert the value
360360
std::stringstream ss(value);
361361
if (!(ss >> std::boolalpha >> is_verbose_).fail()) {
362362
continue;
363363
} else {
364364
LOG_ERROR("Invalid flag \"" << value << "\" for "
365-
<< CCM_CONFIGURATION_VERBOSE << "; defaulting to \""
365+
<< CCM_CONFIGURATION_KEY_VERBOSE << "; defaulting to \""
366366
<< (DEFAULT_IS_VERBOSE ? "true" : "false") << "\"");
367367
is_verbose_ = DEFAULT_IS_VERBOSE;
368368
}

test/integration_tests/src/test_utils.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ MultipleNodesTest::MultipleNodesTest(unsigned int num_nodes_dc1,
246246
cass_cluster_set_max_concurrent_creation(cluster, 8);
247247
if (version.major_version >= 3 && version.minor_version >= 10 &&
248248
protocol_version == CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION) {
249-
cass_cluster_set_use_beta_protocol_version(cluster, cass_true);
249+
cass_cluster_set_use_beta_protocol_version(cluster,
250+
is_beta_protocol() ? cass_true : cass_false);
250251
} else {
251252
cass_cluster_set_protocol_version(cluster, protocol_version);
252253
}
@@ -259,6 +260,16 @@ bool MultipleNodesTest::check_version(const std::string& required) {
259260
return false;
260261
}
261262

263+
bool MultipleNodesTest::is_beta_protocol() {
264+
std::string value;
265+
char* temp = getenv("BETA_PROTOCOL");
266+
if (temp) {
267+
value.assign(temp);
268+
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
269+
}
270+
return !value.empty() && value != "0" && value != "false";
271+
}
272+
262273
MultipleNodesTest::~MultipleNodesTest() {
263274
cass_uuid_gen_free(uuid_gen);
264275
cass_cluster_free(cluster);

test/integration_tests/src/test_utils.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,7 @@ struct MultipleNodesTest {
11961196
bool is_ssl = false);
11971197

11981198
bool check_version(const std::string& required);
1199+
bool is_beta_protocol();
11991200

12001201
virtual ~MultipleNodesTest();
12011202

0 commit comments

Comments
 (0)