Skip to content

Commit 475fcc0

Browse files
author
Michael Fero
committed
test: Adding the ability to use an installed version of Cassandra/DSE
1 parent 8002606 commit 475fcc0

File tree

3 files changed

+87
-23
lines changed

3 files changed

+87
-23
lines changed

test/ccm_bridge/data/config.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
##
2828
#BRANCH_TAG=
2929
##
30+
# Flag to determine if Cassandra/DSE version should be obtained from ASF/GitHub
31+
#
32+
# Uncomment to specify use of installation directory
33+
##
34+
#USE_INSTALL_DIR=false
35+
##
36+
# Cassandra/DSE installation directory to utilize when creating CCM cluster
37+
#
38+
# Uncomment to specify installation directory to use
39+
##
40+
#INSTALL_DIR=/path/to/installation
41+
##
3042
# CCM Deployment Type (local|remote)
3143
#
3244
# Setting to indicate how CCM commands should be run (locally or through SSH)
@@ -52,7 +64,7 @@
5264
#
5365
# Uncomment to specify DSE version
5466
##
55-
#DSE_VERSION=4.8.8
67+
#DSE_VERSION=5.0.2
5668
##
5769
# CCM DSE Credentials Type (username_password|ini_file)
5870
#

test/ccm_bridge/src/bridge.cpp

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ typedef SSIZE_T ssize_t;
113113
#define CCM_CONFIGURATION_KEY_CASSANDRA_VERSION "cassandra_version"
114114
#define CCM_CONFIGURATION_KEY_USE_GIT "use_git"
115115
#define CCM_CONFIGURATION_KEY_BRANCH_TAG "branch_tag"
116+
#define CCM_CONFIGURATION_KEY_USE_INSTALL_DIR "use_install_dir"
117+
#define CCM_CONFIGURATION_KEY_INSTALL_DIR "install_dir"
116118
#define CCM_CONFIGURATION_KEY_DEPLOYMENT_TYPE "deployment_type"
117119
#define CCM_CONFIGURATION_KEY_USE_DSE "use_dse"
118120
#define CCM_CONFIGURATION_KEY_DSE_VERSION "dse_version"
@@ -139,7 +141,7 @@ const std::string DSE_WORKLOADS[] = {
139141
};
140142
const std::vector<std::string> CCM::Bridge::dse_workloads_(DSE_WORKLOADS,
141143
DSE_WORKLOADS + sizeof(DSE_WORKLOADS) / sizeof(DSE_WORKLOADS[0]));
142-
const CCM::DseWorkload DEFAULT_WORKLOAD[] {
144+
const CCM::DseWorkload DEFAULT_WORKLOAD[] = {
143145
CCM::DSE_WORKLOAD_CASSANDRA
144146
};
145147
const std::vector<CCM::DseWorkload> CCM::Bridge::DEFAULT_DSE_WORKLOAD(
@@ -151,6 +153,8 @@ using namespace CCM;
151153
CCM::Bridge::Bridge(CassVersion server_version /*= DEFAULT_CASSANDRA_VERSION*/,
152154
bool use_git /*= DEFAULT_USE_GIT*/,
153155
const std::string& branch_tag /* ""*/,
156+
bool use_install_dir /*=DEFAULT_USE_INSTALL_DIR*/,
157+
const std::string& install_dir /*=""*/,
154158
bool use_dse /*= DEFAULT_USE_DSE*/,
155159
std::vector<DseWorkload> dse_workload /*= DEFAULT_DSE_WORKLOAD*/,
156160
const std::string& cluster_prefix /*= DEFAULT_CLUSTER_PREFIX*/,
@@ -169,6 +173,8 @@ CCM::Bridge::Bridge(CassVersion server_version /*= DEFAULT_CASSANDRA_VERSION*/,
169173
, dse_version_(DEFAULT_DSE_VERSION)
170174
, use_git_(use_git)
171175
, branch_tag_(branch_tag)
176+
, use_install_dir_(use_install_dir)
177+
, install_dir_(install_dir)
172178
, use_dse_(use_dse)
173179
, dse_workload_(dse_workload)
174180
, cluster_prefix_(cluster_prefix)
@@ -198,6 +204,11 @@ CCM::Bridge::Bridge(CassVersion server_version /*= DEFAULT_CASSANDRA_VERSION*/,
198204
dse_version_ = DseVersion(server_version.to_string());
199205
cassandra_version_ = dse_version_.get_cass_version();
200206
}
207+
208+
// Determine if installation directory can be used
209+
if (use_install_dir_ && install_dir_.empty()) {
210+
throw BridgeException("Unable to use Installation Directory: Directory must not be blank");
211+
}
201212
#ifdef CASS_USE_LIBSSH2
202213
// Determine if libssh2 needs to be initialized
203214
if (deployment_type_ == DeploymentType::REMOTE) {
@@ -223,6 +234,7 @@ CCM::Bridge::Bridge(const std::string& configuration_file)
223234
: cassandra_version_(DEFAULT_CASSANDRA_VERSION)
224235
, dse_version_(DEFAULT_DSE_VERSION)
225236
, use_git_(DEFAULT_USE_GIT)
237+
, use_install_dir_(DEFAULT_USE_INSTALL_DIR)
226238
, use_dse_(DEFAULT_USE_DSE)
227239
, dse_workload_(DEFAULT_DSE_WORKLOAD)
228240
, cluster_prefix_(DEFAULT_CLUSTER_PREFIX)
@@ -276,6 +288,17 @@ CCM::Bridge::Bridge(const std::string& configuration_file)
276288
}
277289
} else if (key.compare(CCM_CONFIGURATION_KEY_BRANCH_TAG) == 0) {
278290
branch_tag_ = value;
291+
} else if (key.compare(CCM_CONFIGURATION_KEY_USE_INSTALL_DIR) == 0) {
292+
//Convert the value
293+
std::stringstream valueStream(value);
294+
if (!(valueStream >> std::boolalpha >> use_install_dir_).fail()) {
295+
continue;
296+
} else {
297+
LOG_ERROR("Invalid Flag [" << value << "] for Use Install Directory: Using default [" << DEFAULT_USE_INSTALL_DIR << "]");
298+
use_install_dir_ = DEFAULT_USE_INSTALL_DIR;
299+
}
300+
} else if (key.compare(CCM_CONFIGURATION_KEY_INSTALL_DIR) == 0) {
301+
install_dir_ = value;
279302
} else if (key.compare(CCM_CONFIGURATION_KEY_USE_DSE) == 0) {
280303
//Convert the value
281304
std::stringstream valueStream(value);
@@ -371,6 +394,11 @@ CCM::Bridge::Bridge(const std::string& configuration_file)
371394
cassandra_version_ = dse_version_.get_cass_version();
372395
}
373396

397+
// Determine if installation directory can be used
398+
if (use_install_dir_ && install_dir_.empty()) {
399+
throw BridgeException("Unable to use Installation Directory: Directory must not be blank");
400+
}
401+
374402
// Display the configuration settings being used
375403
LOG("Host: " << host_);
376404
LOG("Cassandra Version: " << cassandra_version_.to_string());
@@ -380,6 +408,9 @@ CCM::Bridge::Bridge(const std::string& configuration_file)
380408
if (use_git_ && !branch_tag_.empty()) {
381409
LOG(" Branch/Tag: " << branch_tag_);
382410
}
411+
if (use_install_dir_ && !install_dir_.empty()) {
412+
LOG(" Installation Directory: " << install_dir_);
413+
}
383414
LOG("Cluster Prefix: " << cluster_prefix_);
384415
LOG("Deployment Type: " << deployment_type_.to_string());
385416
#ifdef CASS_USE_LIBSSH2
@@ -544,31 +575,35 @@ bool CCM::Bridge::create_cluster(std::vector<unsigned short> data_center_nodes,
544575
// Create the cluster create command and execute
545576
std::vector<std::string> create_command;
546577
create_command.push_back("create");
547-
create_command.push_back("-v");
548-
if (use_dse_) {
549-
if (use_git_) {
550-
if (branch_tag_.empty()) {
551-
create_command.push_back("git:" + dse_version_.to_string());
578+
if (use_install_dir_ && !install_dir_.empty()) {
579+
create_command.push_back("--install-dir=" + install_dir_);
580+
} else {
581+
create_command.push_back("-v");
582+
if (use_dse_) {
583+
if (use_git_) {
584+
if (branch_tag_.empty()) {
585+
create_command.push_back("git:" + dse_version_.to_string());
586+
} else {
587+
create_command.push_back("git:" + branch_tag_);
588+
}
552589
} else {
553-
create_command.push_back("git:" + branch_tag_);
590+
create_command.push_back(dse_version_.to_string());
591+
}
592+
create_command.push_back("--dse");
593+
if (dse_credentials_type_ == DseCredentialsType::USERNAME_PASSWORD) {
594+
create_command.push_back("--dse-username=" + dse_username_);
595+
create_command.push_back("--dse-password=" + dse_password_);
554596
}
555597
} else {
556-
create_command.push_back(dse_version_.to_string());
557-
}
558-
create_command.push_back("--dse");
559-
if (dse_credentials_type_ == DseCredentialsType::USERNAME_PASSWORD) {
560-
create_command.push_back("--dse-username=" + dse_username_);
561-
create_command.push_back("--dse-password=" + dse_password_);
562-
}
563-
} else {
564-
if (use_git_) {
565-
if (branch_tag_.empty()) {
566-
create_command.push_back("git:cassandra-" + cassandra_version_.to_string());
598+
if (use_git_) {
599+
if (branch_tag_.empty()) {
600+
create_command.push_back("git:cassandra-" + cassandra_version_.to_string());
601+
} else {
602+
create_command.push_back("git:" + branch_tag_);
603+
}
567604
} else {
568-
create_command.push_back("git:" + branch_tag_);
605+
create_command.push_back(cassandra_version_.to_string());
569606
}
570-
} else {
571-
create_command.push_back(cassandra_version_.to_string());
572607
}
573608
}
574609
create_command.push_back("-b");

test/ccm_bridge/src/bridge.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ typedef struct _LIBSSH2_CHANNEL LIBSSH2_CHANNEL;
4343

4444
// Default values
4545
#define DEFAULT_CASSANDRA_VERSION CassVersion("3.7")
46-
#define DEFAULT_DSE_VERSION DseVersion("4.8.8")
46+
#define DEFAULT_DSE_VERSION DseVersion("5.0.2")
4747
#define DEFAULT_USE_GIT false
48+
#define DEFAULT_USE_INSTALL_DIR false
4849
#define DEFAULT_USE_DSE false
4950
#define DEFAULT_CLUSTER_PREFIX "cpp-driver"
5051
#define DEFAULT_DSE_CREDENTIALS DseCredentialsType::USERNAME_PASSWORD
@@ -149,6 +150,11 @@ namespace CCM {
149150
* @param branch_tag Branch/Tag to use when use_git is enabled
150151
* (default: Empty). This value is independent of the
151152
* version specified.
153+
* @param use_install_dir True if CCM should use a particular installation
154+
* directory; false otherwise
155+
* (default: DEAFAULT_USE_INSTALL_DIR)
156+
* @param install_dir Installation directory to use when use_install_dir is
157+
* enabled (default: Empty)
152158
* @param use_dse True if CCM should load DSE for provided version; false
153159
* otherwise (default: DEFAULT_USE_DSE)
154160
* @param dse_workload DSE workload to utilize
@@ -182,6 +188,8 @@ namespace CCM {
182188
Bridge(CassVersion cassandra_version = DEFAULT_CASSANDRA_VERSION,
183189
bool use_git = DEFAULT_USE_GIT,
184190
const std::string& branch_tag = "",
191+
bool use_install_dir = DEFAULT_USE_INSTALL_DIR,
192+
const std::string& install_dir = "",
185193
bool use_dse = DEFAULT_USE_DSE,
186194
std::vector<DseWorkload> dse_workload = DEFAULT_DSE_WORKLOAD,
187195
const std::string& cluster_prefix = DEFAULT_CLUSTER_PREFIX,
@@ -683,6 +691,15 @@ namespace CCM {
683691
* Branch/Tag to retrieve from ASF/GitHub
684692
*/
685693
std::string branch_tag_;
694+
/**
695+
* Flag to determine if installation directory should be used (passed to
696+
* CCM)
697+
*/
698+
bool use_install_dir_;
699+
/**
700+
* Installation directory to pass to CCM
701+
*/
702+
std::string install_dir_;
686703
/**
687704
* Flag to determine if DSE is being used
688705
*/

0 commit comments

Comments
 (0)