Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -411,19 +411,31 @@ endif()
## scylladb
set(BEHH_USING_SCYLLADB false)
set(BEHH_CASSANDRA_HEADER)
set(BEHH_SCYLLA_EXECUTEABLE)
set(BEHH_SCYLLA_CPP_LIB)

if(LINUX)
find_file(BEHH_CASSANDRA_HEADER "cassandra.h")
find_file(BEHH_SCYLLA_EXECUTEABLE "scylla")
find_file(BEHH_CASSANDRA_HEADER "cassandra.h")

if(BEHH_CASSANDRA_HEADER AND BEHH_SCYLLA_EXECUTEABLE)
set(BEHH_USING_SCYLLADB true)
message(NOTICE "-- ${PROJECT_NAME}: adding scylladb since deps found")
endif()
if(WIN32)
find_file(BEHH_SCYLLA_CPP_LIB "scylla-cpp-driver.lib")
else()
message(NOTICE "-- ${PROJECT_NAME}: skipping scylladb deps, system not supported")
find_file(BEHH_SCYLLA_CPP_LIB "libscylla-cpp-driver.so")
endif()

if(BEHH_CASSANDRA_HEADER AND BEHH_SCYLLA_CPP_LIB)
set(BEHH_USING_SCYLLADB true)
message(NOTICE "-- ${PROJECT_NAME}: adding scylladb since deps found")
endif()

if(BEHH_USING_SCYLLADB)
get_filename_component(BEHH_SCYLLA_CPP_LIB_DIR "${BEHH_SCYLLA_CPP_LIB}" DIRECTORY)
get_filename_component(BEHH_CASSANDRA_HEADER_DIR "${BEHH_CASSANDRA_HEADER}" DIRECTORY)

include_directories(${BEHH_SCYLLA_CPP_LIB_DIR})
include_directories(${BEHH_CASSANDRA_HEADER_DIR})

link_directories(BEFORE "${BEHH_SCYLLA_CPP_LIB_DIR}")
link_directories(BEFORE "${BEHH_CASSANDRA_HEADER_DIR}")
endif(BEHH_USING_SCYLLADB)
##
## stb
set(BEHH_USING_STB false)
Expand Down
2 changes: 1 addition & 1 deletion src/iscylladb_core_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void IScyllaDbCoreInterface::_IScyllaDb::print_error(CassFuture* pCassFuture, co

cass_future_error_message(pCassFuture, &message, &messageSize);

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

int32_t IScyllaDbCoreInterface::_IScyllaDb::initialize_constructor(const scylladb_connection_t& connection, const char* extra_info) {
Expand Down
3 changes: 1 addition & 2 deletions tests/test_database_couchbase_rw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ class BasicDbTable : public behh::ICouchbaseCoreInterface {

/////////////////////////////////////////////////////////////////

PRAGMA_MESSAGE("TODO: initialize_table / initialize_bucket")

// equivalent initialize_bucket
void initialize_table_index() {
/* not implemented */
}
Expand Down
13 changes: 7 additions & 6 deletions tests/test_database_scylla_rw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ create table if not exists {KEYSPACE}.{TABLE_NAME} (
auto this_host = host.asString() + ",";
conn.host += this_host;
}
conn.host.resize(conn.host.size() - 1); // remove last , (coma)
std::cout << "conn.host: " << conn.host << "\n";
conn.host.resize(conn.host.size() - 1); // remove last , (coma) // error in msvc, it said

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

IScyllaDb.initialize_constructor(conn);

// // check table gen
// std::cout << "table gen: " << TABLE_GEN_1ST << "\n";

// finally
m_conn = conn;
}
~BasicDbTable() {};

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

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

cleanup();
// note: multiple_datacenters might need to check

cleanup(); // remove existing table
}

void initialize_table() {
Expand Down
87 changes: 42 additions & 45 deletions tests/test_database_scylla_rw.json.debug
Original file line number Diff line number Diff line change
@@ -1,49 +1,46 @@
{
"behh_test_scylladb":
"keyspace": "scope_behh_test",
// 0:undefined 1:SimpleStrategy 2:NetworkTopologyStrategy 3:LocalStrategy 4:EverywhereStrategy
"strategy": 3,
"connection":
{
"keyspace": "behh_test_scylladb",
// 0:undefined 1:SimpleStrategy 2:NetworkTopologyStrategy 3:LocalStrategy 4:EverywhereStrategy
"strategy": 3,
"connection":
{
// 0:undefined 1:AllowAllAuthenticator 2:PasswordAuthenticator 3:com.scylladb.auth.TransitionalAuthenticator
"auth": 2,
"hosts":
[
"127.0.0.1"
],
// CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY
"username": "",
// CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY
"password": ""
},
"factors_configs": // array index is set by strategy
// 0:undefined 1:AllowAllAuthenticator 2:PasswordAuthenticator 3:com.scylladb.auth.TransitionalAuthenticator
"auth": 2,
"hosts":
[
// expected for: undefined
[
""
],
// expected for: SimpleStrategy
[
"'replication_factor': 3"
],
// expected for: NetworkTopologyStrategy
[
"'replication_factor': 1"
],
// expected for: LocalStrategy
[
"'replication_factor': 3"
],
// expected for: EverywhereStrategy
[
"'replication_factor': 3"
]
"127.0.0.1"
],
// if true, factors_configs_extra will be use
// replication factor need to be specific across datacenter/s
"multiple_datacenters": false,
// will ignore if length is 0 & only applied with multiple data center
"factors_configs_extra": "'dc1': 3, 'dc2': 3, 'dc3': 3"
}
}
// CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY
"username": "",
// CHANGE_THIS_IF_REQUIRED_OR_LET_IT_EMPTY
"password": ""
},
"factors_configs": // array index is set by strategy
[
// expected for: undefined
[
""
],
// expected for: SimpleStrategy
[
"'replication_factor': 3"
],
// expected for: NetworkTopologyStrategy
[
"'replication_factor': 1"
],
// expected for: LocalStrategy
[
"'replication_factor': 3"
],
// expected for: EverywhereStrategy
[
"'replication_factor': 3"
]
],
// if true, factors_configs_extra will be use
// replication factor need to be specific across datacenter/s
"multiple_datacenters": false,
// will ignore if length is 0 & only applied with multiple data center
"factors_configs_extra": "'dc1': 3, 'dc2': 3, 'dc3': 3"
}