mirror of https://gitee.com/bigwinds/arangodb
agency test waits exactly for the leader election to have ended
This commit is contained in:
parent
d55c85f8fa
commit
b40e5a3d24
|
@ -14,6 +14,10 @@
|
|||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#ifndef malloc_usable_size
|
||||
extern "C" size_t malloc_usable_size(const void *ptr);
|
||||
#endif
|
||||
|
||||
#include "db/dbformat.h"
|
||||
#include "db/pinned_iterators_manager.h"
|
||||
#include "rocksdb/iterator.h"
|
||||
|
|
|
@ -86,7 +86,7 @@ term_t Agent::term() const {
|
|||
|
||||
|
||||
/// Agency size
|
||||
inline size_t Agent::size() const {
|
||||
size_t Agent::size() const {
|
||||
return _config.size();
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ HttpHandler::status_t RestAgencyHandler::handleWrite() {
|
|||
}
|
||||
|
||||
if (max_index > 0) {
|
||||
std::this_thread::sleep_for(duration_t(5));
|
||||
std::this_thread::sleep_for(duration_t((_agent->size()-1)*5));
|
||||
_agent->waitFor(max_index);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1222,6 +1222,8 @@ int ClusterInfo::setCollectionPropertiesCoordinator(
|
|||
|
||||
AgencyPrecondition databaseExists(
|
||||
"Plan/Databases/" + databaseName, AgencyPrecondition::EMPTY, false);
|
||||
AgencyOperation incrementVersion(
|
||||
"Plan/Version", AgencySimpleOperationType::INCREMENT_OP);
|
||||
|
||||
res = ac.getValues("Plan/Collections/" + databaseName+"/" + collectionID);
|
||||
|
||||
|
@ -1264,7 +1266,7 @@ int ClusterInfo::setCollectionPropertiesCoordinator(
|
|||
"Plan/Collections/" + databaseName + "/" + collectionID,
|
||||
AgencyValueOperationType::SET, copy.slice());
|
||||
|
||||
AgencyWriteTransaction trans (setColl, databaseExists);
|
||||
AgencyWriteTransaction trans ({setColl, incrementVersion}, databaseExists);
|
||||
|
||||
res = ac.sendTransactionWithFailover(trans);
|
||||
|
||||
|
|
|
@ -41,12 +41,30 @@ function agencyTestSuite () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief the agency servers
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
var agencyServers = ARGUMENTS[0].split(" ");
|
||||
var whoseTurn = 0;
|
||||
|
||||
var nagents = agencyServers.length;
|
||||
var request = require("@arangodb/request");
|
||||
|
||||
// Wait for multi-host agency to have elected a leader
|
||||
if (agencyServers.length > 1) {
|
||||
while (true) {
|
||||
var res = request({url: agencyServers[whoseTurn] + "/_api/agency/config",
|
||||
method: "GET", followRedirects: true, body: "",
|
||||
headers: {"Content-Type": "application/json"}});
|
||||
wait(1);
|
||||
res.bodyParsed = JSON.parse(res.body);
|
||||
require("internal").print("Leadership election going on ... ");
|
||||
if (res.bodyParsed.leaderId >= 0 && res.bodyParsed.leaderId < nagents) {
|
||||
whoseTurn = res.bodyParsed.leaderId;
|
||||
require("internal").print("Agents elected " + res.bodyParsed.leaderId +
|
||||
" leader in term " + res.bodyParsed.term + ".");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function readAgency(list) {
|
||||
// We simply try all agency servers in turn until one gives us an HTTP
|
||||
// response:
|
||||
|
@ -100,7 +118,6 @@ function agencyTestSuite () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testSingleTopLevel : function () {
|
||||
wait(2);
|
||||
assertEqual(readAndCheck([["/x"]]), [{}]);
|
||||
writeAndCheck([[{x:12}]]);
|
||||
assertEqual(readAndCheck([["/x"]]), [{x:12}]);
|
||||
|
|
Loading…
Reference in New Issue