1
0
Fork 0

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

This commit is contained in:
jsteemann 2017-04-26 10:19:29 +02:00
commit 46da4b938f
2 changed files with 153 additions and 6 deletions

View File

@ -805,6 +805,58 @@ describe('Cluster sync', function() {
db._useDatabase('test');
expect(db._collection('s100001').isLeader()).to.equal(true);
});
it('should kill any unplanned server from current', function() {
let collection = db._create('s100001');
collection.assumeLeadership();
collection.addFollower('test');
collection.addFollower('test2');
let plan = {
test: {
"100001": {
"deleted": false,
"doCompact": true,
"id": "100001",
"indexBuckets": 8,
"indexes": [
{
"fields": [
"_key"
],
"id": "0",
"sparse": false,
"type": "primary",
"unique": true
}
],
"isSystem": false,
"isVolatile": false,
"journalSize": 1048576,
"keyOptions": {
"allowUserKeys": true,
"type": "traditional"
},
"name": "testi",
"numberOfShards": 1,
"replicationFactor": 2,
"shardKeys": [
"_key"
],
"shards": {
"s100001": [
"repltest",
"test2",
]
},
"status": 2,
"type": 2,
"waitForSync": false
}
}
};
cluster.executePlanForCollections(plan);
db._useDatabase('test');
expect(collection.getFollowers()).to.deep.equal(['test2']);
});
});
describe('Update current database', function() {
beforeEach(function() {
@ -972,7 +1024,7 @@ describe('Cluster sync', function() {
let collection = db._create('testi', props);
let current = {
};
let result = cluster.updateCurrentForCollections({}, current);
let result = cluster.updateCurrentForCollections({}, {}, current);
expect(Object.keys(result)).to.have.lengthOf(0);
});
it('should not delete any collections for which we are not a leader locally', function() {
@ -983,7 +1035,7 @@ describe('Cluster sync', function() {
},
}
};
let result = cluster.updateCurrentForCollections({}, current);
let result = cluster.updateCurrentForCollections({}, {}, current);
expect(Object.keys(result)).to.have.lengthOf(0);
});
it('should resign leadership for which we are no more leader locally', function() {
@ -996,7 +1048,7 @@ describe('Cluster sync', function() {
},
}
};
let result = cluster.updateCurrentForCollections({}, current);
let result = cluster.updateCurrentForCollections({}, {}, current);
expect(result).to.be.an('object');
expect(Object.keys(result)).to.have.lengthOf(1);
expect(result).to.have.property('/arango/Current/Collections/testung/888111/testi/servers')
@ -1016,7 +1068,7 @@ describe('Cluster sync', function() {
},
}
};
let result = cluster.updateCurrentForCollections({}, current);
let result = cluster.updateCurrentForCollections({}, {}, current);
expect(result).to.be.an('object');
expect(Object.keys(result)).to.have.lengthOf(1);
expect(result).to.have.property('/arango/Current/Collections/testung/888111/testi')
@ -1033,7 +1085,7 @@ describe('Cluster sync', function() {
},
}
};
let result = cluster.updateCurrentForCollections({}, current);
let result = cluster.updateCurrentForCollections({}, {}, current);
expect(result).to.be.an('object');
expect(Object.keys(result)).to.have.lengthOf(1);
expect(result).to.have.property('/arango/Current/Collections/testung/888111/testi')
@ -1051,7 +1103,7 @@ describe('Cluster sync', function() {
},
}
};
let result = cluster.updateCurrentForCollections({}, current);
let result = cluster.updateCurrentForCollections({}, {}, current);
expect(result).to.be.an('object');
expect(Object.keys(result)).to.have.lengthOf(1);
expect(result).to.have.property('/arango/Current/Collections/testung/888111/testi')

View File

@ -0,0 +1,95 @@
/*jshint globalstrict:false, strict:false */
/*global fail, assertEqual */
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2017 ArangoDB GmbH, Cologne, Germany
/// Copyright 2010-2017 triagens 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 Max Neunhoeffer
////////////////////////////////////////////////////////////////////////////////
var jsunity = require("jsunity");
var arangodb = require("@arangodb");
var errors = require("internal").errors;
var db = arangodb.db;
function DistributeShardsLikeSuite() {
'use strict';
var cn1 = "UnitTestsDistributeShardsLike1";
var cn2 = "UnitTestsDistributeShardsLike2";
var cn3 = "UnitTestsDistributeShardsLike3";
return {
setUp: function() {
db._drop(cn2);
db._drop(cn3);
db._drop(cn1);
},
tearDown: function() {
db._drop(cn2);
db._drop(cn3);
db._drop(cn1);
},
testPointToEmpty: function() {
try {
db._create(cn1, {numberOfShards: 2, distributeShardsLike: cn2});
fail();
}
catch (err) {
require("internal").print("FUXX:", JSON.stringify(err));
assertEqual(errors.ERROR_CLUSTER_UNKNOWN_DISTRIBUTESHARDSLIKE.code,
err.errorNum);
}
},
testAvoidChain: function() {
db._create(cn1, {numberOfShards: 2});
db._create(cn2, {numberOfShards: 2, distributeShardsLike: cn1});
try {
db._create(cn3, {numberOfShards: 2, distributeShardsLike: cn2});
fail();
}
catch (err) {
assertEqual(errors.ERROR_CLUSTER_CHAIN_OF_DISTRIBUTESHARDSLIKE.code,
err.errorNum);
}
},
testPreventDrop: function() {
db._create(cn1, {numberOfShards: 2});
db._create(cn2, {numberOfShards: 2, distributeShardsLike: cn1});
db._create(cn3, {numberOfShards: 2, distributeShardsLike: cn1});
try {
db._drop(cn1);
fail();
}
catch (err) {
assertEqual(errors.ERROR_CLUSTER_MUST_NOT_DROP_COLL_OTHER_DISTRIBUTESHARDSLIKE.code,
err.errorNum);
}
}
};
}
jsunity.run(DistributeShardsLikeSuite);
return jsunity.done();