Skip to content

Commit 5169071

Browse files
authored
test: CPP-820: Adding the ability to run against DDAC using CCM (#304)
1 parent 56b7caa commit 5169071

16 files changed

Lines changed: 272 additions & 97 deletions

cpp-driver/gtests/src/integration/integration.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Integration::Integration()
6565
// Determine if the schema keyspaces table should be updated
6666
// TODO: Make cass_version (and dse_version) available for all tests
6767
CCM::CassVersion cass_version = server_version_;
68-
if (Options::is_dse()) {
68+
if (!Options::is_cassandra()) {
6969
cass_version = static_cast<CCM::DseVersion>(cass_version).get_cass_version();
7070
}
7171
if (cass_version >= "3.0.0") {
@@ -145,7 +145,7 @@ void Integration::SetUp() {
145145
// Create and start the CCM cluster (if not already created)
146146
ccm_ = new CCM::Bridge(
147147
server_version_, Options::use_git(), Options::branch_tag(), Options::use_install_dir(),
148-
Options::install_dir(), Options::is_dse(), dse_workload_, Options::cluster_prefix(),
148+
Options::install_dir(), Options::server_type(), dse_workload_, Options::cluster_prefix(),
149149
Options::dse_credentials(), Options::dse_username(), Options::dse_password(),
150150
Options::deployment_type(), Options::authentication_type(), Options::host(),
151151
Options::port(), Options::username(), Options::password(), Options::public_key(),
@@ -319,6 +319,10 @@ void Integration::connect(Cluster cluster) {
319319

320320
// Update the server version if branch_tag was specified
321321
if (Options::use_git() && !Options::branch_tag().empty()) {
322+
if (Options::is_ddac()) {
323+
FAIL() << "Unable to build DDAC from Branch/Tag";
324+
return;
325+
}
322326
if (Options::is_dse()) {
323327
server_version_ = ccm_->get_dse_version();
324328
} else {

cpp-driver/gtests/src/integration/integration.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
#define CHECK_VERSION(version) \
8484
do { \
8585
CCM::CassVersion cass_version = this->server_version_; \
86-
if (Options::is_dse()) { \
86+
if (!Options::is_cassandra()) { \
8787
cass_version = static_cast<CCM::DseVersion>(cass_version).get_cass_version(); \
8888
} \
8989
if (cass_version < #version) { \
@@ -98,7 +98,7 @@
9898

9999
#define CHECK_VALUE_TYPE_VERSION(type) \
100100
CCM::CassVersion cass_version = this->server_version_; \
101-
if (Options::is_dse()) { \
101+
if (!Options::is_cassandra()) { \
102102
cass_version = static_cast<CCM::DseVersion>(cass_version).get_cass_version(); \
103103
} \
104104
if (cass_version < type::supported_server_version()) { \

cpp-driver/gtests/src/integration/options.cpp

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
#include <iostream>
2525

2626
#define DEFAULT_OPTIONS_CASSSANDRA_VERSION CCM::CassVersion("3.11.4")
27-
#define DEFAULT_OPTIONS_DSE_VERSION CCM::DseVersion("6.0.8")
27+
#define DEFAULT_OPTIONS_DSE_VERSION CCM::DseVersion("6.7.5")
28+
#define DEFAULT_OPTIONS_DDAC_VERSION CCM::DseVersion("5.1.17")
2829

2930
// Initialize the defaults for all the options
3031
bool Options::is_initialized_ = false;
3132
bool Options::is_help_ = false;
3233
bool Options::is_keep_clusters_ = false;
3334
bool Options::is_log_tests_ = true;
3435
CCM::CassVersion Options::server_version_ = DEFAULT_OPTIONS_CASSSANDRA_VERSION;
35-
bool Options::is_dse_ = false;
3636
bool Options::use_git_ = false;
3737
std::string Options::branch_tag_;
3838
bool Options::use_install_dir_ = false;
@@ -55,6 +55,7 @@ CCM::DseCredentialsType Options::dse_credentials_type_;
5555
CCM::AuthenticationType Options::authentication_type_;
5656
CCM::DeploymentType Options::deployment_type_;
5757
std::set<TestCategory> Options::categories_;
58+
CCM::ServerType Options::server_type_;
5859

5960
bool Options::initialize(int argc, char* argv[]) {
6061
// Only allow initialization to occur once
@@ -63,6 +64,7 @@ bool Options::initialize(int argc, char* argv[]) {
6364
dse_credentials_type_ = CCM::DseCredentialsType::USERNAME_PASSWORD;
6465
authentication_type_ = CCM::AuthenticationType::USERNAME_PASSWORD;
6566
deployment_type_ = CCM::DeploymentType::LOCAL;
67+
server_type_ = CCM::ServerType::CASSANDRA;
6668

6769
// Check for the help argument first (keeps defaults for help display)
6870
for (int i = 1; i < argc; ++i) {
@@ -77,6 +79,8 @@ bool Options::initialize(int argc, char* argv[]) {
7779
for (int i = 1; i < argc; ++i) {
7880
if (std::string(argv[i]) == "--dse") {
7981
server_version_ = DEFAULT_OPTIONS_DSE_VERSION;
82+
} else if (std::string(argv[i]) == "--ddac") {
83+
server_version_ = DEFAULT_OPTIONS_DDAC_VERSION;
8084
}
8185
}
8286

@@ -107,7 +111,9 @@ bool Options::initialize(int argc, char* argv[]) {
107111
<< std::endl;
108112
}
109113
} else if (key == "--dse") {
110-
is_dse_ = true;
114+
server_type_ = CCM::ServerType::DSE;
115+
} else if (key == "--ddac") {
116+
server_type_ = CCM::ServerType::DDAC;
111117
} else if (key == "--dse-username") {
112118
if (!value.empty()) {
113119
dse_username_ = value;
@@ -129,7 +135,7 @@ bool Options::initialize(int argc, char* argv[]) {
129135
}
130136
}
131137
if (!is_found) {
132-
std::cerr << "Invalid DSE Credentials Type: Using default "
138+
std::cerr << "Invalid DSE/DDAC Credentials Type: Using default "
133139
<< dse_credentials_type_.to_string() << std::endl;
134140
}
135141
} else if (key == "--git") {
@@ -272,7 +278,7 @@ bool Options::initialize(int argc, char* argv[]) {
272278
for (TestCategory::iterator iterator = TestCategory::begin(); iterator != TestCategory::end();
273279
++iterator) {
274280
// Only add the DSE test category if DSE is enabled
275-
if (*iterator != TestCategory::DSE || is_dse_) {
281+
if (*iterator != TestCategory::DSE || is_dse()) {
276282
categories_.insert(*iterator);
277283
} else {
278284
std::cerr << "DSE Category Will be Ignored: DSE is not enabled [--dse]" << std::endl;
@@ -282,11 +288,11 @@ bool Options::initialize(int argc, char* argv[]) {
282288
if (deployment_type_ == CCM::DeploymentType::LOCAL) {
283289
host_ = "127.0.0.1";
284290
}
285-
if (is_dse_ && !use_install_dir_) {
286-
// Determine if the DSE credentials type should be updated
291+
if (!is_cassandra() && !use_install_dir_) {
292+
// Determine if the DSE/DDAC credentials type should be updated
287293
if (dse_credentials_type_ == CCM::DseCredentialsType::USERNAME_PASSWORD) {
288294
if (dse_username_.empty() || dse_password_.empty()) {
289-
std::cerr << "Invalid Username and/or Password: Default to INI_FILE DSE credentials"
295+
std::cerr << "Invalid Username and/or Password: Default to INI_FILE DSE/DDAC credentials"
290296
<< std::endl;
291297
dse_credentials_type_ = CCM::DseCredentialsType::INI_FILE;
292298
}
@@ -309,10 +315,11 @@ void Options::print_help() {
309315
std::cout << std::endl << "CCM Options:" << std::endl;
310316
std::cout << " --version=[VERSION]" << std::endl
311317
<< " "
312-
<< "Cassandra/DSE version to use." << std::endl
318+
<< "Cassandra/DSE/DDAC version to use." << std::endl
313319
<< " Default:" << std::endl
314320
<< " Cassandra Version: " << server_version().to_string() << std::endl
315-
<< " DSE Version: " << DEFAULT_OPTIONS_DSE_VERSION.to_string() << std::endl;
321+
<< " DSE Version: " << DEFAULT_OPTIONS_DSE_VERSION.to_string() << std::endl
322+
<< " DDAC Version: " << DEFAULT_OPTIONS_DDAC_VERSION.to_string() << std::endl;
316323
std::string categories;
317324
for (TestCategory::iterator iterator = TestCategory::begin(); iterator != TestCategory::end();
318325
++iterator) {
@@ -330,16 +337,20 @@ void Options::print_help() {
330337
std::cout << " --dse" << std::endl
331338
<< " "
332339
<< "Indicate server version supplied is DSE." << std::endl;
340+
std::cout << " --ddac" << std::endl
341+
<< " "
342+
<< "Indicate server version supplied is DDAC." << std::endl;
333343
std::cout << " --dse-credentials=(USERNAME_PASSWORD|INI_FILE)" << std::endl
334344
<< " "
335-
<< "DSE credentials to use for download authentication. The default is " << std::endl
345+
<< "DSE/DDAC credentials to use for download authentication. The default is "
346+
<< std::endl
336347
<< " " << dse_credentials().to_string() << "." << std::endl;
337348
std::cout << " --dse-username=[USERNAME]" << std::endl
338349
<< " "
339-
<< "Username to use for DSE download authentication." << std::endl;
350+
<< "Username to use for DSE/DDAC download authentication." << std::endl;
340351
std::cout << " --dse-password=[PASSWORD]" << std::endl
341352
<< " "
342-
<< "Password to use for DSE download authentication." << std::endl;
353+
<< "Password to use for DSE/DDAC download authentication." << std::endl;
343354
std::cout << " --git" << std::endl
344355
<< " "
345356
<< "Indicate Cassandra/DSE server download should be obtained from" << std::endl
@@ -408,18 +419,20 @@ void Options::print_settings() {
408419
if (log_tests()) {
409420
std::cout << " Logging driver messages" << std::endl;
410421
}
411-
if (is_dse()) {
412-
std::cout << " DSE Version: " << CCM::DseVersion(server_version()).to_string() << std::endl;
422+
if (!is_cassandra()) {
423+
std::cout << " " << server_type_.to_string()
424+
<< " Version: " << CCM::DseVersion(server_version()).to_string() << std::endl;
413425
if (!use_install_dir()) {
414426
if (dse_credentials() == CCM::DseCredentialsType::USERNAME_PASSWORD) {
415427
std::cout << " Username: " << dse_username() << std::endl;
416428
std::cout << " Password: " << dse_password() << std::endl;
417429
} else {
418-
std::cout << " Using INI file for DSE download authentication" << std::endl;
430+
std::cout << " Using INI file for DSE/DDAC download authentication" << std::endl;
419431
}
420432
}
421433
} else {
422-
std::cout << " Cassandra Version: " << server_version().to_string() << std::endl;
434+
std::cout << " " << server_type_.to_string() << " Version: " << server_version().to_string()
435+
<< std::endl;
423436
}
424437
if (use_install_dir()) {
425438
std::cout << " Using installation directory [" << install_dir() << "]" << std::endl;
@@ -456,7 +469,13 @@ bool Options::log_tests() { return is_log_tests_; }
456469

457470
CCM::CassVersion Options::server_version() { return server_version_; }
458471

459-
bool Options::is_dse() { return is_dse_; }
472+
CCM::ServerType Options::server_type() { return server_type_; }
473+
474+
bool Options::is_cassandra() { return server_type_ == CCM::ServerType::CASSANDRA; }
475+
476+
bool Options::is_dse() { return server_type_ == CCM::ServerType::DSE; }
477+
478+
bool Options::is_ddac() { return server_type_ == CCM::ServerType::DDAC; }
460479

461480
CCM::DseCredentialsType Options::dse_credentials() {
462481
// Static initialization cannot be guaranteed
@@ -514,7 +533,7 @@ const std::string& Options::private_key() { return private_key_; }
514533

515534
SharedPtr<CCM::Bridge, StdDeleter<CCM::Bridge> > Options::ccm() {
516535
return new CCM::Bridge(Options::server_version(), Options::use_git(), Options::branch_tag(),
517-
Options::use_install_dir(), Options::install_dir(), Options::is_dse(),
536+
Options::use_install_dir(), Options::install_dir(), Options::server_type(),
518537
CCM::Bridge::DEFAULT_DSE_WORKLOAD, Options::cluster_prefix(),
519538
Options::dse_credentials(), Options::dse_username(),
520539
Options::dse_password(), Options::deployment_type(),

cpp-driver/gtests/src/integration/options.hpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,35 @@ class Options {
6767
*/
6868
static bool log_tests();
6969
/**
70-
* Get the server version (Cassandra/DSE) to use
70+
* Get the server version (Cassandra/DSE/DDAC) to use
7171
*
72-
* @return Cassandra/DSE version to use
72+
* @return Cassandra/DSE/DDAC version to use
7373
*/
7474
static CCM::CassVersion server_version();
75+
/**
76+
* Get the server type (Cassandra/DSE/DDAC)
77+
*
78+
* @return Server type
79+
*/
80+
static CCM::ServerType server_type();
81+
/**
82+
* Flag to determine if Cassandra should be used or not
83+
*
84+
* @return True if Cassandra should be used; false otherwise
85+
*/
86+
static bool is_cassandra();
7587
/**
7688
* Flag to determine if DSE should be used or not
7789
*
7890
* @return True if DSE should be used; false otherwise
7991
*/
8092
static bool is_dse();
93+
/**
94+
* Flag to determine if DDAC should be used or not
95+
*
96+
* @return True if DDAC should be used; false otherwise
97+
*/
98+
static bool is_ddac();
8199
/**
82100
* Get the DSE credentials type (username|password/INI file)
83101
*
@@ -240,13 +258,13 @@ class Options {
240258
*/
241259
static bool is_log_tests_;
242260
/**
243-
* Server version to use (Cassandra/DSE)
261+
* Server version to use (Cassandra/DSE/DDAC)
244262
*/
245263
static CCM::CassVersion server_version_;
246264
/**
247-
* Flag to indicate if DSE should be used instead of Cassandra
265+
* Server type to use
248266
*/
249-
static bool is_dse_;
267+
static CCM::ServerType server_type_;
250268
/**
251269
* Flag to determine if Cassandra should be built from ASF git (github if DSE)
252270
*/

cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ test::SimulacronCluster::SimulacronCluster()
6666

6767
// Determine the release version (for priming nodes)
6868
CCM::CassVersion cassandra_version = Options::server_version();
69-
if (Options::is_dse()) {
69+
if (!Options::is_cassandra()) {
7070
CCM::DseVersion dse_version(cassandra_version);
7171
cassandra_version = dse_version.get_cass_version();
7272
if (cassandra_version == "0.0.0") {
@@ -127,7 +127,7 @@ void test::SimulacronCluster::create_cluster(
127127
}
128128

129129
// Add the DSE version (if applicable)
130-
if (Options::is_dse()) {
130+
if (!Options::is_cassandra()) {
131131
paramters << "&dse_version=" << dse_version_;
132132
cluster_name << dse_version_;
133133
} else {

cpp-driver/gtests/src/integration/tests/test_auth.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, BadCredentials) {
200200

201201
// Add the proper logging criteria (based on server version)
202202
CCM::CassVersion cass_version = this->server_version_;
203-
if (Options::is_dse()) {
203+
if (!Options::is_cassandra()) {
204204
cass_version = static_cast<CCM::DseVersion>(cass_version).get_cass_version();
205205
}
206206
if (cass_version >= "3.10") {
@@ -242,7 +242,7 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, AuthenticatorSetErrorNull) {
242242

243243
// Add the proper logging criteria (based on server version)
244244
CCM::CassVersion cass_version = this->server_version_;
245-
if (Options::is_dse()) {
245+
if (!Options::is_cassandra()) {
246246
cass_version = static_cast<CCM::DseVersion>(cass_version).get_cass_version();
247247
}
248248
if (cass_version >= "3.10") {

cpp-driver/gtests/src/integration/tests/test_basics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, NoCompactEnabledConnection) {
334334
CHECK_VERSION(3.0.16);
335335
CHECK_VERSION(3.11.2);
336336
CCM::CassVersion cass_version = server_version_;
337-
if (Options::is_dse()) {
337+
if (!Options::is_cassandra()) {
338338
if (server_version_ >= "6.0.0") {
339339
SKIP_TEST("Unsupported for DataStax Enterprise Version "
340340
<< server_version_.to_string()

cpp-driver/gtests/src/integration/tests/test_exec_profile.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,12 @@ CASSANDRA_INTEGRATION_TEST_F(ExecutionProfileTest, Consistency) {
302302
batch.set_execution_profile("consistency");
303303
result = session_.execute(batch, false);
304304
ASSERT_EQ(CASS_ERROR_SERVER_INVALID_QUERY, result.error_code());
305+
CCM::CassVersion cass_version = server_version_;
306+
if (!Options::is_cassandra()) {
307+
cass_version = static_cast<CCM::DseVersion>(cass_version).get_cass_version();
308+
}
305309
std::string expected_message = "SERIAL is not supported as conditional update commit consistency";
306-
if (server_version_ >= "4.0.0") {
310+
if (cass_version >= "4.0.0") {
307311
expected_message = "You must use conditional updates for serializable writes";
308312
}
309313
ASSERT_TRUE(contains(result.error_message(), expected_message));

cpp-driver/gtests/src/integration/tests/test_session.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ CASSANDRA_INTEGRATION_TEST_F(SessionTest, ExternalHostListener) {
140140
// Restart node 1 (up event)
141141
ccm_->start_node(1);
142142
CCM::CassVersion cass_version = this->server_version_;
143-
if (Options::is_dse()) {
143+
if (!Options::is_cassandra()) {
144144
cass_version = static_cast<CCM::DseVersion>(cass_version).get_cass_version();
145145
}
146146
if (cass_version >= "2.2") {

cpp-driver/gtests/src/integration/tests/test_startup_options.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* Startup options integration tests
2121
*/
22-
class StartupOptionssTests : public Integration {};
22+
class StartupOptionsTests : public Integration {};
2323

2424
/**
2525
* Verify driver name and version are assigned in startup options.
@@ -34,10 +34,10 @@ class StartupOptionssTests : public Integration {};
3434
* @cassandra_version 4.0.0
3535
* @expected_result Driver startup options are validated.
3636
*/
37-
CASSANDRA_INTEGRATION_TEST_F(StartupOptionssTests, DriverOptions) {
37+
CASSANDRA_INTEGRATION_TEST_F(StartupOptionsTests, DriverOptions) {
3838
CHECK_FAILURE;
3939
CHECK_VERSION(4.0.0);
40-
if (Options::is_dse()) {
40+
if (!Options::is_cassandra()) {
4141
SKIP_TEST("Unsupported for DataStax Enterprise Version "
4242
<< server_version_.to_string() << ": 'system_views.clients' is unavailable");
4343
}

0 commit comments

Comments
 (0)