Skip to content

Commit fb6141d

Browse files
committed
update:
- scylladb-cpp-driver case: scylladb/cpp-driver#80 - updating test and config for scylladb test - modify preparing to use scylla in main cmake
1 parent 2e719cb commit fb6141d

File tree

5 files changed

+72
-63
lines changed

5 files changed

+72
-63
lines changed

CMakeLists.txt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -411,19 +411,31 @@ endif()
411411
## scylladb
412412
set(BEHH_USING_SCYLLADB false)
413413
set(BEHH_CASSANDRA_HEADER)
414-
set(BEHH_SCYLLA_EXECUTEABLE)
414+
set(BEHH_SCYLLA_CPP_LIB)
415415

416-
if(LINUX)
417-
find_file(BEHH_CASSANDRA_HEADER "cassandra.h")
418-
find_file(BEHH_SCYLLA_EXECUTEABLE "scylla")
416+
find_file(BEHH_CASSANDRA_HEADER "cassandra.h")
419417

420-
if(BEHH_CASSANDRA_HEADER AND BEHH_SCYLLA_EXECUTEABLE)
421-
set(BEHH_USING_SCYLLADB true)
422-
message(NOTICE "-- ${PROJECT_NAME}: adding scylladb since deps found")
423-
endif()
418+
if(WIN32)
419+
find_file(BEHH_SCYLLA_CPP_LIB "scylla-cpp-driver.lib")
424420
else()
425-
message(NOTICE "-- ${PROJECT_NAME}: skipping scylladb deps, system not supported")
421+
find_file(BEHH_SCYLLA_CPP_LIB "libscylla-cpp-driver.so")
422+
endif()
423+
424+
if(BEHH_CASSANDRA_HEADER AND BEHH_SCYLLA_CPP_LIB)
425+
set(BEHH_USING_SCYLLADB true)
426+
message(NOTICE "-- ${PROJECT_NAME}: adding scylladb since deps found")
426427
endif()
428+
429+
if(BEHH_USING_SCYLLADB)
430+
get_filename_component(BEHH_SCYLLA_CPP_LIB_DIR "${BEHH_SCYLLA_CPP_LIB}" DIRECTORY)
431+
get_filename_component(BEHH_CASSANDRA_HEADER_DIR "${BEHH_CASSANDRA_HEADER}" DIRECTORY)
432+
433+
include_directories(${BEHH_SCYLLA_CPP_LIB_DIR})
434+
include_directories(${BEHH_CASSANDRA_HEADER_DIR})
435+
436+
link_directories(BEFORE "${BEHH_SCYLLA_CPP_LIB_DIR}")
437+
link_directories(BEFORE "${BEHH_CASSANDRA_HEADER_DIR}")
438+
endif(BEHH_USING_SCYLLADB)
427439
##
428440
## stb
429441
set(BEHH_USING_STB false)

src/iscylladb_core_interface.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void IScyllaDbCoreInterface::_IScyllaDb::print_error(CassFuture* pCassFuture, co
6565

6666
cass_future_error_message(pCassFuture, &message, &messageSize);
6767

68-
std::fprintf(stderr, "ERROR: \"%s\":\n%.*s\n", info, (int)messageSize, message);
68+
std::fprintf(stderr, "\nERROR: \"%s\":\n%.*s\n", info, (int)messageSize, message);
6969
}
7070

