8000 added test for addOperation returning an error (#14410) · arangodb/arangodb@0a0cfcb · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a0cfcb

Browse files
authored
added test for addOperation returning an error (#14410)
1 parent dcb5581 commit 0a0cfcb

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

arangod/RocksDBEngine/RocksDBTransactionState.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,10 @@ void RocksDBTransactionState::rollbackOperation(TRI_voc_document_operation_e ope
543543
Result RocksDBTransactionState::addOperation(DataSourceId cid, RevisionId revisionId,
544544
TRI_voc_document_operation_e operationType,
545545
bool& hasPerformedIntermediateCommit) {
546+
TRI_IF_FAILURE("addOperationSizeError") {
547+
return Result(TRI_ERROR_RESOURCE_LIMIT);
548+
}
549+
546550
size_t currentSize = _rocksTransaction->GetWriteBatch()->GetWriteBatch()->GetDataSize();
547551
if (currentSize > _options.maxTransactionSize) {
548552
// we hit the transaction size limit

tests/js/server/shell/shell-collection-failures-noncluster.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,27 @@ function DocumentOperationsFailuresSuite() {
4848
internal.debugClearFailAt();
4949
db._drop(cn);
5050
},
51+
52+
testInsertSizeLimit: function () {
53+
let c = db._create(cn);
54+
55+
internal.debugSetFailAt("addOperationSizeError");
56+
57+
try {
58+
c.insert({ _key: "testi" });
59+
fail();
60+
} catch (e) {
61+
// Validate that we died with debug
62+
assertEqual(e.errorNum, ERRORS.ERROR_RESOURCE_LIMIT.code);
63+
}
64+
65+
assertEqual(0, c.count());
66+
67+
internal.debugClearFailAt();
68+
69+
c.insert({ _key: "testi" });
70+
assertEqual(1, c.count());
71+
},
5172

5273
testInsertFailure1: function () {
5374
let c = db._create(cn);
@@ -91,6 +112,28 @@ function DocumentOperationsFailuresSuite() {
91112
assertEqual(1, c.count());
92113
},
93114

115+
testRemoveSizeLimit: function () {
116+
let c = db._create(cn);
117+
c.insert({ _key: "testi" });
118+
119+
internal.debugSetFailAt("addOperationSizeError");
120+
121+
try {
122+
c.remove("testi");
123+
fail();
124+
} catch (e) {
125+
// Validate that we died with debug
126+
assertEqual(e.errorNum, ERRORS.ERROR_RESOURCE_LIMIT.code);
127+
}
128+
129+
assertEqual(1, c.count());
130+
131+
internal.debugClearFailAt();
132+
133+
c.remove("testi");
134+
assertEqual(0, c.count());
135+
},
136+
94137
testRemoveFailure1: function () {
95138
let c = db._create(cn);
96139
c.insert({ _key: "testi" });
@@ -135,6 +178,30 @@ function DocumentOperationsFailuresSuite() {
135178
assertEqual(0, c.count());
136179
},
137180

181+
testModifySizeLimit: function () {
182+
let c = db._create(cn);
183+
c.insert({ _key: "testi", value: 1 });
184+
185+
internal.debugSetFailAt("addOperationSizeError");
186+
187+
try {
188+
c.update("testi", { value: 2 });
189+
fail();
190+
} catch (e) {
191+
// Validate that we died with debug
192+
assertEqual(e.errorNum, ERRORS.ERROR_RESOURCE_LIMIT.code);
193+
}
194+
195+
assertEqual(1, c.count());
196+
assertEqual(1, c.document("testi").value);
197+
198+
internal.debugClearFailAt();
199+
200+
c.update("testi", { value: 3 });
201+
assertEqual(1, c.count());
202+
assertEqual(3, c.document("testi").value);
203+
},
204+
138205
testModifyFailure1: function () {
139206
let c = db._create(cn);
140207
c.insert({ _key: "testi", value: 1 });

0 commit comments

Comments
 (0)
0