From ef76ab38ccde781daa181fddbe6dd576a2dceb3e Mon Sep 17 00:00:00 2001 From: jsteemann Date: Fri, 6 Jan 2017 15:29:01 +0100 Subject: [PATCH 1/9] fixed test --- js/common/tests/shell/shell-fs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/common/tests/shell/shell-fs.js b/js/common/tests/shell/shell-fs.js index a65355ab2c..8584b9c85a 100644 --- a/js/common/tests/shell/shell-fs.js +++ b/js/common/tests/shell/shell-fs.js @@ -714,7 +714,7 @@ function FileSystemSuite () { fail(); } catch (err) { - assertEqual(ERRORS.ERROR_FILE_NOT_FOUND.code, err.errorNum); + assertEqual(ERRORS.ERROR_SYS_ERROR.code, err.errorNum); } }, From 173d647a5ed998fe38d0e2008857e9bebd3fc5a4 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Fri, 6 Jan 2017 15:44:46 +0100 Subject: [PATCH 2/9] fixed compile error --- arangod/RestHandler/RestReplicationHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arangod/RestHandler/RestReplicationHandler.cpp b/arangod/RestHandler/RestReplicationHandler.cpp index af1495af12..764b7e4977 100644 --- a/arangod/RestHandler/RestReplicationHandler.cpp +++ b/arangod/RestHandler/RestReplicationHandler.cpp @@ -2670,7 +2670,7 @@ void RestReplicationHandler::handleCommandRestoreDataCoordinator() { } if (res != TRI_ERROR_NO_ERROR) { - THROW_ARANGO_EXCEPTION_Message(res, errorMessage); + THROW_ARANGO_EXCEPTION_MESSAGE(res, errorMsg); } VPackBuilder result; From d5c871564a54558c818ac589f6f270bdc939ece6 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Fri, 6 Jan 2017 16:29:23 +0100 Subject: [PATCH 3/9] force closing collection --- arangod/StorageEngine/MMFilesEngine.cpp | 162 +++++++++++++----------- arangod/StorageEngine/MMFilesEngine.h | 3 +- arangod/VocBase/LogicalCollection.cpp | 3 + 3 files changed, 93 insertions(+), 75 deletions(-) diff --git a/arangod/StorageEngine/MMFilesEngine.cpp b/arangod/StorageEngine/MMFilesEngine.cpp index 4d6b9190c6..570eb070ba 100644 --- a/arangod/StorageEngine/MMFilesEngine.cpp +++ b/arangod/StorageEngine/MMFilesEngine.cpp @@ -24,6 +24,7 @@ #include "MMFilesEngine.h" #include "Basics/FileUtils.h" #include "Basics/MutexLocker.h" +#include "Basics/ReadLocker.h" #include "Basics/StringUtils.h" #include "Basics/VelocyPackHelper.h" #include "Basics/WriteLocker.h" @@ -525,7 +526,10 @@ int MMFilesEngine::dropDatabase(TRI_vocbase_t* vocbase) { // stop compactor thread shutdownDatabase(vocbase); - _collectionPaths.erase(vocbase->id()); + { + WRITE_LOCKER(locker, _pathsLock); + _collectionPaths.erase(vocbase->id()); + } return dropDatabaseDirectory(databaseDirectory(vocbase->id())); } @@ -681,96 +685,98 @@ void MMFilesEngine::dropCollection(TRI_vocbase_t* vocbase, arangodb::LogicalColl RocksDBFeature::dropCollection(vocbase->id(), collection->cid()); // rename collection directory - if (!collection->path().empty()) { - std::string const collectionPath = collection->path(); + if (collection->path().empty()) { + return; + } + + std::string const collectionPath = collection->path(); #ifdef _WIN32 - size_t pos = collectionPath.find_last_of('\\'); + size_t pos = collectionPath.find_last_of('\\'); #else - size_t pos = collectionPath.find_last_of('/'); + size_t pos = collectionPath.find_last_of('/'); #endif - bool invalid = false; + bool invalid = false; - if (pos == std::string::npos || pos + 1 >= collectionPath.size()) { + if (pos == std::string::npos || pos + 1 >= collectionPath.size()) { + invalid = true; + } + + std::string path; + std::string relName; + if (!invalid) { + // extract path part + if (pos > 0) { + path = collectionPath.substr(0, pos); + } + + // extract relative filename + relName = collectionPath.substr(pos + 1); + + if (!StringUtils::isPrefix(relName, "collection-") || + StringUtils::isSuffix(relName, ".tmp")) { invalid = true; } + } - std::string path; - std::string relName; - if (!invalid) { - // extract path part - if (pos > 0) { - path = collectionPath.substr(0, pos); - } + if (invalid) { + LOG(ERR) << "cannot rename dropped collection '" << name + << "': unknown path '" << collection->path() << "'"; + } else { + // prefix the collection name with "deleted-" - // extract relative filename - relName = collectionPath.substr(pos + 1); + std::string const newFilename = + FileUtils::buildFilename(path, "deleted-" + relName.substr(std::string("collection-").size())); - if (!StringUtils::isPrefix(relName, "collection-") || - StringUtils::isSuffix(relName, ".tmp")) { - invalid = true; - } + // check if target directory already exists + if (TRI_IsDirectory(newFilename.c_str())) { + // remove existing target directory + TRI_RemoveDirectory(newFilename.c_str()); } - if (invalid) { - LOG(ERR) << "cannot rename dropped collection '" << name - << "': unknown path '" << collection->path() << "'"; - } else { - // prefix the collection name with "deleted-" + // perform the rename + LOG(TRACE) << "renaming collection directory from '" + << collection->path() << "' to '" << newFilename << "'"; - std::string const newFilename = - FileUtils::buildFilename(path, "deleted-" + relName.substr(std::string("collection-").size())); - - // check if target directory already exists - if (TRI_IsDirectory(newFilename.c_str())) { - // remove existing target directory - TRI_RemoveDirectory(newFilename.c_str()); + std::string systemError; + int res = TRI_RenameFile(collection->path().c_str(), newFilename.c_str(), nullptr, &systemError); + + if (res != TRI_ERROR_NO_ERROR) { + if (!systemError.empty()) { + systemError = ", error details: " + systemError; } + LOG(ERR) << "cannot rename directory of dropped collection '" << name + << "' from '" << collection->path() << "' to '" + << newFilename << "': " << TRI_errno_string(res) << systemError + << ", source exists: " << TRI_IsDirectory(collection->path().c_str()) + << ", dest exists: " << TRI_IsDirectory(newFilename.c_str()) + << ", status: " << collection->statusString(); - // perform the rename - LOG(TRACE) << "renaming collection directory from '" - << collection->path() << "' to '" << newFilename << "'"; + std::vector files = TRI_FilesDirectory(collection->path().c_str()); + LOG(ERR) << "ALL FILES: " << files; + for (auto const& f : files) { + bool isDir = TRI_IsDirectory(f.c_str()); + std::string full = basics::FileUtils::buildFilename(collection->path(), f); + LOG(ERR) << "- found: " << f << ", IS DIR: " << isDir; + if (isDir) { + LOG(ERR) << "- removing dir: " << TRI_RemoveDirectory(full.c_str()); + } else { + LOG(ERR) << "- file: " << full << ", size: " << TRI_SizeFile(full.c_str()); + LOG(ERR) << "- removing file: " << TRI_UnlinkFile(full.c_str()); + } + } + LOG(ERR) << "ALL FILES AGAIN: " << TRI_FilesDirectory(collection->path().c_str()); + + } else { + LOG(DEBUG) << "wiping dropped collection '" << name + << "' from disk"; + + res = TRI_RemoveDirectory(newFilename.c_str()); - std::string systemError; - int res = TRI_RenameFile(collection->path().c_str(), newFilename.c_str(), nullptr, &systemError); - if (res != TRI_ERROR_NO_ERROR) { - if (!systemError.empty()) { - systemError = ", error details: " + systemError; - } - LOG(ERR) << "cannot rename directory of dropped collection '" << name - << "' from '" << collection->path() << "' to '" - << newFilename << "': " << TRI_errno_string(res) << systemError - << ", source exists: " << TRI_IsDirectory(collection->path().c_str()) - << ", dest exists: " << TRI_IsDirectory(newFilename.c_str()) - << ", status: " << collection->statusString(); - - std::vector files = TRI_FilesDirectory(collection->path().c_str()); - LOG(ERR) << "ALL FILES: " << files; - for (auto const& f : files) { - bool isDir = TRI_IsDirectory(f.c_str()); - std::string full = basics::FileUtils::buildFilename(collection->path(), f); - LOG(ERR) << "- found: " << f << ", IS DIR: " << isDir; - if (isDir) { - LOG(ERR) << "- removing dir: " << TRI_RemoveDirectory(full.c_str()); - } else { - LOG(ERR) << "- file: " << full << ", size: " << TRI_SizeFile(full.c_str()); - LOG(ERR) << "- removing file: " << TRI_UnlinkFile(full.c_str()); - } - } - LOG(ERR) << "ALL FILES AGAIN: " << TRI_FilesDirectory(collection->path().c_str()); - - } else { - LOG(DEBUG) << "wiping dropped collection '" << name - << "' from disk"; - - res = TRI_RemoveDirectory(newFilename.c_str()); - - if (res != TRI_ERROR_NO_ERROR) { - LOG(ERR) << "cannot wipe dropped collection '" << name - << "' from disk: " << TRI_errno_string(res); - } + LOG(ERR) << "cannot wipe dropped collection '" << name + << "' from disk: " << TRI_errno_string(res); } } } @@ -1167,6 +1173,8 @@ std::string MMFilesEngine::databaseParametersFilename(TRI_voc_tick_t id) const { } std::string MMFilesEngine::collectionDirectory(TRI_voc_tick_t databaseId, TRI_voc_cid_t id) const { + READ_LOCKER(locker, _pathsLock); + auto it = _collectionPaths.find(databaseId); if (it == _collectionPaths.end()) { @@ -1307,6 +1315,8 @@ std::string MMFilesEngine::createCollectionDirectoryName(std::string const& base } void MMFilesEngine::registerCollectionPath(TRI_voc_tick_t databaseId, TRI_voc_cid_t id, std::string const& path) { + WRITE_LOCKER(locker, _pathsLock); + auto it = _collectionPaths.find(databaseId); if (it == _collectionPaths.end()) { @@ -1316,12 +1326,16 @@ void MMFilesEngine::registerCollectionPath(TRI_voc_tick_t databaseId, TRI_voc_ci } void MMFilesEngine::unregisterCollectionPath(TRI_voc_tick_t databaseId, TRI_voc_cid_t id) { + /* + WRITE_LOCKER(locker, _pathsLock); + auto it = _collectionPaths.find(databaseId); if (it == _collectionPaths.end()) { return; } -// (*it).second.erase(id); + (*it).second.erase(id); + */ } void MMFilesEngine::saveCollectionInfo(TRI_vocbase_t* vocbase, diff --git a/arangod/StorageEngine/MMFilesEngine.h b/arangod/StorageEngine/MMFilesEngine.h index bd258f1e01..74bf3196b8 100644 --- a/arangod/StorageEngine/MMFilesEngine.h +++ b/arangod/StorageEngine/MMFilesEngine.h @@ -339,6 +339,7 @@ class MMFilesEngine final : public StorageEngine { TRI_voc_tick_t _maxTick; std::vector> _deleted; + arangodb::basics::ReadWriteLock mutable _pathsLock; std::unordered_map> _collectionPaths; struct CompactionBlocker { @@ -350,7 +351,7 @@ class MMFilesEngine final : public StorageEngine { }; // lock for compaction blockers - arangodb::basics::ReadWriteLock _compactionBlockersLock; + arangodb::basics::ReadWriteLock mutable _compactionBlockersLock; // cross-database map of compaction blockers, protected by _compactionBlockersLock std::unordered_map> _compactionBlockers; diff --git a/arangod/VocBase/LogicalCollection.cpp b/arangod/VocBase/LogicalCollection.cpp index 8b549533da..ba034bcbc1 100644 --- a/arangod/VocBase/LogicalCollection.cpp +++ b/arangod/VocBase/LogicalCollection.cpp @@ -1038,6 +1038,9 @@ void LogicalCollection::drop() { if (_revisionsCache != nullptr) { _revisionsCache->clear(); } + + // make sure collection has been closed + this->close(); TRI_ASSERT(!ServerState::instance()->isCoordinator()); StorageEngine* engine = EngineSelectorFeature::ENGINE; From a47a9712afb7c3576fa0f43ef0f7b3d7221a426b Mon Sep 17 00:00:00 2001 From: Andreas Streichardt Date: Fri, 6 Jan 2017 16:42:13 +0100 Subject: [PATCH 4/9] Brake internal, authenticated cluster foxx requests again so we don't break the normal usecases --- arangod/RestServer/VocbaseContext.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/arangod/RestServer/VocbaseContext.cpp b/arangod/RestServer/VocbaseContext.cpp index 221cbc1362..a3f0abadaf 100644 --- a/arangod/RestServer/VocbaseContext.cpp +++ b/arangod/RestServer/VocbaseContext.cpp @@ -96,7 +96,6 @@ rest::ResponseCode VocbaseContext::authenticate() { if (username.empty()) { // mop: set user to root so that the foxx stuff // knows about us - _request->setUser("root"); return rest::ResponseCode::OK; } From e9f4bd94c4b625a5aadc82f083d1e4116abf0747 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Fri, 6 Jan 2017 17:13:05 +0100 Subject: [PATCH 5/9] removed diagnostics --- arangod/StorageEngine/MMFilesEngine.cpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/arangod/StorageEngine/MMFilesEngine.cpp b/arangod/StorageEngine/MMFilesEngine.cpp index 570eb070ba..6f73ab7ff9 100644 --- a/arangod/StorageEngine/MMFilesEngine.cpp +++ b/arangod/StorageEngine/MMFilesEngine.cpp @@ -748,26 +748,7 @@ void MMFilesEngine::dropCollection(TRI_vocbase_t* vocbase, arangodb::LogicalColl } LOG(ERR) << "cannot rename directory of dropped collection '" << name << "' from '" << collection->path() << "' to '" - << newFilename << "': " << TRI_errno_string(res) << systemError - << ", source exists: " << TRI_IsDirectory(collection->path().c_str()) - << ", dest exists: " << TRI_IsDirectory(newFilename.c_str()) - << ", status: " << collection->statusString(); - - std::vector files = TRI_FilesDirectory(collection->path().c_str()); - LOG(ERR) << "ALL FILES: " << files; - for (auto const& f : files) { - bool isDir = TRI_IsDirectory(f.c_str()); - std::string full = basics::FileUtils::buildFilename(collection->path(), f); - LOG(ERR) << "- found: " << f << ", IS DIR: " << isDir; - if (isDir) { - LOG(ERR) << "- removing dir: " << TRI_RemoveDirectory(full.c_str()); - } else { - LOG(ERR) << "- file: " << full << ", size: " << TRI_SizeFile(full.c_str()); - LOG(ERR) << "- removing file: " << TRI_UnlinkFile(full.c_str()); - } - } - LOG(ERR) << "ALL FILES AGAIN: " << TRI_FilesDirectory(collection->path().c_str()); - + << newFilename << "': " << TRI_errno_string(res) << systemError; } else { LOG(DEBUG) << "wiping dropped collection '" << name << "' from disk"; From 466f9327010d7efc810dec17f51d5f9c8529e866 Mon Sep 17 00:00:00 2001 From: Andreas Streichardt Date: Fri, 6 Jan 2017 17:18:44 +0100 Subject: [PATCH 6/9] First steps to low level replication debugging --- arangod/Agency/AgencyComm.cpp | 13 +++++++ arangod/Agency/AgencyComm.h | 5 +++ arangod/Cluster/v8-cluster.cpp | 24 +++++++++++++ js/server/modules/@arangodb/cluster.js | 2 ++ .../@arangodb/sync-replication-debug.js | 36 +++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 js/server/modules/@arangodb/sync-replication-debug.js diff --git a/arangod/Agency/AgencyComm.cpp b/arangod/Agency/AgencyComm.cpp index d08901c7a9..6b4234cfd5 100644 --- a/arangod/Agency/AgencyComm.cpp +++ b/arangod/Agency/AgencyComm.cpp @@ -46,12 +46,20 @@ #include "SimpleHttpClient/SimpleHttpResult.h" #include +#ifdef DEBUG_SYNC_REPLICATION +#include +#endif using namespace arangodb; using namespace arangodb::application_features; using namespace arangodb::httpclient; using namespace arangodb::rest; +#ifdef DEBUG_SYNC_REPLICATION +static std::atomic debugUniqId(1); +bool AgencyComm::syncReplDebug = false; +#endif + static void addEmptyVPackObject(std::string const& name, VPackBuilder& builder) { builder.add(VPackValue(name)); @@ -862,6 +870,11 @@ AgencyCommResult AgencyComm::casValue(std::string const& key, } uint64_t AgencyComm::uniqid(uint64_t count, double timeout) { +#ifdef DEBUG_SYNC_REPLICATION + if (AgencyComm::syncReplDebug == true) { + return debugUniqId++; + } +#endif static int const maxTries = 1000000; // this is pretty much forever, but we simply cannot continue at all // if we do not get a unique id from the agency. diff --git a/arangod/Agency/AgencyComm.h b/arangod/Agency/AgencyComm.h index cf9ed17357..bafa184c36 100644 --- a/arangod/Agency/AgencyComm.h +++ b/arangod/Agency/AgencyComm.h @@ -477,6 +477,11 @@ class AgencyComm { static uint64_t const INITIAL_SLEEP_TIME = 5000; static uint64_t const MAX_SLEEP_TIME = 50000; +#ifdef DEBUG_SYNC_REPLICATION + public: + static bool syncReplDebug; +#endif + public: AgencyCommResult sendServerState(double ttl); diff --git a/arangod/Cluster/v8-cluster.cpp b/arangod/Cluster/v8-cluster.cpp index 5d06593a5f..f8fe5d2617 100644 --- a/arangod/Cluster/v8-cluster.cpp +++ b/arangod/Cluster/v8-cluster.cpp @@ -1318,6 +1318,26 @@ static void JS_CoordinatorConfigServerState( TRI_V8_TRY_CATCH_END } +#ifdef DEBUG_SYNC_REPLICATION +//////////////////////////////////////////////////////////////////////////////// +/// @brief set arangoserver state to initialized +//////////////////////////////////////////////////////////////////////////////// + +static void JS_EnableSyncReplicationDebug( + v8::FunctionCallbackInfo const& args) { + TRI_V8_TRY_CATCH_BEGIN(isolate); + v8::HandleScope scope(isolate); + + if (args.Length() != 0) { + TRI_V8_THROW_EXCEPTION_USAGE("enableSyncReplicationDebug()"); + } + + ServerState::instance()->setInitialized(); + AgencyComm::syncReplDebug = true; + TRI_V8_TRY_CATCH_END +} +#endif + //////////////////////////////////////////////////////////////////////////////// /// @brief return whether the cluster is initialized //////////////////////////////////////////////////////////////////////////////// @@ -2227,6 +2247,10 @@ void TRI_InitV8Cluster(v8::Isolate* isolate, v8::Handle context) { JS_DBserverConfigServerState); TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("coordinatorConfig"), JS_CoordinatorConfigServerState); +#ifdef DEBUG_SYNC_REPLICATION + TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("enableSyncReplicationDebug"), + JS_EnableSyncReplicationDebug); +#endif TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("initialized"), JS_InitializedServerState); TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("isCoordinator"), diff --git a/js/server/modules/@arangodb/cluster.js b/js/server/modules/@arangodb/cluster.js index 7529e716e8..45ec7760b5 100644 --- a/js/server/modules/@arangodb/cluster.js +++ b/js/server/modules/@arangodb/cluster.js @@ -316,6 +316,7 @@ function createLocalDatabases (plannedDatabases, currentDatabases, writeLocked) // check which databases need to be created locally for (name in plannedDatabases) { + console.log("NAME", name, plannedDatabases[name]); if (plannedDatabases.hasOwnProperty(name)) { var payload = plannedDatabases[name]; payload.error = false; @@ -373,6 +374,7 @@ function dropLocalDatabases (plannedDatabases, writeLocked) { var localDatabases = getLocalDatabases(); var name; + console.log(localDatabases); // check which databases need to be deleted locally for (name in localDatabases) { diff --git a/js/server/modules/@arangodb/sync-replication-debug.js b/js/server/modules/@arangodb/sync-replication-debug.js new file mode 100644 index 0000000000..a8309d9d4c --- /dev/null +++ b/js/server/modules/@arangodb/sync-replication-debug.js @@ -0,0 +1,36 @@ +/* jshint strict: false */ + +// ////////////////////////////////////////////////////////////////////////////// +// / DISCLAIMER +// / +// / Copyright 2017 ArangoDB GmbH, Cologne, Germany +// / +// / Licensed under the Apache License, Version 2.0 (the "License") +// / you may not use this file except in compliance with the License. +// / You may obtain a copy of the License at +// / +// / http://www.apache.org/licenses/LICENSE-2.0 +// / +// / Unless required by applicable law or agreed to in writing, software +// / distributed under the License is distributed on an "AS IS" BASIS, +// / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// / See the License for the specific language governing permissions and +// / limitations under the License. +// / +// / Copyright holder is triAGENS GmbH, Cologne, Germany +// / +// / @author Andreas Streichardt +// ////////////////////////////////////////////////////////////////////////////// + +exports.setup = function() { + global.ArangoServerState.enableSyncReplicationDebug(); + ArangoServerState.setRole('PRIMARY'); + global.ArangoAgency.set = function() { return true }; + global.ArangoAgency.write = function() { return true }; + global.ArangoAgency.increaseVersion = function() { return true }; + global.ArangoAgency.get = function() { return true }; + global.ArangoAgency.lockRead = function() { return true }; + global.ArangoAgency.lockWrite = function() { return true }; + global.ArangoAgency.unlockRead = function() { return true }; + global.ArangoAgency.unlockWrite = function() { return true }; +} From b447051677f726ea134396dde0e434fd36b60745 Mon Sep 17 00:00:00 2001 From: Andreas Streichardt Date: Fri, 6 Jan 2017 17:24:39 +0100 Subject: [PATCH 7/9] remove console.logs --- js/server/modules/@arangodb/cluster.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/js/server/modules/@arangodb/cluster.js b/js/server/modules/@arangodb/cluster.js index 45ec7760b5..7529e716e8 100644 --- a/js/server/modules/@arangodb/cluster.js +++ b/js/server/modules/@arangodb/cluster.js @@ -316,7 +316,6 @@ function createLocalDatabases (plannedDatabases, currentDatabases, writeLocked) // check which databases need to be created locally for (name in plannedDatabases) { - console.log("NAME", name, plannedDatabases[name]); if (plannedDatabases.hasOwnProperty(name)) { var payload = plannedDatabases[name]; payload.error = false; @@ -374,7 +373,6 @@ function dropLocalDatabases (plannedDatabases, writeLocked) { var localDatabases = getLocalDatabases(); var name; - console.log(localDatabases); // check which databases need to be deleted locally for (name in localDatabases) { From 11eb78c0562d8a8df71d4ad4cb82de4e4d8a40de Mon Sep 17 00:00:00 2001 From: Andreas Streichardt Date: Fri, 6 Jan 2017 17:28:39 +0100 Subject: [PATCH 8/9] jslint --- .../@arangodb/sync-replication-debug.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/js/server/modules/@arangodb/sync-replication-debug.js b/js/server/modules/@arangodb/sync-replication-debug.js index a8309d9d4c..1663f2d0a4 100644 --- a/js/server/modules/@arangodb/sync-replication-debug.js +++ b/js/server/modules/@arangodb/sync-replication-debug.js @@ -1,4 +1,5 @@ /* jshint strict: false */ +/* global ArangoServerState */ // ////////////////////////////////////////////////////////////////////////////// // / DISCLAIMER @@ -25,12 +26,12 @@ exports.setup = function() { global.ArangoServerState.enableSyncReplicationDebug(); ArangoServerState.setRole('PRIMARY'); - global.ArangoAgency.set = function() { return true }; - global.ArangoAgency.write = function() { return true }; - global.ArangoAgency.increaseVersion = function() { return true }; - global.ArangoAgency.get = function() { return true }; - global.ArangoAgency.lockRead = function() { return true }; - global.ArangoAgency.lockWrite = function() { return true }; - global.ArangoAgency.unlockRead = function() { return true }; - global.ArangoAgency.unlockWrite = function() { return true }; -} + global.ArangoAgency.set = function() { return true; }; + global.ArangoAgency.write = function() { return true; }; + global.ArangoAgency.increaseVersion = function() { return true; }; + global.ArangoAgency.get = function() { return true; }; + global.ArangoAgency.lockRead = function() { return true; }; + global.ArangoAgency.lockWrite = function() { return true; }; + global.ArangoAgency.unlockRead = function() { return true; }; + global.ArangoAgency.unlockWrite = function() { return true; }; +}; From 13e3e8e673518bdbb2d47682096923eb340806b4 Mon Sep 17 00:00:00 2001 From: Andreas Streichardt Date: Fri, 6 Jan 2017 17:57:11 +0100 Subject: [PATCH 9/9] more agency request mockery --- .../modules/@arangodb/sync-replication-debug.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/server/modules/@arangodb/sync-replication-debug.js b/js/server/modules/@arangodb/sync-replication-debug.js index 1663f2d0a4..2115678e53 100644 --- a/js/server/modules/@arangodb/sync-replication-debug.js +++ b/js/server/modules/@arangodb/sync-replication-debug.js @@ -29,7 +29,17 @@ exports.setup = function() { global.ArangoAgency.set = function() { return true; }; global.ArangoAgency.write = function() { return true; }; global.ArangoAgency.increaseVersion = function() { return true; }; - global.ArangoAgency.get = function() { return true; }; + global.ArangoAgency.get = function(path) { + let value = {}; + let pathSegments = path.split('/'); + let keyValue = 1; + value.arango = pathSegments.reverse().reduce((v, key) => { + let kv = {}; + kv[key] = v; + return kv; + }, keyValue); + return value; + }; global.ArangoAgency.lockRead = function() { return true; }; global.ArangoAgency.lockWrite = function() { return true; }; global.ArangoAgency.unlockRead = function() { return true; };