1
0
Fork 0

add some more intermediate commit tests (#7416)

This commit is contained in:
Jan 2018-11-22 15:29:27 +01:00 committed by GitHub
parent a21a197cad
commit e1e0f62647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 91 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*jshint globalstrict:false, strict:false */
/*global assertEqual, assertTrue, assertEqual, assertTypeOf, assertNotEqual, fail, assertFalse */
/*global assertEqual, assertTrue, assertNull, fail, assertFalse */
////////////////////////////////////////////////////////////////////////////////
/// @brief test the collection interface
@ -294,12 +294,102 @@ function CollectionTruncateFailuresSuite() {
};
}
function IntermediateCommitFailureSuite() {
'use strict';
const cn = "UnitTestsIntermediate";
let c;
const cleanUp = () => {
internal.debugClearFailAt();
try {
db._drop(cn);
} catch(_) { }
};
const docs = [];
for (let i = 0; i < 10000; ++i) {
docs.push({value: i % 250, value2: i % 100});
}
return {
tearDown: cleanUp,
setUp: function () {
cleanUp();
c = db._create(cn);
c.insert(docs);
},
testFailOnRemoveAql: function () {
internal.debugSetFailAt("FailBeforeIntermediateCommit");
try {
db._query("FOR doc IN @@cn REMOVE doc IN @@cn", { "@cn" : cn }, { intermediateCommitCount: 10000 });
fail();
} catch (e) {
// Validate that we died with debug
assertEqual(e.errorNum, ERRORS.ERROR_DEBUG.code);
}
assertEqual(c.count(), 10000);
assertEqual(c.toArray().length, 10000);
},
testFailOnUpdateAql: function () {
internal.debugSetFailAt("FailBeforeIntermediateCommit");
try {
db._query("FOR doc IN @@cn UPDATE doc WITH { aha: 1 } IN @@cn", { "@cn" : cn }, { intermediateCommitCount: 10000 });
fail();
} catch (e) {
// Validate that we died with debug
assertEqual(e.errorNum, ERRORS.ERROR_DEBUG.code);
}
assertEqual(c.count(), 10000);
assertEqual(c.toArray().length, 10000);
assertNull(c.firstExample({ aha: 1 }));
},
testFailOnReplaceAql: function () {
internal.debugSetFailAt("FailBeforeIntermediateCommit");
try {
db._query("FOR doc IN @@cn REPLACE doc WITH { aha: 1 } IN @@cn", { "@cn" : cn }, { intermediateCommitCount: 10000 });
fail();
} catch (e) {
// Validate that we died with debug
assertEqual(e.errorNum, ERRORS.ERROR_DEBUG.code);
}
assertEqual(c.count(), 10000);
assertEqual(c.toArray().length, 10000);
assertNull(c.firstExample({ aha: 1 }));
},
testFailOnInsertAql: function () {
internal.debugSetFailAt("FailBeforeIntermediateCommit");
try {
db._query("FOR i IN 1..10000 INSERT {} IN @@cn", { "@cn" : cn }, { intermediateCommitCount: 10000 });
fail();
} catch (e) {
// Validate that we died with debug
assertEqual(e.errorNum, ERRORS.ERROR_DEBUG.code);
}
assertEqual(c.count(), 10000);
assertEqual(c.toArray().length, 10000);
},
};
}
////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suites
////////////////////////////////////////////////////////////////////////////////
if (internal.debugCanUseFailAt()) {
jsunity.run(CollectionTruncateFailuresSuite);
jsunity.run(IntermediateCommitFailureSuite);
}
return jsunity.done();