Skip to content
Closed
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
3 changes: 2 additions & 1 deletion src/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ namespace cass {
template<>
struct IsValidValueType<CassBytes> {
bool operator()(uint16_t type) const {
return type == CASS_VALUE_TYPE_BLOB;
return type == CASS_VALUE_TYPE_BLOB ||
type == CASS_VALUE_TYPE_VARINT;
}
};

Expand Down
56 changes: 53 additions & 3 deletions test/ccm_bridge/include/cql_ccm_bridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <exception>
#include <deque>
#include <string.h>
#include <sstream>

#include <boost/smart_ptr.hpp>
#include <boost/noncopyable.hpp>
Expand All @@ -46,7 +47,7 @@ struct CassVersion {
/**
* Extra portion of version number
*/
char extra[64];
std::string extra;

/**
* Initializing constructor for structure
Expand All @@ -55,8 +56,58 @@ struct CassVersion {
major = 0;
minor = 0;
patch = 0;
memset(extra, '\0', sizeof(extra));
extra = "";
};

/**
* Create the CassVersion from a human readable string
*
* @param version_string String representation to convert
*/
CassVersion(std::string version_string) {
major = 0;
minor = 0;
patch = 0;
extra = "";
from_string(version_string);
};

/**
* Convert the version into a human readable string
*/
std::string to_string() {
std::stringstream version_string;
version_string << major << "." << minor << "." << patch;
if (!extra.empty()) {
version_string << "-" << patch;
}
return version_string.str();
}

/**
* Convert the version from human readable string to structure
*
* @param version_string String representation to convert
*/
void from_string(const std::string &version_string) {
// Clean up the string for tokens
std::string version(version_string);
std::replace(version.begin(), version.end(), '.', ' ');
std::size_t found = version.find("-");
if (found != std::string::npos) {
version.replace(found, 1, " ");
}

// Convert to tokens and assign version parameters
std::istringstream tokens(version);
if (tokens >> major) {
if (tokens >> minor) {
if (tokens >> patch) {
tokens >> extra;
}
}
}
}
};

namespace cql {
Expand All @@ -81,7 +132,6 @@ class cql_ccm_bridge_t : public boost::noncopyable {
void resume(int node);
void kill();
void kill(int node);
void binary(int node, bool enable);
void gossip(int node, bool enable);

void remove();
Expand Down
19 changes: 4 additions & 15 deletions test/ccm_bridge/src/cql_ccm_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,24 +310,21 @@ void cql_ccm_bridge_t::execute_ccm_and_print(const string& ccm_args) {
}

CassVersion cql_ccm_bridge_t::get_cassandra_version() {
//Convert the cassandra_version value into the CassVersion structure
CassVersion version;
sscanf(_cassandra_version.c_str(), "%hu.%hu.%hu-%s", &version.major, &version.minor, &version.patch, version.extra);
CassVersion version(_cassandra_version);
return version;
}


CassVersion cql_ccm_bridge_t::get_cassandra_version(int node) {
//Get the version string from CCM
// Get the version string from CCM
std::string version_string = execute_command(boost::str(boost::format("%1% node%2% version") % CCM_COMMAND % node));
size_t prefix_index = version_string.find("ReleaseVersion: ");
if (prefix_index != std::string::npos) {
version_string.replace(0, 16, "");
}

//Convert the version string into the CassVersion structure
CassVersion version;
sscanf(version_string.c_str(), "%hu.%hu.%hu-%s", &version.major, &version.minor, &version.patch, version.extra);
// Return the version of the node
CassVersion version(_cassandra_version);
return version;
}

Expand Down Expand Up @@ -371,14 +368,6 @@ void cql_ccm_bridge_t::kill(int node) {
execute_ccm_command(boost::str(boost::format("node%1% stop --not-gently") % node));
}

void cql_ccm_bridge_t::binary(int node, bool enable) {
if (enable) {
execute_ccm_command(boost::str(boost::format("node%1% nodetool enablebinary") % node));
} else {
execute_ccm_command(boost::str(boost::format("node%1% nodetool disablebinary") % node));
}
}

void cql_ccm_bridge_t::gossip(int node, bool enable) {
if (enable) {
execute_ccm_command(boost::str(boost::format("node%1% nodetool enablegossip") % node));
Expand Down
18 changes: 13 additions & 5 deletions test/integration_tests/src/test_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,20 @@ struct AsyncTests : public test_utils::SingleSessionTest {
std::vector<CassUuid> ids;
for (size_t i = 0; i < num_concurrent_requests; ++i) {
CassUuid id = test_utils::generate_time_uuid(uuid_gen);
test_utils::CassStatementPtr statement(cass_statement_new_n(insert_query.data(), insert_query.size(), 3));
test_utils::CassStatementPtr statement(cass_statement_new(insert_query.c_str(), 3));

// Determine if bound parameters can be used based on C* version
if (version.major == 1) {
insert_query = str(boost::format("INSERT INTO %s (id, num, str) VALUES(%s, %s, 'row%s')") % table_name % test_utils::Value<CassUuid>::to_string(id) % i % i);
statement = test_utils::CassStatementPtr(cass_statement_new(insert_query.c_str(), 0));
} else {
BOOST_REQUIRE(cass_statement_bind_uuid(statement.get(), 0, id) == CASS_OK);
BOOST_REQUIRE(cass_statement_bind_int32(statement.get(), 1, i) == CASS_OK);
std::string str_value = str(boost::format("row%d") % i);
BOOST_REQUIRE(cass_statement_bind_string(statement.get(), 2, str_value.c_str()) == CASS_OK);
}

cass_statement_set_consistency(statement.get(), CASS_CONSISTENCY_QUORUM);
BOOST_REQUIRE(cass_statement_bind_uuid(statement.get(), 0, id) == CASS_OK);
BOOST_REQUIRE(cass_statement_bind_int32(statement.get(), 1, i) == CASS_OK);
std::string str_value = str(boost::format("row%d") % i);
BOOST_REQUIRE(cass_statement_bind_string_n(statement.get(), 2, str_value.data(), str_value.size()) == CASS_OK);
futures->push_back(test_utils::CassFuturePtr(cass_session_execute(session, statement.get())));
ids.push_back(id);
}
Expand Down
Loading