1
0
Fork 0

Split view and original tests and change approach of test in move shards

This commit is contained in:
Vadim Kondratyev 2018-08-22 00:36:34 +02:00
parent 2e05ad8f90
commit 0c78848876
4 changed files with 1884 additions and 197 deletions

View File

@ -53,11 +53,10 @@ const servers = getDBServers();
function MovingShardsSuite () {
'use strict';
const cn = "UnitTestMovingShards";
let count = 0;
let c = [];
let v = [];
let dbservers = getDBServers();
var cn = "UnitTestMovingShards";
var count = 0;
var c = [];
var dbservers = getDBServers();
////////////////////////////////////////////////////////////////////////////////
/// @brief find out servers for a collection
@ -398,42 +397,6 @@ function MovingShardsSuite () {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief create some views for existing collections
////////////////////////////////////////////////////////////////////////////////
function createSomeViews(n) {
assertTrue(c.length > 0);
console.info("Creating views on existing collections.");
for (let i = 0; i < n; i++) {
let vn = cn + "View" + i;
let view = db._createView(vn, "arangosearch", {});
let props = {links: {}};
for (let x = 0; x < c.length; x++) {
props.links[c[x].name()] = { includeAllFields: true, analyzers: ['text_en'] };
/*for (let y = 0; y < 1000; y++) {
c[x].save({ value: "the quick brown foxx jumped over the lazy dog"});
}*/
}
view.properties(props);
v.push(view);
}
console.info("Successfully created views.");
}
function checkViews() {
assertTrue(v.length > 0);
v.forEach( view => {
let props = view.properties();
let colls = Object.keys(props.links);
assertTrue(colls.length > 0);
/*colls.forEach(cc => assertEqual(db._collection(cc).count(), 1000));
const q = "FOR doc IN @@vv SEARCH PHRASE(doc.text, 'foxx jumped', 'text_en') RETURN doc";
let res = db._query(q, {"@vv": view.name()}).toArray();
assertTrue(colls.length * 1000, res.length);*/
});
}
////////////////////////////////////////////////////////////////////////////////
/// @brief find server not on a list
////////////////////////////////////////////////////////////////////////////////
@ -491,14 +454,10 @@ function MovingShardsSuite () {
////////////////////////////////////////////////////////////////////////////////
tearDown : function () {
for (let i = 0; i < c.length; ++i) {
for (var i = 0; i < c.length; ++i) {
c[i].drop();
}
c = [];
for (let i = 0; i < v.length; ++i) {
v[i].drop();
}
v = [];
resetCleanedOutServers();
},
@ -535,7 +494,6 @@ function MovingShardsSuite () {
////////////////////////////////////////////////////////////////////////////////
testMoveShardFromFollower : function() {
createSomeViews(1);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[0].name());
var fromServer = servers[1];
@ -546,7 +504,6 @@ function MovingShardsSuite () {
assertTrue(moveShard("_system", c[0]._id, shard, fromServer, toServer, false));
assertTrue(testServerEmpty(fromServer), false);
assertTrue(waitForSupervision());
checkViews();
},
////////////////////////////////////////////////////////////////////////////////
@ -554,7 +511,6 @@ function MovingShardsSuite () {
////////////////////////////////////////////////////////////////////////////////
testMoveShardFromLeader : function() {
createSomeViews(1);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[0].name());
var fromServer = servers[0];
@ -565,7 +521,6 @@ function MovingShardsSuite () {
assertTrue(moveShard("_system", c[0]._id, shard, fromServer, toServer, false));
assertTrue(testServerEmpty(fromServer), false);
assertTrue(waitForSupervision());
checkViews();
},
////////////////////////////////////////////////////////////////////////////////
@ -574,7 +529,6 @@ function MovingShardsSuite () {
testMoveShardFromLeaderNoReplication : function() {
createSomeCollections(1, 1, 1);
createSomeViews(1);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var fromServer = servers[0];
@ -585,7 +539,6 @@ function MovingShardsSuite () {
assertTrue(moveShard("_system", c[1]._id, shard, fromServer, toServer, false));
assertTrue(testServerEmpty(fromServer, false, 1, 1));
assertTrue(waitForSupervision());
checkViews();
},
////////////////////////////////////////////////////////////////////////////////
@ -594,7 +547,6 @@ function MovingShardsSuite () {
testMoveShardFromFollowerRepl3_1 : function() {
createSomeCollections(1, 1, 3);
createSomeViews(1);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var fromServer = servers[1];
@ -605,7 +557,6 @@ function MovingShardsSuite () {
assertTrue(moveShard("_system", c[1]._id, shard, fromServer, toServer, false));
assertTrue(testServerEmpty(fromServer, false, 1, 1));
assertTrue(waitForSupervision());
checkViews();
},
////////////////////////////////////////////////////////////////////////////////
@ -649,14 +600,12 @@ function MovingShardsSuite () {
////////////////////////////////////////////////////////////////////////////////
testCleanOutFollower : function() {
createSomeViews(1);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[0].name());
var toClean = servers[1];
assertTrue(cleanOutServer(toClean));
assertTrue(testServerEmpty(toClean, true));
assertTrue(waitForSupervision());
checkViews();
},
////////////////////////////////////////////////////////////////////////////////
@ -664,14 +613,12 @@ function MovingShardsSuite () {
////////////////////////////////////////////////////////////////////////////////
testCleanOutLeader : function() {
createSomeViews(1);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[0].name());
var toClean = servers[0];
assertTrue(cleanOutServer(toClean));
assertTrue(testServerEmpty(toClean, true));
assertTrue(waitForSupervision());
checkViews();
},
////////////////////////////////////////////////////////////////////////////////
@ -680,14 +627,12 @@ function MovingShardsSuite () {
testCleanOutMultipleCollections : function() {
createSomeCollections(10, 1, 2);
createSomeViews(2);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var toClean = servers[0];
assertTrue(cleanOutServer(toClean));
assertTrue(testServerEmpty(toClean, true));
assertTrue(waitForSupervision());
checkViews();
},
////////////////////////////////////////////////////////////////////////////////
@ -710,7 +655,6 @@ function MovingShardsSuite () {
testCleanOutMultipleShards : function() {
createSomeCollections(1, 10, 2);
createSomeViews(1);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var toClean = servers[1];

View File

@ -0,0 +1,903 @@
/*jshint globalstrict:false, strict:false */
/*global assertTrue, assertEqual, ArangoAgency */
////////////////////////////////////////////////////////////////////////////////
/// @brief test moving shards in the cluster
///
/// @file js/server/tests/resilience/moving-shards-cluster.js
///
/// DISCLAIMER
///
/// Copyright 2016-2018 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 ArangoDB GmbH, Cologne, Germany
///
/// @author Vadim Kondratyev
/// @author Copyright 2018, ArangoDB GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
const jsunity = require("jsunity");
const arangodb = require("@arangodb");
const db = arangodb.db;
const _ = require("lodash");
const wait = require("internal").wait;
const supervisionState = require("@arangodb/cluster").supervisionState;
function getDBServers() {
var tmp = global.ArangoClusterInfo.getDBServers();
var servers = [];
for (var i = 0; i < tmp.length; ++i) {
servers[i] = tmp[i].serverId;
}
return servers;
}
const servers = getDBServers();
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
////////////////////////////////////////////////////////////////////////////////
function MovingShardsWithViewSuite (options) {
'use strict';
var cn = "UnitTestMovingShards";
var count = 0;
var c = [], v = [];
var dbservers = getDBServers();
var useData = options.useData;
////////////////////////////////////////////////////////////////////////////////
/// @brief find out servers for a collection
////////////////////////////////////////////////////////////////////////////////
function findCollectionServers(database, collection) {
var cinfo = global.ArangoClusterInfo.getCollectionInfo(database, collection);
var shard = Object.keys(cinfo.shards)[0];
return cinfo.shards[shard];
}
////////////////////////////////////////////////////////////////////////////////
/// @brief find out servers for the shards of a collection
////////////////////////////////////////////////////////////////////////////////
function findCollectionShardServers(database, collection, sort = true, unique = false) {
var cinfo = global.ArangoClusterInfo.getCollectionInfo(database, collection);
var sColServers = [];
for(var shard in cinfo.shards) {
sColServers.push(...cinfo.shards[shard]);
}
if (unique) sColServers = Array.from(new Set(sColServers));
return sort ? sColServers.sort() : sColServers;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief wait for synchronous replication
////////////////////////////////////////////////////////////////////////////////
function waitForSynchronousReplication(database) {
console.info("Waiting for synchronous replication to settle...");
global.ArangoClusterInfo.flush();
for (var i = 0; i < c.length; ++i) {
var cinfo = global.ArangoClusterInfo.getCollectionInfo(
database, c[i].name());
var shards = Object.keys(cinfo.shards);
var replFactor = cinfo.shards[shards[0]].length;
var count = 0;
while (++count <= 180) {
var ccinfo = shards.map(
s => global.ArangoClusterInfo.getCollectionInfoCurrent(
database, c[i].name(), s)
);
let replicas = ccinfo.map(s => s.servers.length);
if (_.every(replicas, x => x === replFactor)) {
console.info("Replication up and running!");
break;
}
wait(0.5);
global.ArangoClusterInfo.flush();
}
if (count > 120) {
return false;
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief get cleaned out servers
////////////////////////////////////////////////////////////////////////////////
function getCleanedOutServers() {
var coordEndpoint =
global.ArangoClusterInfo.getServerEndpoint("Coordinator0001");
var request = require("@arangodb/request");
var endpointToURL = require("@arangodb/cluster").endpointToURL;
var url = endpointToURL(coordEndpoint);
var res;
try {
var envelope =
{ method: "GET", url: url + "/_admin/cluster/numberOfServers" };
res = request(envelope);
} catch (err) {
console.error(
"Exception for POST /_admin/cluster/cleanOutServer:", err.stack);
return {};
}
var body = res.body;
if (typeof body === "string") {
body = JSON.parse(body);
}
return body;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief test whether or not a server is clean
////////////////////////////////////////////////////////////////////////////////
function testServerEmpty(id, checkList, fromCollNr, toCollNr) {
if (fromCollNr === undefined) {
fromCollNr = 0;
}
if (toCollNr === undefined) {
toCollNr = c.length - 1;
}
var count = 600;
var ok = false;
console.info("Waiting for server " + id + " to be cleaned out ...");
if (checkList) {
// Wait until the server appears in the list of cleanedOutServers:
var obj;
while (--count > 0) {
obj = getCleanedOutServers();
if (obj.cleanedServers.indexOf(id) >= 0) {
ok = true;
console.info(
"Success: Server " + id + " cleaned out after " + (600-count) + " seconds");
break;
}
wait(1.0);
}
if (!ok) {
console.info(
"Failed: Server " + id + " was not cleaned out. List of cleaned servers: ["
+ obj.cleanedServers + "]");
}
} else {
for (var i = fromCollNr; i <= toCollNr; ++i) {
while (--count > 0) {
wait(1.0);
global.ArangoClusterInfo.flush();
var servers = findCollectionServers("_system", c[i].name());
if (servers.indexOf(id) === -1) {
// Now check current as well:
var collInfo =
global.ArangoClusterInfo.getCollectionInfo("_system", c[i].name());
var shards = collInfo.shards;
var collInfoCurr =
Object.keys(shards).map(
s => global.ArangoClusterInfo.getCollectionInfoCurrent(
"_system", c[i].name(), s).servers);
var idxs = collInfoCurr.map(l => l.indexOf(id));
ok = true;
for (var j = 0; j < idxs.length; j++) {
if (idxs[j] !== -1) {
ok = false;
}
}
if (ok) {
break;
}
}
}
if (!ok) {
return false;
}
}
}
return ok;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief order the cluster to clean out a server:
////////////////////////////////////////////////////////////////////////////////
function cleanOutServer(id) {
var coordEndpoint =
global.ArangoClusterInfo.getServerEndpoint("Coordinator0001");
var request = require("@arangodb/request");
var endpointToURL = require("@arangodb/cluster").endpointToURL;
var url = endpointToURL(coordEndpoint);
var body = {"server": id};
var result;
try {
result = request({ method: "POST",
url: url + "/_admin/cluster/cleanOutServer",
body: JSON.stringify(body) });
} catch (err) {
console.error(
"Exception for POST /_admin/cluster/cleanOutServer:", err.stack);
return false;
}
console.info("cleanOutServer job:", JSON.stringify(body));
console.info("result of request:", JSON.stringify(result.json));
// Now wait until the job we triggered is finished:
var count = 1200; // seconds
while (true) {
var job = require("@arangodb/cluster").queryAgencyJob(result.json.id);
console.info("Status of cleanOutServer job:", job.status);
if (job.error === false && job.status === "Finished") {
return result;
}
if (count-- < 0) {
console.error(
"Timeout in waiting for cleanOutServer to complete: "
+ JSON.stringify(body));
return false;
}
require("internal").wait(1.0);
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief order the cluster to reduce number of db servers
////////////////////////////////////////////////////////////////////////////////
function shrinkCluster(toNum) {
var coordEndpoint =
global.ArangoClusterInfo.getServerEndpoint("Coordinator0001");
var request = require("@arangodb/request");
var endpointToURL = require("@arangodb/cluster").endpointToURL;
var url = endpointToURL(coordEndpoint);
var body = {"numberOfDBServers":toNum};
try {
return request({ method: "PUT",
url: url + "/_admin/cluster/numberOfServers",
body: JSON.stringify(body) });
} catch (err) {
console.error(
"Exception for PUT /_admin/cluster/numberOfServers:", err.stack);
return false;
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief order the cluster to clean out a server:
////////////////////////////////////////////////////////////////////////////////
function resetCleanedOutServers() {
var coordEndpoint =
global.ArangoClusterInfo.getServerEndpoint("Coordinator0001");
var request = require("@arangodb/request");
var endpointToURL = require("@arangodb/cluster").endpointToURL;
var url = endpointToURL(coordEndpoint);
var numberOfDBServers = servers.length;
var body = {"cleanedServers":[], "numberOfDBServers":numberOfDBServers};
try {
var res = request({ method: "PUT",
url: url + "/_admin/cluster/numberOfServers",
body: JSON.stringify(body) });
return res;
}
catch (err) {
console.error(
"Exception for PUT /_admin/cluster/numberOfServers:", err.stack);
return false;
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief move a single shard
////////////////////////////////////////////////////////////////////////////////
function moveShard(database, collection, shard, fromServer, toServer, dontwait) {
var coordEndpoint =
global.ArangoClusterInfo.getServerEndpoint("Coordinator0001");
var request = require("@arangodb/request");
var endpointToURL = require("@arangodb/cluster").endpointToURL;
var url = endpointToURL(coordEndpoint);
var body = {database, collection, shard, fromServer, toServer};
var result;
try {
result = request({ method: "POST",
url: url + "/_admin/cluster/moveShard",
body: JSON.stringify(body) });
} catch (err) {
console.error(
"Exception for PUT /_admin/cluster/moveShard:", err.stack);
return false;
}
if (dontwait) {
return result;
}
console.info("moveShard job:", JSON.stringify(body));
console.info("result of request:", JSON.stringify(result.json));
// Now wait until the job we triggered is finished:
var count = 600; // seconds
while (true) {
var job = require("@arangodb/cluster").queryAgencyJob(result.json.id);
console.info("Status of moveShard job:", job.status);
if (job.error === false && job.status === "Finished") {
return result;
}
if (count-- < 0) {
console.error(
"Timeout in waiting for moveShard to complete: "
+ JSON.stringify(body));
return false;
}
require("internal").wait(1.0);
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Set supervision mode
////////////////////////////////////////////////////////////////////////////////
function maintenanceMode(mode) {
console.log("Switching supervision maintenance " + mode);
var coordEndpoint =
global.ArangoClusterInfo.getServerEndpoint("Coordinator0001");
var request = require("@arangodb/request");
var endpointToURL = require("@arangodb/cluster").endpointToURL;
var url = endpointToURL(coordEndpoint);
var req;
try {
req = request({ method: "PUT",
url: url + "/_admin/cluster/maintenance",
body: JSON.stringify(mode) });
} catch (err) {
console.error(
"Exception for PUT /_admin/cluster/maintenance:", err.stack);
return false;
}
console.log("Supervision maintenance is " + mode);
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief create some collections
////////////////////////////////////////////////////////////////////////////////
function createSomeCollectionsWithView(n, nrShards, replFactor, withData = false) {
var systemCollServers = findCollectionServers("_system", "_graphs");
console.info("System collections use servers:", systemCollServers);
for (var i = 0; i < n; ++i) {
++count;
while (true) {
var name = cn + count;
db._drop(name);
var coll = db._create(name, {numberOfShards: nrShards,
replicationFactor: replFactor,
avoidServers: systemCollServers});
var servers = findCollectionServers("_system", name);
console.info("Test collection uses servers:", servers);
if (_.intersection(systemCollServers, servers).length === 0) {
c.push(coll);
var vname = "v" + name;
try {
db._view(vname).drop();
} catch (ignored) {}
var view = db._createView(vname, "arangosearch", {});
view.properties(
{links:
{[name]:
{fields:
{'a': { analyzers: ['identity']}, 'b': { analyzers: ['text_en']}}
}
}
});
v.push(view);
if (withData) {
for (let i = 0; i < 1000; ++i) {
coll.save({a: i, b: "text" + i});
}
}
break;
}
console.info("Need to recreate collection to avoid system collection servers.");
c.push(coll);
waitForSynchronousReplication("_system");
c.pop();
console.info("Synchronous replication has settled, now dropping again.");
}
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief find server not on a list
////////////////////////////////////////////////////////////////////////////////
function findServerNotOnList(list) {
var count = 0;
while (list.indexOf(dbservers[count]) >= 0) {
count += 1;
}
return dbservers[count];
}
////////////////////////////////////////////////////////////////////////////////
/// @brief wait for Supervision to finish jobs
////////////////////////////////////////////////////////////////////////////////
function waitForSupervision() {
var count = 300;
while (--count > 0) {
var state = supervisionState();
if (!state.error &&
Object.keys(state.ToDo).length === 0 &&
Object.keys(state.Pending).length === 0) {
return true;
}
if (state.error) {
console.warn("Waiting for supervision jobs to finish:",
"Currently no agency communication possible.");
} else {
console.info("Waiting for supervision jobs to finish:",
"ToDo jobs:", Object.keys(state.ToDo).length,
"Pending jobs:", Object.keys(state.Pending).length);
}
wait(1.0);
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief get DBServers for a shard view of collection
////////////////////////////////////////////////////////////////////////////////
function getShardedViewServers(database, collection, sort = true, unique = false) {
var request = require("@arangodb/request");
var endpointToURL = require("@arangodb/cluster").endpointToURL;
var sViewServers = [];
global.ArangoClusterInfo.flush();
var cinfo = global.ArangoClusterInfo.getCollectionInfo(
database, collection.name());
for(var shard in cinfo.shards) {
getDBServers().forEach(serverId => {
var dbServerEndpoint = global.ArangoClusterInfo.getServerEndpoint(serverId);
var url = endpointToURL(dbServerEndpoint);
var res;
try {
var envelope =
{ method: "GET", url: url + "/_api/view" };
res = request(envelope);
} catch (err) {
console.error(
"Exception for GET /_api/view:", err.stack);
return {};
}
var body = res.body;
if (typeof body === "string") {
var views = JSON.parse(body).result;
}
views.forEach(v => {
var res;
try {
var envelope =
{ method: "GET", url: url + "/_api/view/" + v.name + "/properties" };
res = request(envelope);
} catch (err) {
console.error(
"Exception for GET /_api/view/" + v.name + "/properties:", err.stack);
return {};
}
var body = res.body;
if (typeof body === "string") {
var links = JSON.parse(body).links;
if (links !== undefined
&& links.hasOwnProperty(shard)
&& links.shard !== {}) {
sViewServers.push(serverId);
}
}
});
});
}
if (unique) sViewServers = Array.from(new Set(sViewServers));
return sort ? sViewServers.sort() : sViewServers;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief the actual tests
////////////////////////////////////////////////////////////////////////////////
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
setUp : function () {
createSomeCollectionsWithView(1, 1, 2, useData);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
tearDown : function () {
for (var i = 0; i < c.length; ++i) {
v[i].drop();
c[i].drop();
}
c = [], v = [];
resetCleanedOutServers();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief check if a synchronously replicated collection gets online
////////////////////////////////////////////////////////////////////////////////
testSetup : function () {
dbservers = getDBServers();
assertTrue(waitForSynchronousReplication("_system"));
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief cleaning out collection with one shard without replication
////////////////////////////////////////////////////////////////////////////////
testShrinkNoReplication : function() {
assertTrue(waitForSynchronousReplication("_system"));
var _dbservers = servers;
_dbservers.sort();
assertTrue(shrinkCluster(4));
assertTrue(testServerEmpty(_dbservers[4], true));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
assertTrue(shrinkCluster(3));
assertTrue(testServerEmpty(_dbservers[3], true));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
assertTrue(shrinkCluster(2));
assertTrue(testServerEmpty(_dbservers[2], true));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief moving away a shard from a follower
////////////////////////////////////////////////////////////////////////////////
testMoveShardFromFollower : function() {
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[0].name());
var fromServer = servers[1];
var toServer = findServerNotOnList(servers);
var cinfo = global.ArangoClusterInfo.getCollectionInfo(
"_system", c[0].name());
var shard = Object.keys(cinfo.shards)[0];
assertTrue(moveShard("_system", c[0]._id, shard, fromServer, toServer, false));
assertTrue(testServerEmpty(fromServer), false);
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief moving away a shard from a leader
////////////////////////////////////////////////////////////////////////////////
testMoveShardFromLeader : function() {
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[0].name());
var fromServer = servers[0];
var toServer = findServerNotOnList(servers);
var cinfo = global.ArangoClusterInfo.getCollectionInfo(
"_system", c[0].name());
var shard = Object.keys(cinfo.shards)[0];
assertTrue(moveShard("_system", c[0]._id, shard, fromServer, toServer, false));
assertTrue(testServerEmpty(fromServer), false);
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief moving away a shard from a leader without replication
////////////////////////////////////////////////////////////////////////////////
testMoveShardFromLeaderNoReplication : function() {
createSomeCollectionsWithView(1, 1, 1, useData);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var fromServer = servers[0];
var toServer = findServerNotOnList(servers);
var cinfo = global.ArangoClusterInfo.getCollectionInfo(
"_system", c[1].name());
var shard = Object.keys(cinfo.shards)[0];
assertTrue(moveShard("_system", c[1]._id, shard, fromServer, toServer, false));
assertTrue(testServerEmpty(fromServer, false, 1, 1));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief moving away a shard from a follower with 3 replicas #1
////////////////////////////////////////////////////////////////////////////////
testMoveShardFromFollowerRepl3_1 : function() {
createSomeCollectionsWithView(1, 1, 3, useData);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var fromServer = servers[1];
var toServer = findServerNotOnList(servers);
var cinfo = global.ArangoClusterInfo.getCollectionInfo(
"_system", c[1].name());
var shard = Object.keys(cinfo.shards)[0];
assertTrue(moveShard("_system", c[1]._id, shard, fromServer, toServer, false));
assertTrue(testServerEmpty(fromServer, false, 1, 1));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief moving away a shard from a follower with 3 replicas #2
////////////////////////////////////////////////////////////////////////////////
testMoveShardFromRepl3_2 : function() {
createSomeCollectionsWithView(1, 1, 3, useData);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var fromServer = servers[2];
var toServer = findServerNotOnList(servers);
var cinfo = global.ArangoClusterInfo.getCollectionInfo(
"_system", c[1].name());
var shard = Object.keys(cinfo.shards)[0];
assertTrue(moveShard("_system", c[1]._id, shard, fromServer, toServer, false));
assertTrue(testServerEmpty(fromServer, false, 1, 1));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief moving away a shard from a leader with 3 replicas
////////////////////////////////////////////////////////////////////////////////
testMoveShardFromLeaderRepl : function() {
createSomeCollectionsWithView(1, 1, 3, useData);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var fromServer = servers[0];
var toServer = findServerNotOnList(servers);
var cinfo = global.ArangoClusterInfo.getCollectionInfo(
"_system", c[1].name());
var shard = Object.keys(cinfo.shards)[0];
assertTrue(moveShard("_system", c[1]._id, shard, fromServer, toServer, false));
assertTrue(testServerEmpty(fromServer, false, 1, 1));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief cleaning out a follower
////////////////////////////////////////////////////////////////////////////////
testCleanOutFollower : function() {
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[0].name());
var toClean = servers[1];
assertTrue(cleanOutServer(toClean));
assertTrue(testServerEmpty(toClean, true));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief cleaning out a leader
////////////////////////////////////////////////////////////////////////////////
testCleanOutLeader : function() {
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[0].name());
var toClean = servers[0];
assertTrue(cleanOutServer(toClean));
assertTrue(testServerEmpty(toClean, true));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief cleaning out with multiple collections
////////////////////////////////////////////////////////////////////////////////
testCleanOutMultipleCollections : function() {
createSomeCollectionsWithView(10, 1, 2, useData);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var toClean = servers[0];
assertTrue(cleanOutServer(toClean));
assertTrue(testServerEmpty(toClean, true));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief cleaning out with a collection with 3 replicas
////////////////////////////////////////////////////////////////////////////////
testCleanOut3Replicas : function() {
createSomeCollectionsWithView(1, 1, 3, useData);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var toClean = servers[0];
assertTrue(cleanOutServer(toClean));
assertTrue(testServerEmpty(toClean, true));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief cleaning out collection with multiple shards
////////////////////////////////////////////////////////////////////////////////
testCleanOutMultipleShards : function() {
createSomeCollectionsWithView(1, 10, 2, useData);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var toClean = servers[1];
assertTrue(cleanOutServer(toClean));
assertTrue(testServerEmpty(toClean, true));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief cleaning out collection with one shard without replication
////////////////////////////////////////////////////////////////////////////////
testCleanOutNoReplication : function() {
createSomeCollectionsWithView(1, 1, 1, useData);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var toClean = servers[0];
assertTrue(cleanOutServer(toClean));
assertTrue(testServerEmpty(toClean, true));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief pausing supervision for a couple of seconds
////////////////////////////////////////////////////////////////////////////////
testMaintenanceMode : function() {
createSomeCollectionsWithView(1, 1, 3, useData);
assertTrue(waitForSynchronousReplication("_system"));
var servers = findCollectionServers("_system", c[1].name());
var fromServer = servers[0];
var toServer = findServerNotOnList(servers);
var cinfo = global.ArangoClusterInfo.getCollectionInfo(
"_system", c[1].name());
var shard = Object.keys(cinfo.shards)[0];
assertTrue(maintenanceMode("on"));
assertTrue(moveShard("_system", c[1]._id, shard, fromServer, toServer, true));
var first = global.ArangoAgency.transient([["/arango/Supervision/State"]])[0].
arango.Supervision.State, state;
var waitUntil = new Date().getTime() + 30.0*1000;
while(true) {
state = global.ArangoAgency.transient([["/arango/Supervision/State"]])[0].
arango.Supervision.State;
assertEqual(state.Timestamp, first.Timestamp);
wait(5.0);
if (new Date().getTime() > waitUntil) {
break;
}
}
assertTrue(maintenanceMode("off"));
state = global.ArangoAgency.transient([["/arango/Supervision/State"]])[0].
arango.Supervision.State;
assertTrue(state.Timestamp !== first.Timestamp);
assertTrue(testServerEmpty(fromServer, false, 1, 1));
assertTrue(waitForSupervision());
c.forEach( c_v => {
assertEqual(getShardedViewServers("_system", c_v),
findCollectionShardServers("_system", c_v.name()));
});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief just to allow a trailing comma at the end of the last test
////////////////////////////////////////////////////////////////////////////////
testDummy : function () {
assertEqual(12, 12);
}
};
}
////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////
jsunity.run(function MovingShardsWithViewSuite_nodata() {
return MovingShardsWithViewSuite({ useData: false });
});
/*jsunity.run(function MovingShardsWithViewSuite_data() {
return MovingShardsWithViewSuite({ useData: true });
});*/
return jsunity.done();

View File

@ -185,21 +185,11 @@ function SynchronousReplicationSuite () {
var id = c.insert({Hallo:12});
assertEqual(1, c.count());
viewOperations("assert", null, function assert() {
assertEqual(
viewOperations("query", { query: "FOR d IN @@vn COLLECT WITH COUNT into iCount RETURN iCount",
bind: '{ "@vn" : name }' }).toArray()[0], 1); } );
if (healing.place === 1) { healFailure(healing); }
if (failure.place === 2) { makeFailure(failure); }
var doc = c.document(id._key);
assertEqual(12, doc.Hallo);
viewOperations("assert", null, function assert() {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d.Hallo == 12 RETURN d.Hallo", bind: '{ "@vn" : name }' }).toArray();
assertEqual(result.length, 1);
assertEqual(result[0], 12);
});
if (healing.place === 2) { healFailure(healing); }
if (failure.place === 3) { makeFailure(failure); }
@ -207,10 +197,6 @@ function SynchronousReplicationSuite () {
var ids = c.insert([{Hallo:13}, {Hallo:14}]);
assertEqual(3, c.count());
assertEqual(2, ids.length);
viewOperations("assert", null, function assert() {
var result = viewOperations("query", { query: "FOR d IN @@vn RETURN d", bind: '{ "@vn" : name }' }).toArray();
assertEqual(result.length, 3);
});
if (healing.place === 3) { healFailure(healing); }
if (failure.place === 4) { makeFailure(failure); }
@ -219,15 +205,6 @@ function SynchronousReplicationSuite () {
assertEqual(2, docs.length);
assertEqual(13, docs[0].Hallo);
assertEqual(14, docs[1].Hallo);
viewOperations("assert", null, function assert(inFilter = ids) {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d._key IN ["
+ inFilter.map(e => "'" + e._key + "'").join(",")
+ "] SORT d._key RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(2, result.length);
assertEqual(13, result[0].Hallo);
assertEqual(14, result[1].Hallo);
});
if (healing.place === 4) { healFailure(healing); }
if (failure.place === 5) { makeFailure(failure); }
@ -240,12 +217,6 @@ function SynchronousReplicationSuite () {
doc = c.document(id._key);
assertEqual(100, doc.Hallo);
viewOperations("assert", null, function assert(inFilter = id._key) {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d._key == '" + `${inFilter}` + "' RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(1, result.length);
assertEqual(100, result[0].Hallo);
});
if (healing.place === 6) { healFailure(healing); }
if (failure.place === 7) { makeFailure(failure); }
@ -259,15 +230,6 @@ function SynchronousReplicationSuite () {
assertEqual(2, docs.length);
assertEqual(101, docs[0].Hallo);
assertEqual(102, docs[1].Hallo);
viewOperations("assert", null, function assert(inFilter = ids) {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d._key IN ["
+ inFilter.map(e => "'" + e._key + "'").join(",")
+ "] SORT d._key RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(2, result.length);
assertEqual(101, result[0].Hallo);
assertEqual(102, result[1].Hallo);
});
if (healing.place === 8) { healFailure(healing); }
if (failure.place === 9) { makeFailure(failure); }
@ -281,13 +243,6 @@ function SynchronousReplicationSuite () {
doc = c.document(id._key);
assertEqual(100, doc.Hallo);
assertEqual(105, doc.Hallox);
viewOperations("assert", null, function assert(inFilter = id._key) {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d._key == '" + `${inFilter}` + "' RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(1, result.length);
assertEqual(100, result[0].Hallo);
assertEqual(105, result[0].Hallox);
});
if (healing.place === 10) { healFailure(healing); }
if (failure.place === 11) { makeFailure(failure); }
@ -303,17 +258,6 @@ function SynchronousReplicationSuite () {
assertEqual(102, docs[1].Hallo);
assertEqual(106, docs[0].Hallox);
assertEqual(107, docs[1].Hallox);
viewOperations("assert", null, function assert(inFilter = ids) {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d._key IN ["
+ inFilter.map(e => "'" + e._key + "'").join(",")
+ "] SORT d._key RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(2, result.length);
assertEqual(101, result[0].Hallo);
assertEqual(102, result[1].Hallo);
assertEqual(106, result[0].Hallox);
assertEqual(107, result[1].Hallox);
});
if (healing.place === 12) { healFailure(healing); }
if (failure.place === 13) { makeFailure(failure); }
@ -326,12 +270,6 @@ function SynchronousReplicationSuite () {
docs = q.toArray();
assertEqual(3, docs.length);
assertEqual([{Hallo:100}, {Hallo:101}, {Hallo:102}], docs);
viewOperations("assert", null, function assert() {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d.Hallo > 0 SORT d.Hallo RETURN {'Hallo': d.Hallo}",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(3, result.length);
assertEqual([{Hallo:100}, {Hallo:101}, {Hallo:102}], result);
});
if (healing.place === 13) { healFailure(healing); }
if (failure.place === 14) { makeFailure(failure); }
@ -354,12 +292,6 @@ function SynchronousReplicationSuite () {
if (failure.place === 16) { makeFailure(failure); }
assertEqual(2, c.count());
viewOperations("assert", null, function assert(doc = id._key) {
var result = viewOperations("query", { query: "FOR d IN @@vn RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(2, result.length);
assertEqual(undefined, result.find(e => e._key === doc));
});
if (healing.place === 16) { healFailure(healing); }
if (failure.place === 17) { makeFailure(failure); }
@ -373,72 +305,10 @@ function SynchronousReplicationSuite () {
assertEqual(2, docs.length);
assertTrue(docs[0].error);
assertTrue(docs[1].error);
viewOperations("assert", null, function assert(doc = id._key) {
var result = viewOperations("query", { query: "FOR d IN @@vn RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(0, result.length);
});
if (healing.place === 18) { healFailure(healing); }
}
///////////////////////////////////////////////////////////////////////////////
/// @brief view operations:
////////////////////////////////////////////////////////////////////////////////
function viewOperations(type, options = null, exec = null) {
var useView = false;
// check if arangosearch views are supported and could be used
if (useView === true && db._views() !== 0) {
var name = (typeof options !== "undefined" && options != null && options.hasOwnProperty("name")) ? options.name : "vn";
var checkArgument = (parameter, argument = null, type = "object") => {
if (type === "object") {
return (typeof parameter === type && parameter != null && parameter.hasOwnProperty(argument) && parameter[argument] !== null);
}
if (type === "function") {
return (typeof parameter === "function" && parameter.name === argument);
}
return false;
};
switch(type) {
case "drop":
try {
return db._view(name).drop();
} catch (ignored) { }
break;
case "create":
let view = db._createView(name, "arangosearch", {});
if (checkArgument(options, "properties")) {
view.properties(options.properties);
}
return view;
break;
case "query":
if (checkArgument(options, "query")) {
if (checkArgument(options, "bind")) {
var binded;
eval("binded = " + options.bind );
return db._query(options.query, binded, { waitForSync: true });
} else {
return db._query(options.query, null, { waitForSync: true });
}
} else {
return null;
}
break;
case "assert":
if (checkArgument(exec, "assert", "function")) {
exec();
} else {
fail();
}
break;
}
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief the actual tests
////////////////////////////////////////////////////////////////////////////////
@ -456,10 +326,6 @@ function SynchronousReplicationSuite () {
db._drop(cn);
c = db._create(cn, {numberOfShards: 1, replicationFactor: 2,
avoidServers: systemCollServers});
viewOperations("drop");//try { db._view("vn1").drop(); } catch(ignore) { }
viewOperations("create", { properties: { links: { [cn]: { includeAllFields: true } } } });
var servers = findCollectionServers("_system", cn);
console.info("Test collections uses servers:", servers);
if (_.intersection(systemCollServers, servers).length === 0) {
@ -477,7 +343,6 @@ function SynchronousReplicationSuite () {
tearDown : function () {
db._drop(cn);
viewOperations("drop");
//global.ArangoAgency.set('Target/FailedServers', {});
},
@ -942,7 +807,7 @@ function SynchronousReplicationSuite () {
assertTrue(waitForSynchronousReplication("_system"));
},
///////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief just to allow a trailing comma at the end of the last test
////////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,975 @@
/*jshint globalstrict:false, strict:false */
/*global assertTrue, assertFalse, assertEqual, fail, instanceInfo */
////////////////////////////////////////////////////////////////////////////////
/// @brief test synchronous replication in the cluster
///
/// @file js/server/tests/resilience/resilience-synchronous-replication-cluster.js
///
/// DISCLAIMER
///
/// Copyright 2016-2018 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 ArangoDB GmbH, Cologne, Germany
///
/// @author Vadim Kondratyev
/// @author Copyright 2018, ArangoDB GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
const jsunity = require("jsunity");
const arangodb = require("@arangodb");
const db = arangodb.db;
const ERRORS = arangodb.errors;
const _ = require("lodash");
const wait = require("internal").wait;
const suspendExternal = require("internal").suspendExternal;
const continueExternal = require("internal").continueExternal;
const download = require('internal').download;
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
////////////////////////////////////////////////////////////////////////////////
function SynchronousReplicationWithViewSuite () {
'use strict';
var cn = "UnitTestSyncRep";
var c;
var cinfo;
var ccinfo;
var shards;
// FIXME: remove it after issue #2900 of planning is fixed
var useView = false;
////////////////////////////////////////////////////////////////////////////////
/// @brief find out servers for the system collections
////////////////////////////////////////////////////////////////////////////////
function findCollectionServers(database, collection) {
var cinfo = global.ArangoClusterInfo.getCollectionInfo(database, collection);
var shard = Object.keys(cinfo.shards)[0];
return cinfo.shards[shard];
}
////////////////////////////////////////////////////////////////////////////////
/// @brief find out servers for the shards of a collection
////////////////////////////////////////////////////////////////////////////////
function findCollectionShardServers(database, collection) {
var cinfo = global.ArangoClusterInfo.getCollectionInfo(database, collection);
var shard = Object.keys(cinfo.shards)[0];
return cinfo.shards[shard];
}
////////////////////////////////////////////////////////////////////////////////
/// @brief wait for synchronous replication
////////////////////////////////////////////////////////////////////////////////
function waitForSynchronousReplication(database) {
console.info("Waiting for synchronous replication to settle...");
global.ArangoClusterInfo.flush();
cinfo = global.ArangoClusterInfo.getCollectionInfo(database, cn);
shards = Object.keys(cinfo.shards);
var count = 0;
var replicas;
while (++count <= 300) {
ccinfo = shards.map(
s => global.ArangoClusterInfo.getCollectionInfoCurrent(database, cn, s)
);
console.info("Plan:", cinfo.shards, "Current:", ccinfo.map(s => s.servers));
replicas = ccinfo.map(s => s.servers.length);
if (replicas.every(x => x > 1)) {
console.info("Replication up and running!");
return true;
}
wait(0.5);
global.ArangoClusterInfo.flush();
}
console.error("Replication did not finish");
return false;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief fail the follower
////////////////////////////////////////////////////////////////////////////////
function failFollower() {
var follower = cinfo.shards[shards[0]][1];
var endpoint = global.ArangoClusterInfo.getServerEndpoint(follower);
// Now look for instanceInfo:
var pos = _.findIndex(global.instanceInfo.arangods,
x => x.endpoint === endpoint);
assertTrue(pos >= 0);
assertTrue(suspendExternal(global.instanceInfo.arangods[pos].pid));
console.info("Have failed follower", follower);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief heal the follower
////////////////////////////////////////////////////////////////////////////////
function healFollower() {
var follower = cinfo.shards[shards[0]][1];
var endpoint = global.ArangoClusterInfo.getServerEndpoint(follower);
// Now look for instanceInfo:
var pos = _.findIndex(global.instanceInfo.arangods,
x => x.endpoint === endpoint);
assertTrue(pos >= 0);
assertTrue(continueExternal(global.instanceInfo.arangods[pos].pid));
console.info("Have healed follower", follower);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief fail the leader
////////////////////////////////////////////////////////////////////////////////
function failLeader() {
var leader = cinfo.shards[shards[0]][0];
var endpoint = global.ArangoClusterInfo.getServerEndpoint(leader);
// Now look for instanceInfo:
var pos = _.findIndex(global.instanceInfo.arangods,
x => x.endpoint === endpoint);
assertTrue(pos >= 0);
assertTrue(suspendExternal(global.instanceInfo.arangods[pos].pid));
console.info("Have failed leader", leader);
return leader;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief heal the follower
////////////////////////////////////////////////////////////////////////////////
function healLeader() {
var leader = cinfo.shards[shards[0]][0];
var endpoint = global.ArangoClusterInfo.getServerEndpoint(leader);
// Now look for instanceInfo:
var pos = _.findIndex(global.instanceInfo.arangods,
x => x.endpoint === endpoint);
assertTrue(pos >= 0);
assertTrue(continueExternal(global.instanceInfo.arangods[pos].pid));
console.info("Have healed leader", leader);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief produce failure
////////////////////////////////////////////////////////////////////////////////
function makeFailure(failure) {
if (failure.follower) {
failFollower();
} else {
failLeader();
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief heal failure
////////////////////////////////////////////////////////////////////////////////
function healFailure(failure) {
if (failure.follower) {
healFollower();
} else {
healLeader();
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief basic operations, with various failure modes:
////////////////////////////////////////////////////////////////////////////////
function runBasicOperations(failure, healing) {
if (failure.place === 1) { makeFailure(failure); }
// Insert with check:
var id = c.insert({Hallo:12});
assertEqual(1, c.count());
viewOperations("assert", null, function assert() {
assertEqual(
viewOperations("query", { query: "FOR d IN @@vn COLLECT WITH COUNT into iCount RETURN iCount",
bind: '{ "@vn" : name }' }).toArray()[0], 1) } );
if (healing.place === 1) { healFailure(healing); }
if (failure.place === 2) { makeFailure(failure); }
var doc = c.document(id._key);
assertEqual(12, doc.Hallo);
viewOperations("assert", null, function assert() {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d.Hallo == 12 RETURN d.Hallo", bind: '{ "@vn" : name }' }).toArray();
assertEqual(result.length, 1);
assertEqual(result[0], 12);
});
if (healing.place === 2) { healFailure(healing); }
if (failure.place === 3) { makeFailure(failure); }
var ids = c.insert([{Hallo:13}, {Hallo:14}]);
assertEqual(3, c.count());
assertEqual(2, ids.length);
viewOperations("assert", null, function assert() {
var result = viewOperations("query", { query: "FOR d IN @@vn RETURN d", bind: '{ "@vn" : name }' }).toArray();
assertEqual(result.length, 3);
});
if (healing.place === 3) { healFailure(healing); }
if (failure.place === 4) { makeFailure(failure); }
var docs = c.document([ids[0]._key, ids[1]._key]);
assertEqual(2, docs.length);
assertEqual(13, docs[0].Hallo);
assertEqual(14, docs[1].Hallo);
viewOperations("assert", null, function assert(inFilter = ids) {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d._key IN ["
+ inFilter.map(e => "'" + e._key + "'").join(",")
+ "] SORT d._key RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(2, result.length);
assertEqual(13, result[0].Hallo);
assertEqual(14, result[1].Hallo);
});
if (healing.place === 4) { healFailure(healing); }
if (failure.place === 5) { makeFailure(failure); }
// Replace with check:
c.replace(id._key, {"Hallo": 100});
if (healing.place === 5) { healFailure(healing); }
if (failure.place === 6) { makeFailure(failure); }
doc = c.document(id._key);
assertEqual(100, doc.Hallo);
viewOperations("assert", null, function assert(inFilter = id._key) {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d._key == '" + `${inFilter}` + "' RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(1, result.length);
assertEqual(100, result[0].Hallo);
});
if (healing.place === 6) { healFailure(healing); }
if (failure.place === 7) { makeFailure(failure); }
c.replace([ids[0]._key, ids[1]._key], [{Hallo:101}, {Hallo:102}]);
if (healing.place === 7) { healFailure(healing); }
if (failure.place === 8) { makeFailure(failure); }
docs = c.document([ids[0]._key, ids[1]._key]);
assertEqual(2, docs.length);
assertEqual(101, docs[0].Hallo);
assertEqual(102, docs[1].Hallo);
viewOperations("assert", null, function assert(inFilter = ids) {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d._key IN ["
+ inFilter.map(e => "'" + e._key + "'").join(",")
+ "] SORT d._key RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(2, result.length);
assertEqual(101, result[0].Hallo);
assertEqual(102, result[1].Hallo);
});
if (healing.place === 8) { healFailure(healing); }
if (failure.place === 9) { makeFailure(failure); }
// Update with check:
c.update(id._key, {"Hallox": 105});
if (healing.place === 9) { healFailure(healing); }
if (failure.place === 10) { makeFailure(failure); }
doc = c.document(id._key);
assertEqual(100, doc.Hallo);
assertEqual(105, doc.Hallox);
viewOperations("assert", null, function assert(inFilter = id._key) {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d._key == '" + `${inFilter}` + "' RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(1, result.length);
assertEqual(100, result[0].Hallo);
assertEqual(105, result[0].Hallox);
});
if (healing.place === 10) { healFailure(healing); }
if (failure.place === 11) { makeFailure(failure); }
c.update([ids[0]._key, ids[1]._key], [{Hallox:106}, {Hallox:107}]);
if (healing.place === 11) { healFailure(healing); }
if (failure.place === 12) { makeFailure(failure); }
docs = c.document([ids[0]._key, ids[1]._key]);
assertEqual(2, docs.length);
assertEqual(101, docs[0].Hallo);
assertEqual(102, docs[1].Hallo);
assertEqual(106, docs[0].Hallox);
assertEqual(107, docs[1].Hallox);
viewOperations("assert", null, function assert(inFilter = ids) {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d._key IN ["
+ inFilter.map(e => "'" + e._key + "'").join(",")
+ "] SORT d._key RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(2, result.length);
assertEqual(101, result[0].Hallo);
assertEqual(102, result[1].Hallo);
assertEqual(106, result[0].Hallox);
assertEqual(107, result[1].Hallox);
});
if (healing.place === 12) { healFailure(healing); }
if (failure.place === 13) { makeFailure(failure); }
// AQL:
var q = db._query(`FOR x IN @@cn
FILTER x.Hallo > 0
SORT x.Hallo
RETURN {"Hallo": x.Hallo}`, {"@cn": cn});
docs = q.toArray();
assertEqual(3, docs.length);
assertEqual([{Hallo:100}, {Hallo:101}, {Hallo:102}], docs);
viewOperations("assert", null, function assert() {
var result = viewOperations("query", { query: "FOR d IN @@vn SEARCH d.Hallo > 0 SORT d.Hallo RETURN {'Hallo': d.Hallo}",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(3, result.length);
assertEqual([{Hallo:100}, {Hallo:101}, {Hallo:102}], result);
});
if (healing.place === 13) { healFailure(healing); }
if (failure.place === 14) { makeFailure(failure); }
// Remove with check:
c.remove(id._key);
if (healing.place === 14) { healFailure(healing); }
if (failure.place === 15) { makeFailure(failure); }
try {
doc = c.document(id._key);
fail();
}
catch (e1) {
assertEqual(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code, e1.errorNum);
}
if (healing.place === 15) { healFailure(healing); }
if (failure.place === 16) { makeFailure(failure); }
assertEqual(2, c.count());
viewOperations("assert", null, function assert(doc = id._key) {
var result = viewOperations("query", { query: "FOR d IN @@vn RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(2, result.length);
assertEqual(undefined, result.find(e => e._key === doc));
});
if (healing.place === 16) { healFailure(healing); }
if (failure.place === 17) { makeFailure(failure); }
c.remove([ids[0]._key, ids[1]._key]);
if (healing.place === 17) { healFailure(healing); }
if (failure.place === 18) { makeFailure(failure); }
docs = c.document([ids[0]._key, ids[1]._key]);
assertEqual(2, docs.length);
assertTrue(docs[0].error);
assertTrue(docs[1].error);
viewOperations("assert", null, function assert(doc = id._key) {
var result = viewOperations("query", { query: "FOR d IN @@vn RETURN d",
bind: '{ "@vn" : name }' }).toArray();
assertEqual(0, result.length);
});
if (healing.place === 18) { healFailure(healing); }
}
///////////////////////////////////////////////////////////////////////////////
/// @brief view operations:
////////////////////////////////////////////////////////////////////////////////
function viewOperations(type, options = null, exec = null) {
// check if arangosearch views are supported and could be used
// FIXME: remove useView check after issue #2900 of planning is fixed
if (useView === true && db._views() !== 0) {
var name = (typeof options !== "undefined" && options != null && options.hasOwnProperty("name")) ? options.name : "vn";
var checkArgument = (parameter, argument = null, type = "object") => {
if (type === "object") {
return (typeof parameter === type && parameter != null && parameter.hasOwnProperty(argument) && parameter[argument] !== null);
}
if (type === "function") {
return (typeof parameter === "function" && parameter.name === argument);
}
return false;
};
switch(type) {
case "drop":
try {
return db._view(name).drop();
} catch (ignored) { }
break;
case "create":
let view = db._createView(name, "arangosearch", {});
if (checkArgument(options, "properties")) {
view.properties(options.properties);
}
return view;
break;
case "query":
if (checkArgument(options, "query")) {
if (checkArgument(options, "bind")) {
var binded;
eval("binded = " + options.bind );
return db._query(options.query, binded, { waitForSync: true });
} else {
return db._query(options.query, null, { waitForSync: true });
}
} else {
return null;
}
break;
case "assert":
if (checkArgument(exec, "assert", "function")) {
exec();
} else {
fail();
}
break;
}
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief the actual tests
////////////////////////////////////////////////////////////////////////////////
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
setUp : function () {
var systemCollServers = findCollectionServers("_system", "_graphs");
console.info("System collections use servers:", systemCollServers);
while (true) {
db._drop(cn);
c = db._create(cn, {numberOfShards: 1, replicationFactor: 2,
avoidServers: systemCollServers});
viewOperations("drop");//try { db._view("vn1").drop(); } catch(ignore) { }
viewOperations("create", { properties: { links: { [cn]: { includeAllFields: true } } } });
var servers = findCollectionServers("_system", cn);
console.info("Test collections uses servers:", servers);
if (_.intersection(systemCollServers, servers).length === 0) {
return;
}
console.info("Need to recreate collection to avoid system collection servers.");
//waitForSynchronousReplication("_system");
console.info("Synchronous replication has settled, now dropping again.");
}
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
tearDown : function () {
db._drop(cn);
viewOperations("drop");
//global.ArangoAgency.set('Target/FailedServers', {});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief check inquiry functionality
////////////////////////////////////////////////////////////////////////////////
testInquiry : function () {
console.warn("Checking inquiry");
var writeResult = global.ArangoAgency.write(
[[{"a":1},{"a":{"oldEmpty":true}},"INTEGRATION_TEST_INQUIRY_ERROR_503"]]);
console.log(
"Inquired successfully a matched precondition under 503 response from write");
assertTrue(typeof writeResult === "object");
assertTrue(writeResult !== null);
assertTrue("results" in writeResult);
assertTrue(writeResult.results[0]>0);
try {
writeResult = global.ArangoAgency.write(
[[{"a":1},{"a":0},"INTEGRATION_TEST_INQUIRY_ERROR_503"]]);
fail();
} catch (e1) {
console.log(
"Inquired successfully a failed precondition under 503 response from write");
}
writeResult = global.ArangoAgency.write(
[[{"a":1},{"a":1},"INTEGRATION_TEST_INQUIRY_ERROR_0"]]);
console.log(
"Inquired successfully a matched precondition under 0 response from write");
try {
writeResult = global.ArangoAgency.write(
[[{"a":1},{"a":0},"INTEGRATION_TEST_INQUIRY_ERROR_0"]]);
fail();
} catch (e1) {
console.log(
"Inquired successfully a failed precondition under 0 response from write");
}
},
////////////////////////////////////////////////////////////////////////////////
/// @brief check whether we have access to global.instanceInfo
////////////////////////////////////////////////////////////////////////////////
testCheckInstanceInfo : function () {
assertTrue(global.instanceInfo !== undefined);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief check if a synchronously replicated collection gets online
////////////////////////////////////////////////////////////////////////////////
testSetup : function () {
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief run a standard check without failures:
////////////////////////////////////////////////////////////////////////////////
testBasicOperations : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({}, {});
},
////////////////////////////////////////////////////////////////////////////////
/// @brief run a standard check with failures:
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFailureFollower : function () {
assertTrue(waitForSynchronousReplication("_system"));
failFollower();
runBasicOperations({}, {});
healFollower();
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 1
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail1 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:1, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 2
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail2 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:2, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 3
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail3 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:3, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 4
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail4 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:4, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 5
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail5 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:5, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 6
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail6 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:6, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 7
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail7 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:7, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 8
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail8 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:8, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 9
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail9 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:9, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 10
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail10 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:10, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 11
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail11 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:11, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 12
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail12 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:12, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 13
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail13 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:13, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 14
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail14 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:14, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 15
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail15 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:15, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 16
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail16 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:16, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 17
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail17 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:17, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail in place 18
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFollowerFail18 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:18, follower:true}, {place:18, follower:true});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief run a standard check with failures:
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsFailureLeader : function () {
assertTrue(waitForSynchronousReplication("_system"));
failLeader();
runBasicOperations({}, {});
healLeader();
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 1
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail1 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:1, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 2
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail2 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:2, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 3
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail3 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:3, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 4
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail4 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:4, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 5
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail5 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:5, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 6
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail6 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:6, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 7
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail7 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:7, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 8
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail8 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:8, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 9
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail9 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:9, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 10
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail10 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:10, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 11
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail11 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:11, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 12
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail12 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:12, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 13
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail13 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:13, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 14
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail14 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:14, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 15
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail15 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:15, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 16
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail16 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:16, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 17
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail17 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:17, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief fail leader in place 18
////////////////////////////////////////////////////////////////////////////////
testBasicOperationsLeaderFail18 : function () {
assertTrue(waitForSynchronousReplication("_system"));
runBasicOperations({place:18, follower: false},
{place:18, follower: false});
assertTrue(waitForSynchronousReplication("_system"));
},
///////////////////////////////////////////////////////////////////////////////
/// @brief just to allow a trailing comma at the end of the last test
////////////////////////////////////////////////////////////////////////////////
testDummy : function () {
assertEqual(12, 12);
}
};
}
////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////
jsunity.run(SynchronousReplicationWithViewSuite);
return jsunity.done();