7171
int32_t IScyllaDbCoreInterface::_IScyllaDb::initialize_constructor(const scylladb_connection_t& connection, const char* extra_info) {

tests/test_database_couchbase_rw.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ class BasicDbTable : public behh::ICouchbaseCoreInterface {
8181

8282
/////////////////////////////////////////////////////////////////
8383

84-
PRAGMA_MESSAGE("TODO: initialize_table / initialize_bucket")
85-
84+
// equivalent initialize_bucket
8685
void initialize_table_index() {
8786
/* not implemented */
8887
}

tests/test_database_scylla_rw.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ create table if not exists {KEYSPACE}.{TABLE_NAME} (
6868
auto this_host = host.asString() + ",";
6969
conn.host += this_host;
7070
}
71-
conn.host.resize(conn.host.size() - 1); // remove last , (coma)
71+
std::cout << "conn.host: " << conn.host << "\n";
72+
conn.host.resize(conn.host.size() - 1); // remove last , (coma) // error in msvc, it said
7273

7374
conn.username = CONFIG["connection"]["username"].asString();
7475
conn.password = CONFIG["connection"]["password"].asString();
@@ -83,18 +84,16 @@ create table if not exists {KEYSPACE}.{TABLE_NAME} (
8384

8485
IScyllaDb.initialize_constructor(conn);
8586

86-
// // check table gen
87-
// std::cout << "table gen: " << TABLE_GEN_1ST << "\n";
88-
8987
// finally
9088
m_conn = conn;
9189
}
9290
~BasicDbTable() {};
9391

9492
void initialize() {
9593
// create keyspace if not exists
94+
// - SimpleStrategy: required replication factor
9695
//
97-
std::string query = "create keyspace if not exists {KEYSPACE} with replication = { 'class': '{TOPOLOGY_STRATEGY}' };";
96+
std::string query = "create keyspace if not exists {KEYSPACE} with replication = { 'class': '{TOPOLOGY_STRATEGY}', 'replication_factor': 3 };";
9897

9998
behh::utility_functions::find::and_replace_all(query, "{KEYSPACE}", m_conn.keyspace);
10099
behh::utility_functions::find::and_replace_all(query, "{TOPOLOGY_STRATEGY}", behh::scylladb_topology_strat_to_string(m_conn.strategy));
@@ -111,7 +110,9 @@ create table if not exists {KEYSPACE}.{TABLE_NAME} (
111110
);
112111
}
113112

114-
cleanup();
113+
// note: multiple_datacenters might need to check
114+
115+
cleanup(); // remove existing table
115116
}
116117

117118
void initialize_table() {
Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,46 @@
11
{
2-
"behh_test_scylladb":
2+
"keyspace": "scope_behh_test",
3+
// 0:undefined 1:SimpleStrategy 2:NetworkTopologyStrategy 3:LocalStrategy 4:EverywhereStrategy
4+
"strategy": 3,
5+
"connection":
36
{
4-
"keyspace": "behh_test_scylladb",
5-
// 0:undefined 1:SimpleStrategy 2:NetworkTopologyStrategy 3:LocalStrategy 4:EverywhereStrategy
6-
"strategy": 3,
7-
"connection":
8-
{
9-
// 0:undefined 1:AllowAllAuthenticator 2:PasswordAuthenticator 3:com.scylladb.auth.TransitionalAuthenticator
10-
"auth": 2,
11-
"hosts":
12-
[
13-
"127.0.0.1"
14-
],
15-
// CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY
16-
"username": "",
17-
// CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY
18-
"password": ""
19-
},
20-
"factors_configs": // array index is set by strategy
7+
// 0:undefined 1:AllowAllAuthenticator 2:PasswordAuthenticator 3:com.scylladb.auth.TransitionalAuthenticator
8+
"auth": 2,
9+
"hosts":
2110
[
22-
// expected for: undefined
23-
[
24-
""
25-
],
26-
// expected for: SimpleStrategy
27-
[
28-
"'replication_factor': 3"
29-
],
30-
// expected for: NetworkTopologyStrategy
31-
[
32-
"'replication_factor': 1"
33-
],
34-
// expected for: LocalStrategy
35-
[
36-
"'replication_factor': 3"
37-
],
38-
// expected for: EverywhereStrategy
39-
[
40-
"'replication_factor': 3"
41-
]
11+
"127.0.0.1"
4212
],
43-
// if true, factors_configs_extra will be use
44-
// replication factor need to be specific across datacenter/s
45-
"multiple_datacenters": false,
46-
// will ignore if length is 0 & only applied with multiple data center
47-
"factors_configs_extra": "'dc1': 3, 'dc2': 3, 'dc3': 3"
48-
}
49-
}
13+
// CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY
14+
"username": "",
15+
// CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY
16+
"password": ""
17+
},
18+
"factors_configs": // array index is set by strategy
19+
[
20+
// expected for: undefined
21+
[
22+
""
23+
],
24+
// expected for: SimpleStrategy
25+
[
26+
"'replication_factor': 3"
27+
],
28+
// expected for: NetworkTopologyStrategy
29+
[
30+
"'replication_factor': 1"
31+
],
32+
// expected for: LocalStrategy
33+
[
34+
"'replication_factor': 3"
35+
],
36+
// expected for: EverywhereStrategy
37+
[
38+
"'replication_factor': 3"
39+
]
40+
],
41+
// if true, factors_configs_extra will be use
42+
// replication factor need to be specific across datacenter/s
43+
"multiple_datacenters": false,
44+
// will ignore if length is 0 & only applied with multiple data center
45+
"factors_configs_extra": "'dc1': 3, 'dc2': 3, 'dc3': 3"
46+
}

0 commit comments

Comments
 (0)