mirror of https://gitee.com/bigwinds/arangodb
Add test for rolling back indexes
This commit is contained in:
parent
11cf6ed5c6
commit
41f8185553
|
@ -1654,6 +1654,7 @@ int ClusterInfo::ensureIndexCoordinator(
|
|||
AgencyCommResult eraseResult = _agency.sendTransactionWithFailover(trx, 0.0);
|
||||
|
||||
if (eraseResult.successful()) {
|
||||
loadPlan();
|
||||
return errorCode;
|
||||
}
|
||||
std::chrono::duration<size_t, std::milli> waitTime(10);
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*global describe, it, ArangoAgency, afterEach */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief cluster collection creation tests
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 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 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Andreas Streichardt
|
||||
/// @author Copyright 2017, ArangoDB GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
'use strict';
|
||||
|
||||
const expect = require('chai').expect;
|
||||
|
||||
var internal = require("internal");
|
||||
var db = require("org/arangodb").db;
|
||||
|
||||
describe('Cluster collection creation options', function() {
|
||||
afterEach(function() {
|
||||
db._drop('testi');
|
||||
});
|
||||
it('should always throw an error when creating a faulty index', function() {
|
||||
db._create("testi", {numberOfShards: 1});
|
||||
db.testi.save({"test": 1});
|
||||
db.testi.save({"test": 1});
|
||||
|
||||
expect(function() {
|
||||
db.testi.ensureIndex({ type: "hash", fields: [ "test" ], unique: true });
|
||||
}).to.throw();
|
||||
// before fixing it the second call would return the faulty index
|
||||
expect(function() {
|
||||
db.testi.ensureIndex({ type: "hash", fields: [ "test" ], unique: true });
|
||||
}).to.throw();
|
||||
});
|
||||
it('should cleanup current after creating a faulty index', function() {
|
||||
db._create("testi", {numberOfShards: 1});
|
||||
let current = ArangoAgency.get('Current/Collections/_system');
|
||||
let plan = ArangoAgency.get('Plan/Collections/_system');
|
||||
let collectionId = Object.values(plan.arango.Plan.Collections['_system']).reduce((result, collectionDef) => {
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (collectionDef.name === 'testi') {
|
||||
return collectionDef.id;
|
||||
}
|
||||
}, undefined);
|
||||
db.testi.save({"test": 1});
|
||||
db.testi.save({"test": 1});
|
||||
|
||||
expect(function() {
|
||||
db.testi.ensureIndex({ type: "hash", fields: [ "test" ], unique: true });
|
||||
}).to.throw();
|
||||
// wait for the schmutz
|
||||
internal.wait(1.0);
|
||||
current = ArangoAgency.get('Current/Collections/_system/' + collectionId);
|
||||
Object.values(current.arango.Current.Collections['_system'][collectionId]).forEach(entry => {
|
||||
expect(entry.indexes).to.have.lengthOf(1);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue