1
0
Fork 0

Merge branch 'devel' of https://github.com/arangodb/arangodb into devel

This commit is contained in:
Kaveh Vahedipour 2017-01-19 11:33:05 +01:00
commit 86ea92f289
7 changed files with 192 additions and 148 deletions

View File

@ -142,6 +142,13 @@ class Buffer {
initWithNone(); initWithNone();
} }
void resetTo(ValueLength position) {
if (position >= _alloc) {
throw Exception(Exception::IndexOutOfBounds);
}
_pos = position;
}
void clear() { void clear() {
reset(); reset();
if (_buffer != _local) { if (_buffer != _local) {

View File

@ -1,6 +1,8 @@
devel devel
----- -----
* added --replication-factor, --number-of-shards and --wait-for-sync to arangobench
* turn on UTF-8 string validation for VelocyPack values received via VST connections * turn on UTF-8 string validation for VelocyPack values received via VST connections
* fixed issue #2257 * fixed issue #2257

View File

@ -21,6 +21,14 @@ Startup options
- *--collection*: Name of collection to use in test (only relevant for tests - *--collection*: Name of collection to use in test (only relevant for tests
that invoke collections). that invoke collections).
- *--replication-factor*: In case of a cluster, the replication factor of the
created collections.
- *--number-of-shards*: In case of a cluster, the number of shards of the
created collections.
- *--wait-for-sync*: The value of *waitForSync* for created collections.
- *--complexity*: Complexity value for test case (default: 1). Meaning depends - *--complexity*: Complexity value for test case (default: 1). Meaning depends
on test case. on test case.

View File

@ -3593,9 +3593,9 @@ void LogicalCollection::mergeObjectsForUpdate(
std::unordered_map<std::string, VPackSlice> newValues; std::unordered_map<std::string, VPackSlice> newValues;
{ {
VPackObjectIterator it(newValue, false); VPackObjectIterator it(newValue, true);
while (it.valid()) { while (it.valid()) {
std::string key = it.key().copyString(); StringRef key(it.key());
if (!key.empty() && key[0] == '_' && if (!key.empty() && key[0] == '_' &&
(key == StaticStrings::KeyString || key == StaticStrings::IdString || (key == StaticStrings::KeyString || key == StaticStrings::IdString ||
key == StaticStrings::RevString || key == StaticStrings::RevString ||
@ -3609,7 +3609,7 @@ void LogicalCollection::mergeObjectsForUpdate(
} // else do nothing } // else do nothing
} else { } else {
// regular attribute // regular attribute
newValues.emplace(std::move(key), it.value()); newValues.emplace(std::string(key.data(), key.size()), it.value());
} }
it.next(); it.next();
@ -3647,7 +3647,7 @@ void LogicalCollection::mergeObjectsForUpdate(
// add other attributes after the system attributes // add other attributes after the system attributes
{ {
VPackObjectIterator it(oldValue, false); VPackObjectIterator it(oldValue, true);
while (it.valid()) { while (it.valid()) {
std::string key = it.key().copyString(); std::string key = it.key().copyString();
// exclude system attributes in old value now // exclude system attributes in old value now
@ -3690,15 +3690,15 @@ void LogicalCollection::mergeObjectsForUpdate(
} }
// add remaining values that were only in new object // add remaining values that were only in new object
for (auto& it : newValues) { for (auto const& it : newValues) {
auto& s = it.second; VPackSlice const& s = it.second;
if (s.isNone()) { if (s.isNone()) {
continue; continue;
} }
if (!keepNull && s.isNull()) { if (!keepNull && s.isNull()) {
continue; continue;
} }
b.add(std::move(it.first), s); b.add(it.first, s);
} }
b.close(); b.close();

View File

@ -22,9 +22,9 @@
#include "BenchFeature.h" #include "BenchFeature.h"
#include <iostream>
#include <iomanip>
#include <ctime> #include <ctime>
#include <iomanip>
#include <iostream>
#include "ApplicationFeatures/ApplicationServer.h" #include "ApplicationFeatures/ApplicationServer.h"
#include "Basics/StringUtils.h" #include "Basics/StringUtils.h"
@ -54,7 +54,7 @@ BenchFeature* ARANGOBENCH;
#include "Benchmark/test-cases.h" #include "Benchmark/test-cases.h"
BenchFeature::BenchFeature(application_features::ApplicationServer* server, BenchFeature::BenchFeature(application_features::ApplicationServer* server,
int* result) int* result)
: ApplicationFeature(server, "Bench"), : ApplicationFeature(server, "Bench"),
_async(false), _async(false),
_concurreny(1), _concurreny(1),
@ -70,6 +70,9 @@ BenchFeature::BenchFeature(application_features::ApplicationServer* server,
_quiet(false), _quiet(false),
_runs(1), _runs(1),
_junitReportFile(""), _junitReportFile(""),
_replicationFactor(1),
_numberOfShards(1),
_waitForSync(false),
_result(result) { _result(result) {
requiresElevatedPrivileges(false); requiresElevatedPrivileges(false);
setOptional(false); setOptional(false);
@ -99,6 +102,18 @@ void BenchFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
options->addOption("--collection", "collection name to use in tests", options->addOption("--collection", "collection name to use in tests",
new StringParameter(&_collection)); new StringParameter(&_collection));
options->addOption("--replication-factor",
"replication factor of created collections",
new UInt64Parameter(&_replicationFactor));
options->addOption("--number-of-shards",
"number of shards of created collections",
new UInt64Parameter(&_numberOfShards));
options->addOption("--wait-for-sync",
"use waitForSync for created collections",
new BooleanParameter(&_waitForSync));
std::unordered_set<std::string> cases = {"version", std::unordered_set<std::string> cases = {"version",
"document", "document",
"collection", "collection",
@ -132,13 +147,13 @@ void BenchFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
"use a startup delay (necessary only when run in series)", "use a startup delay (necessary only when run in series)",
new BooleanParameter(&_delay)); new BooleanParameter(&_delay));
options->addOption("--junit-report-file", "filename to write junit style report to", options->addOption("--junit-report-file",
"filename to write junit style report to",
new StringParameter(&_junitReportFile)); new StringParameter(&_junitReportFile));
options->addOption(
options->addOption("--runs", "--runs", "run test n times (and calculate statistics based on median)",
"run test n times (and calculate statistics based on median)", new UInt64Parameter(&_runs));
new UInt64Parameter(&_runs));
options->addOption("--progress", "show progress", options->addOption("--progress", "show progress",
new BooleanParameter(&_progress)); new BooleanParameter(&_progress));
@ -164,7 +179,9 @@ void BenchFeature::updateStartCounter() { ++_started; }
int BenchFeature::getStartCounter() { return _started; } int BenchFeature::getStartCounter() { return _started; }
void BenchFeature::start() { void BenchFeature::start() {
ClientFeature* client = application_features::ApplicationServer::getFeature<ClientFeature>("Client"); ClientFeature* client =
application_features::ApplicationServer::getFeature<ClientFeature>(
"Client");
client->setRetries(3); client->setRetries(3);
client->setWarn(true); client->setWarn(true);
@ -181,8 +198,6 @@ void BenchFeature::start() {
FATAL_ERROR_EXIT(); FATAL_ERROR_EXIT();
} }
double const stepSize = (double)_operations / (double)_concurreny; double const stepSize = (double)_operations / (double)_concurreny;
int64_t realStep = (int64_t)stepSize; int64_t realStep = (int64_t)stepSize;
@ -202,18 +217,18 @@ void BenchFeature::start() {
bool ok = true; bool ok = true;
std::vector<BenchRunResult> results; std::vector<BenchRunResult> results;
for (uint64_t j=0;j<_runs;j++) { for (uint64_t j = 0; j < _runs; j++) {
status("starting threads..."); status("starting threads...");
BenchmarkCounter<unsigned long> operationsCounter(0, BenchmarkCounter<unsigned long> operationsCounter(
(unsigned long)_operations); 0, (unsigned long)_operations);
ConditionVariable startCondition; ConditionVariable startCondition;
// start client threads // start client threads
_started = 0; _started = 0;
for (uint64_t i = 0; i < _concurreny; ++i) { for (uint64_t i = 0; i < _concurreny; ++i) {
BenchmarkThread* thread = new BenchmarkThread( BenchmarkThread* thread = new BenchmarkThread(
benchmark.get(), &startCondition, &BenchFeature::updateStartCounter, benchmark.get(), &startCondition, &BenchFeature::updateStartCounter,
static_cast<int>(i), (unsigned long)_batchSize, &operationsCounter, client, _keepAlive, static_cast<int>(i), (unsigned long)_batchSize, &operationsCounter,
_async, _verbose); client, _keepAlive, _async, _verbose);
thread->setOffset((size_t)(i * realStep)); thread->setOffset((size_t)(i * realStep));
thread->start(); thread->start();
threads.push_back(thread); threads.push_back(thread);
@ -272,11 +287,9 @@ void BenchFeature::start() {
} }
results.push_back({ results.push_back({
time, time, operationsCounter.failures(),
operationsCounter.failures(), operationsCounter.incompleteFailures(), requestTime,
operationsCounter.incompleteFailures(), });
requestTime,
});
for (size_t i = 0; i < static_cast<size_t>(_concurreny); ++i) { for (size_t i = 0; i < static_cast<size_t>(_concurreny); ++i) {
delete threads[i]; delete threads[i];
} }
@ -297,7 +310,8 @@ void BenchFeature::start() {
*_result = ret; *_result = ret;
} }
bool BenchFeature::report(ClientFeature* client, std::vector<BenchRunResult> results) { bool BenchFeature::report(ClientFeature* client,
std::vector<BenchRunResult> results) {
std::cout << std::endl; std::cout << std::endl;
std::cout << "Total number of operations: " << _operations std::cout << "Total number of operations: " << _operations
@ -305,17 +319,19 @@ bool BenchFeature::report(ClientFeature* client, std::vector<BenchRunResult> res
<< ", keep alive: " << (_keepAlive ? "yes" : "no") << ", keep alive: " << (_keepAlive ? "yes" : "no")
<< ", async: " << (_async ? "yes" : "no") << ", async: " << (_async ? "yes" : "no")
<< ", batch size: " << _batchSize << ", batch size: " << _batchSize
<< ", replication factor: " << _replicationFactor
<< ", number of shards: " << _numberOfShards
<< ", wait for sync: " << (_waitForSync ? "true" : "false")
<< ", concurrency level (threads): " << _concurreny << std::endl; << ", concurrency level (threads): " << _concurreny << std::endl;
std::cout << "Test case: " << _testCase << ", complexity: " << _complexity std::cout << "Test case: " << _testCase << ", complexity: " << _complexity
<< ", database: '" << client->databaseName() << "', collection: '" << ", database: '" << client->databaseName() << "', collection: '"
<< _collection << "'" << std::endl; << _collection << "'" << std::endl;
std::sort(results.begin(), results.end(), [](BenchRunResult a, BenchRunResult b) { std::sort(results.begin(), results.end(),
return a.time < b.time; [](BenchRunResult a, BenchRunResult b) { return a.time < b.time; });
});
BenchRunResult output {0, 0, 0, 0}; BenchRunResult output{0, 0, 0, 0};
if (_runs > 1) { if (_runs > 1) {
size_t size = results.size(); size_t size = results.size();
std::cout << std::endl; std::cout << std::endl;
@ -329,13 +345,13 @@ bool BenchFeature::report(ClientFeature* client, std::vector<BenchRunResult> res
std::cout << "Printing median result" << std::endl; std::cout << "Printing median result" << std::endl;
std::cout << "=======================" << std::endl; std::cout << "=======================" << std::endl;
size_t mid = (size_t) size / 2; size_t mid = (size_t)size / 2;
if (size % 2 == 0) { if (size % 2 == 0) {
output.update((results[mid - 1].time + results[mid].time) / 2, output.update(
(results[mid - 1].time + results[mid].time) / 2,
(results[mid - 1].failures + results[mid].failures) / 2, (results[mid - 1].failures + results[mid].failures) / 2,
(results[mid - 1].incomplete + results[mid].incomplete) / 2, (results[mid - 1].incomplete + results[mid].incomplete) / 2,
(results[mid - 1].requestTime + results[mid].requestTime) / 2 (results[mid - 1].requestTime + results[mid].requestTime) / 2);
);
} else { } else {
output = results[mid]; output = results[mid];
} }
@ -351,9 +367,10 @@ bool BenchFeature::report(ClientFeature* client, std::vector<BenchRunResult> res
} }
bool BenchFeature::writeJunitReport(BenchRunResult const& result) { bool BenchFeature::writeJunitReport(BenchRunResult const& result) {
std::ofstream outfile (_junitReportFile,std::ofstream::binary); std::ofstream outfile(_junitReportFile, std::ofstream::binary);
if (!outfile.is_open()) { if (!outfile.is_open()) {
std::cerr << "Could not open JUnit Report File: " << _junitReportFile << std::endl; std::cerr << "Could not open JUnit Report File: " << _junitReportFile
<< std::endl;
return false; return false;
} }
@ -362,29 +379,31 @@ bool BenchFeature::writeJunitReport(BenchRunResult const& result) {
std::time_t t = std::time(nullptr); std::time_t t = std::time(nullptr);
std::tm tm = *std::localtime(&t); std::tm tm = *std::localtime(&t);
char date[255]; char date[255];
memset(date, 0, sizeof(date)); memset(date, 0, sizeof(date));
strftime(date, sizeof(date)-1, "%FT%T%z", &tm); strftime(date, sizeof(date) - 1, "%FT%T%z", &tm);
char host[255]; char host[255];
memset(host, 0, sizeof(host)); memset(host, 0, sizeof(host));
gethostname(host, sizeof(host)-1); gethostname(host, sizeof(host) - 1);
std::string hostname(host); std::string hostname(host);
bool ok = false; bool ok = false;
try { try {
outfile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << '\n' outfile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << '\n'
<< "<testsuite name=\"arangobench\" tests=\"1\" skipped=\"0\" failures=\"0\" errors=\"0\" timestamp=\"" << "<testsuite name=\"arangobench\" tests=\"1\" skipped=\"0\" "
<< date << "\" hostname=\"" "failures=\"0\" errors=\"0\" timestamp=\""
<< hostname << "\" time=\"" << std::fixed << result.time << "\">\n" << date << "\" hostname=\"" << hostname << "\" time=\""
<< "<properties/>\n" << std::fixed << result.time << "\">\n"
<< "<testcase name=\"" << testCase() << "\" classname=\"BenchTest\"" << "<properties/>\n"
<< " time=\"" << std::fixed << result.time << "\"/>\n" << "<testcase name=\"" << testCase() << "\" classname=\"BenchTest\""
<< "</testsuite>\n"; << " time=\"" << std::fixed << result.time << "\"/>\n"
<< "</testsuite>\n";
ok = true; ok = true;
} catch(...) { } catch (...) {
std::cerr << "Got an exception writing to junit report file " << _junitReportFile; std::cerr << "Got an exception writing to junit report file "
<< _junitReportFile;
ok = false; ok = false;
} }
outfile.close(); outfile.close();
@ -413,7 +432,8 @@ void BenchFeature::printResult(BenchRunResult const& result) {
<< std::endl; << std::endl;
if (result.failures > 0) { if (result.failures > 0) {
LOG(WARN) << "WARNING: " << result.failures << " arangobench request(s) failed!"; LOG(WARN) << "WARNING: " << result.failures
<< " arangobench request(s) failed!";
} }
if (result.incomplete > 0) { if (result.incomplete > 0) {
LOG(WARN) << "WARNING: " << result.incomplete LOG(WARN) << "WARNING: " << result.incomplete
@ -421,6 +441,4 @@ void BenchFeature::printResult(BenchRunResult const& result) {
} }
} }
void BenchFeature::unprepare() { void BenchFeature::unprepare() { ARANGOBENCH = nullptr; }
ARANGOBENCH = nullptr;
}

View File

@ -54,19 +54,22 @@ class BenchFeature final : public application_features::ApplicationFeature {
public: public:
bool async() const { return _async; } bool async() const { return _async; }
uint64_t const& concurrency() const { return _concurreny; } uint64_t concurrency() const { return _concurreny; }
uint64_t const& operations() const { return _operations; } uint64_t operations() const { return _operations; }
uint64_t const& batchSize() const { return _batchSize; } uint64_t batchSize() const { return _batchSize; }
bool keepAlive() const { return _keepAlive; } bool keepAlive() const { return _keepAlive; }
std::string const& collection() const { return _collection; } std::string const& collection() const { return _collection; }
std::string const& testCase() const { return _testCase; } std::string const& testCase() const { return _testCase; }
uint64_t const& complexity() const { return _complexity; } uint64_t complexity() const { return _complexity; }
bool delay() const { return _delay; } bool delay() const { return _delay; }
bool progress() const { return _progress; } bool progress() const { return _progress; }
bool verbose() const { return _verbose; } bool verbose() const { return _verbose; }
bool quit() const { return _quiet; } bool quit() const { return _quiet; }
uint64_t const& runs() const { return _runs; } uint64_t runs() const { return _runs; }
std::string const& junitReportFile() const { return _junitReportFile; } std::string const& junitReportFile() const { return _junitReportFile; }
uint64_t replicationFactor() const { return _replicationFactor; }
uint64_t numberOfShards() const { return _numberOfShards; }
bool waitForSync() const { return _waitForSync; }
private: private:
void status(std::string const& value); void status(std::string const& value);
@ -89,6 +92,9 @@ class BenchFeature final : public application_features::ApplicationFeature {
bool _quiet; bool _quiet;
uint64_t _runs; uint64_t _runs;
std::string _junitReportFile; std::string _junitReportFile;
uint64_t _replicationFactor;
uint64_t _numberOfShards;
bool _waitForSync;
private: private:
int* _result; int* _result;

View File

@ -49,9 +49,8 @@ struct VersionTest : public BenchmarkOperation {
return _url; return _url;
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
return rest::RequestType::GET; return rest::RequestType::GET;
} }
@ -85,18 +84,19 @@ struct DocumentCrudAppendTest : public BenchmarkOperation {
size_t const mod = globalCounter % 4; size_t const mod = globalCounter % 4;
if (mod == 0) { if (mod == 0) {
return std::string("/_api/document?collection=" + ARANGOBENCH->collection()); return std::string("/_api/document?collection=" +
ARANGOBENCH->collection());
} else { } else {
size_t keyId = (size_t)(globalCounter / 4); size_t keyId = (size_t)(globalCounter / 4);
std::string const key = "testkey" + StringUtils::itoa(keyId); std::string const key = "testkey" + StringUtils::itoa(keyId);
return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" + key); return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" +
key);
} }
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4; size_t const mod = globalCounter % 4;
if (mod == 0) { if (mod == 0) {
@ -176,18 +176,19 @@ struct DocumentCrudWriteReadTest : public BenchmarkOperation {
size_t const mod = globalCounter % 2; size_t const mod = globalCounter % 2;
if (mod == 0) { if (mod == 0) {
return std::string("/_api/document?collection=" + ARANGOBENCH->collection()); return std::string("/_api/document?collection=" +
ARANGOBENCH->collection());
} else { } else {
size_t keyId = (size_t)(globalCounter / 2); size_t keyId = (size_t)(globalCounter / 2);
std::string const key = "testkey" + StringUtils::itoa(keyId); std::string const key = "testkey" + StringUtils::itoa(keyId);
return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" + key); return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" +
key);
} }
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
size_t const mod = globalCounter % 2; size_t const mod = globalCounter % 2;
if (mod == 0) { if (mod == 0) {
@ -253,18 +254,19 @@ struct ShapesTest : public BenchmarkOperation {
size_t const mod = globalCounter % 3; size_t const mod = globalCounter % 3;
if (mod == 0) { if (mod == 0) {
return std::string("/_api/document?collection=" + ARANGOBENCH->collection()); return std::string("/_api/document?collection=" +
ARANGOBENCH->collection());
} else { } else {
size_t keyId = (size_t)(globalCounter / 3); size_t keyId = (size_t)(globalCounter / 3);
std::string const key = "testkey" + StringUtils::itoa(keyId); std::string const key = "testkey" + StringUtils::itoa(keyId);
return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" + key); return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" +
key);
} }
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
size_t const mod = globalCounter % 3; size_t const mod = globalCounter % 3;
if (mod == 0) { if (mod == 0) {
@ -339,18 +341,19 @@ struct ShapesAppendTest : public BenchmarkOperation {
size_t const mod = globalCounter % 2; size_t const mod = globalCounter % 2;
if (mod == 0) { if (mod == 0) {
return std::string("/_api/document?collection=" + ARANGOBENCH->collection()); return std::string("/_api/document?collection=" +
ARANGOBENCH->collection());
} else { } else {
size_t keyId = (size_t)(globalCounter / 2); size_t keyId = (size_t)(globalCounter / 2);
std::string const key = "testkey" + StringUtils::itoa(keyId); std::string const key = "testkey" + StringUtils::itoa(keyId);
return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" + key); return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" +
key);
} }
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
size_t const mod = globalCounter % 2; size_t const mod = globalCounter % 2;
if (mod == 0) { if (mod == 0) {
@ -424,7 +427,8 @@ struct RandomShapesTest : public BenchmarkOperation {
size_t const mod = globalCounter % 3; size_t const mod = globalCounter % 3;
if (mod == 0) { if (mod == 0) {
return std::string("/_api/document?collection=") + ARANGOBENCH->collection(); return std::string("/_api/document?collection=") +
ARANGOBENCH->collection();
} else { } else {
size_t keyId = (size_t)(globalCounter / 3); size_t keyId = (size_t)(globalCounter / 3);
std::string const key = "testkey" + StringUtils::itoa(keyId); std::string const key = "testkey" + StringUtils::itoa(keyId);
@ -434,9 +438,8 @@ struct RandomShapesTest : public BenchmarkOperation {
} }
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
size_t const mod = globalCounter % 3; size_t const mod = globalCounter % 3;
if (mod == 0) { if (mod == 0) {
@ -516,18 +519,19 @@ struct DocumentCrudTest : public BenchmarkOperation {
size_t const mod = globalCounter % 5; size_t const mod = globalCounter % 5;
if (mod == 0) { if (mod == 0) {
return std::string("/_api/document?collection=" + ARANGOBENCH->collection()); return std::string("/_api/document?collection=" +
ARANGOBENCH->collection());
} else { } else {
size_t keyId = (size_t)(globalCounter / 5); size_t keyId = (size_t)(globalCounter / 5);
std::string const key = "testkey" + StringUtils::itoa(keyId); std::string const key = "testkey" + StringUtils::itoa(keyId);
return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" + key); return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" +
key);
} }
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
size_t const mod = globalCounter % 5; size_t const mod = globalCounter % 5;
if (mod == 0) { if (mod == 0) {
@ -609,18 +613,19 @@ struct EdgeCrudTest : public BenchmarkOperation {
size_t const mod = globalCounter % 4; size_t const mod = globalCounter % 4;
if (mod == 0) { if (mod == 0) {
return std::string("/_api/document?collection=" + ARANGOBENCH->collection()); return std::string("/_api/document?collection=" +
ARANGOBENCH->collection());
} else { } else {
size_t keyId = (size_t)(globalCounter / 4); size_t keyId = (size_t)(globalCounter / 4);
std::string const key = "testkey" + StringUtils::itoa(keyId); std::string const key = "testkey" + StringUtils::itoa(keyId);
return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" + key); return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" +
key);
} }
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4; size_t const mod = globalCounter % 4;
if (mod == 0) { if (mod == 0) {
@ -721,18 +726,19 @@ struct SkiplistTest : public BenchmarkOperation {
size_t const mod = globalCounter % 4; size_t const mod = globalCounter % 4;
if (mod == 0) { if (mod == 0) {
return std::string("/_api/document?collection=" + ARANGOBENCH->collection()); return std::string("/_api/document?collection=" +
ARANGOBENCH->collection());
} else { } else {
size_t keyId = (size_t)(globalCounter / 4); size_t keyId = (size_t)(globalCounter / 4);
std::string const key = "testkey" + StringUtils::itoa(keyId); std::string const key = "testkey" + StringUtils::itoa(keyId);
return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" + key); return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" +
key);
} }
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4; size_t const mod = globalCounter % 4;
if (mod == 0) { if (mod == 0) {
@ -794,7 +800,8 @@ struct HashTest : public BenchmarkOperation {
bool setUp(SimpleHttpClient* client) override { bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOBENCH->collection()) && return DeleteCollection(client, ARANGOBENCH->collection()) &&
CreateCollection(client, ARANGOBENCH->collection(), 2) && CreateCollection(client, ARANGOBENCH->collection(), 2) &&
CreateIndex(client, ARANGOBENCH->collection(), "hash", "[\"value\"]"); CreateIndex(client, ARANGOBENCH->collection(), "hash",
"[\"value\"]");
} }
void tearDown() override {} void tearDown() override {}
@ -804,18 +811,19 @@ struct HashTest : public BenchmarkOperation {
size_t const mod = globalCounter % 4; size_t const mod = globalCounter % 4;
if (mod == 0) { if (mod == 0) {
return std::string("/_api/document?collection=" + ARANGOBENCH->collection()); return std::string("/_api/document?collection=" +
ARANGOBENCH->collection());
} else { } else {
size_t keyId = (size_t)(globalCounter / 4); size_t keyId = (size_t)(globalCounter / 4);
std::string const key = "testkey" + StringUtils::itoa(keyId); std::string const key = "testkey" + StringUtils::itoa(keyId);
return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" + key); return std::string("/_api/document/" + ARANGOBENCH->collection() + "/" +
key);
} }
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4; size_t const mod = globalCounter % 4;
if (mod == 0) { if (mod == 0) {
@ -871,8 +879,8 @@ struct HashTest : public BenchmarkOperation {
struct DocumentImportTest : public BenchmarkOperation { struct DocumentImportTest : public BenchmarkOperation {
DocumentImportTest() : BenchmarkOperation(), _url(), _buffer(0) { DocumentImportTest() : BenchmarkOperation(), _url(), _buffer(0) {
_url = _url = "/_api/import?collection=" + ARANGOBENCH->collection() +
"/_api/import?collection=" + ARANGOBENCH->collection() + "&type=documents"; "&type=documents";
uint64_t const n = ARANGOBENCH->complexity(); uint64_t const n = ARANGOBENCH->complexity();
@ -902,9 +910,8 @@ struct DocumentImportTest : public BenchmarkOperation {
return _url; return _url;
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
return rest::RequestType::POST; return rest::RequestType::POST;
} }
@ -962,9 +969,8 @@ struct DocumentCreationTest : public BenchmarkOperation {
return _url; return _url;
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
return rest::RequestType::POST; return rest::RequestType::POST;
} }
@ -999,9 +1005,8 @@ struct CollectionCreationTest : public BenchmarkOperation {
return _url; return _url;
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
return rest::RequestType::POST; return rest::RequestType::POST;
} }
@ -1059,9 +1064,8 @@ struct TransactionAqlTest : public BenchmarkOperation {
return std::string("/_api/cursor"); return std::string("/_api/cursor");
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
return rest::RequestType::POST; return rest::RequestType::POST;
} }
@ -1148,9 +1152,8 @@ struct TransactionCountTest : public BenchmarkOperation {
return std::string("/_api/transaction"); return std::string("/_api/transaction");
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
return rest::RequestType::POST; return rest::RequestType::POST;
} }
@ -1203,9 +1206,8 @@ struct TransactionDeadlockTest : public BenchmarkOperation {
return std::string("/_api/transaction"); return std::string("/_api/transaction");
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
return rest::RequestType::POST; return rest::RequestType::POST;
} }
@ -1272,9 +1274,8 @@ struct TransactionMultiTest : public BenchmarkOperation {
return std::string("/_api/transaction"); return std::string("/_api/transaction");
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
return rest::RequestType::POST; return rest::RequestType::POST;
} }
@ -1354,9 +1355,8 @@ struct TransactionMultiCollectionTest : public BenchmarkOperation {
return std::string("/_api/transaction"); return std::string("/_api/transaction");
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
return rest::RequestType::POST; return rest::RequestType::POST;
} }
@ -1427,9 +1427,8 @@ struct AqlInsertTest : public BenchmarkOperation {
return std::string("/_api/cursor"); return std::string("/_api/cursor");
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
return rest::RequestType::POST; return rest::RequestType::POST;
} }
@ -1481,9 +1480,8 @@ struct AqlV8Test : public BenchmarkOperation {
return std::string("/_api/cursor"); return std::string("/_api/cursor");
} }
rest::RequestType type(int const threadNumber, rest::RequestType type(int const threadNumber, size_t const threadCounter,
size_t const threadCounter, size_t const globalCounter) override {
size_t const globalCounter) override {
return rest::RequestType::POST; return rest::RequestType::POST;
} }
@ -1555,11 +1553,16 @@ static bool CreateCollection(SimpleHttpClient* client, std::string const& name,
std::unordered_map<std::string, std::string> headerFields; std::unordered_map<std::string, std::string> headerFields;
SimpleHttpResult* result = nullptr; SimpleHttpResult* result = nullptr;
std::string payload = std::string payload = "{\"name\":\"" + name + "\",\"type\":" +
"{\"name\":\"" + name + "\",\"type\":" + StringUtils::itoa(type) + "}"; StringUtils::itoa(type) + ",\"replicationFactor\":" +
result = StringUtils::itoa(ARANGOBENCH->replicationFactor()) +
client->request(rest::RequestType::POST, "/_api/collection", ",\"numberOfShards\":" +
payload.c_str(), payload.size(), headerFields); StringUtils::itoa(ARANGOBENCH->numberOfShards()) +
",\"waitForSync\":" +
(ARANGOBENCH->waitForSync() ? "true" : "false") + "}";
result = client->request(rest::RequestType::POST, "/_api/collection",
payload.c_str(), payload.size(), headerFields);
bool failed = true; bool failed = true;
@ -1586,9 +1589,9 @@ static bool CreateIndex(SimpleHttpClient* client, std::string const& name,
std::string payload = std::string payload =
"{\"type\":\"" + type + "\",\"fields\":" + fields + ",\"unique\":false}"; "{\"type\":\"" + type + "\",\"fields\":" + fields + ",\"unique\":false}";
result = client->request(rest::RequestType::POST, result =
"/_api/index?collection=" + name, payload.c_str(), client->request(rest::RequestType::POST, "/_api/index?collection=" + name,
payload.size(), headerFields); payload.c_str(), payload.size(), headerFields);
bool failed = true; bool failed = true;