diff --git a/UnitTests/HttpInterface/run-tests-replication b/UnitTests/HttpInterface/run-tests-replication new file mode 100755 index 0000000000..3c45e7c403 --- /dev/null +++ b/UnitTests/HttpInterface/run-tests-replication @@ -0,0 +1,5 @@ +#!/bin/sh +test -d logs || mkdir logs + +rspec --color --format d \ + api-replication-spec.rb diff --git a/UnitTests/Makefile.unittests b/UnitTests/Makefile.unittests index 62da1c52a3..1c233df9c2 100755 --- a/UnitTests/Makefile.unittests +++ b/UnitTests/Makefile.unittests @@ -560,9 +560,9 @@ unittests-import: ### starts two servers (master & slave) and checks for data drift ################################################################################ -.PHONY: unittests-replication unittests-replication-data unittests-replication-logger +.PHONY: unittests-replication unittests-replication-common unittests-replication-http unittests-replication-data unittests-replication-logger -unittests-replication: unittests-replication-common unittests-replication-data unittests-replication-logger +unittests-replication: unittests-replication-common unittests-replication-data unittests-replication-http unittests-replication-logger unittests-replication-common: @echo @@ -579,6 +579,25 @@ unittests-replication-common: @rm -rf "$(VOCDIR)" @echo +unittests-replication-http: + $(MAKE) start-server PID=$(PID) SERVER_START="--server.endpoint tcp://$(VOCHOST):$(VOCPORT) --server.disable-authentication true" PROTO=http + + @echo + @echo "================================================================================" + @echo "<< REPLICATION SERVER TESTS >>" + @echo "================================================================================" + @echo + + cd @top_srcdir@/UnitTests/HttpInterface && ARANGO_SERVER="$(VOCHOST):$(VOCPORT)" ARANGO_SSL=0 ARANGO_USER="$(USERNAME)" ARANGO_PASSWORD="$(PASSWORD)" ./run-tests-replication || test "x$(FORCE)" == "x1" + + kill `cat $(PIDFILE)` + + while test -f $(PIDFILE); do sleep 1; done + @if [ "$(VALGRIND)" != "" ]; then sleep 60; fi + + @rm -rf "$(VOCDIR)" + @echo + unittests-replication-data: $(MAKE) start-server PID=$(PID) SERVER_START="--server.endpoint tcp://$(VOCHOST):$(VOCPORT) --server.disable-authentication true" PROTO=http $(MAKE) start-slave PID=$(PID) SERVER_START="--server.endpoint tcp://$(SLAVEHOST):$(SLAVEPORT) --server.disable-authentication true" PROTO=http diff --git a/arangod/RestServer/ArangoServer.cpp b/arangod/RestServer/ArangoServer.cpp index 03a23682d2..e36d82743d 100644 --- a/arangod/RestServer/ArangoServer.cpp +++ b/arangod/RestServer/ArangoServer.cpp @@ -79,6 +79,7 @@ #include "V8/v8-utils.h" #include "V8Server/ApplicationV8.h" #include "VocBase/auth.h" +#include "VocBase/replication-common.h" #include "RestServer/VocbaseManager.h" @@ -204,7 +205,7 @@ ArangoServer::ArangoServer (int argc, char** argv) _removeOnDrop(true), _replicationEnableLogger(false), _replicationLogRemoteChanges(false), - _replicationMaxEvents(1048576), + _replicationMaxEvents(TRI_REPLICATION_LOGGER_EVENTS_DEFAULT), _replicationMaxEventsSize(0), _vocbase(0) { diff --git a/arangod/VocBase/replication-common.h b/arangod/VocBase/replication-common.h index 9c702aa005..b2e48d8299 100644 --- a/arangod/VocBase/replication-common.h +++ b/arangod/VocBase/replication-common.h @@ -78,14 +78,20 @@ extern "C" { /// @brief minimum number of log events to keep (lower bound for logger config) //////////////////////////////////////////////////////////////////////////////// -#define TRI_REPLICATION_LOGGER_EVENTS_MIN 4096 +#define TRI_REPLICATION_LOGGER_EVENTS_MIN 4096 + +//////////////////////////////////////////////////////////////////////////////// +/// @brief default number of log events to keep +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_REPLICATION_LOGGER_EVENTS_DEFAULT 1048576 //////////////////////////////////////////////////////////////////////////////// /// @brief minimum cumulated size of log events to keep (lower bound for logger /// config) //////////////////////////////////////////////////////////////////////////////// -#define TRI_REPLICATION_LOGGER_SIZE_MIN 16777216 +#define TRI_REPLICATION_LOGGER_SIZE_MIN 16777216 //////////////////////////////////////////////////////////////////////////////// /// @} diff --git a/arangod/VocBase/replication-logger.c b/arangod/VocBase/replication-logger.c index dfb5bbd978..a7ae520729 100644 --- a/arangod/VocBase/replication-logger.c +++ b/arangod/VocBase/replication-logger.c @@ -265,8 +265,13 @@ static TRI_replication_operation_e TranslateDocumentOperation (TRI_voc_document_ //////////////////////////////////////////////////////////////////////////////// static void FreeCap (TRI_replication_logger_t* logger) { + assert(logger != NULL); + if (logger->_cap != NULL) { TRI_primary_collection_t* primary; + + assert(logger->_trxCollection != NULL); + assert(logger->_trxCollection->_collection != NULL); primary = logger->_trxCollection->_collection->_collection; assert(primary != NULL); @@ -276,8 +281,6 @@ static void FreeCap (TRI_replication_logger_t* logger) { TRI_GetServerId()); logger->_cap = NULL; - logger->_configuration._maxEvents = 0; - logger->_configuration._maxEventsSize = 0; } } @@ -1008,23 +1011,23 @@ static int StopReplicationLogger (TRI_replication_logger_t* logger) { } res = LogEvent(logger, 0, true, REPLICATION_STOP, buffer); + + // destroy cap constraint + FreeCap(logger); TRI_CommitTransaction(logger->_trx, 0); + TRI_FreeTransaction(logger->_trx); LOG_INFO("stopped replication logger for database '%s', last tick: %llu", logger->_databaseName, (unsigned long long) lastTick); - logger->_trx = NULL; logger->_trxCollection = NULL; logger->_state._lastLogTick = 0; logger->_state._active = false; - // destroy cap constraint - FreeCap(logger); - return res; } diff --git a/js/common/tests/shell-replication.js b/js/common/tests/shell-replication.js index 61f995cf96..f045d43e3b 100644 --- a/js/common/tests/shell-replication.js +++ b/js/common/tests/shell-replication.js @@ -2293,7 +2293,7 @@ function ReplicationApplierSuite () { fail(); } catch (err) { - assertEqual(errors.ERROR_REPLICATION_INVALID_CONFIGURATION.code, err.errorNum); + assertEqual(errors.ERROR_REPLICATION_INVALID_APPLIER_CONFIGURATION.code, err.errorNum); } }, @@ -2373,7 +2373,7 @@ function ReplicationApplierSuite () { replication.applier.properties({ }); } catch (err) { - assertEqual(errors.ERROR_REPLICATION_INVALID_CONFIGURATION.code, err.errorNum); + assertEqual(errors.ERROR_REPLICATION_INVALID_APPLIER_CONFIGURATION.code, err.errorNum); } replication.applier.properties({