Skip to content

Commit 4f7524a

Browse files
authored
Ignore if we exeed the memory limits of the SUT (#22186)
1 parent 579a07a commit 4f7524a

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

js/common/modules/@arangodb/test-generators/subquery-chaos-test.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*jshint globalstrict:false, strict:false, maxlen: 500 */
2-
/*global assertEqual */
2+
/*global assertEqual, print */
33

44
// //////////////////////////////////////////////////////////////////////////////
55
// / DISCLAIMER
@@ -25,6 +25,8 @@
2525
// //////////////////////////////////////////////////////////////////////////////
2626
const db = require("@arangodb").db;
2727
const _ = require("lodash");
28+
const internal = require('internal');
29+
const errors = internal.errors;
2830
const {md5} = require("@arangodb/crypto");
2931
const arango = require("@arangodb").arango;
3032
const {randomNumberGeneratorInt} = require("@arangodb/testutils/seededRandom");
@@ -290,25 +292,32 @@ function runQuery(query, queryOptions, testOptions) {
290292
}
291293

292294
/* Run query */
293-
const result = db._createStatement({query: query.queryString, batchSize, options: queryOptions, ttl: 600})
294-
.execute();
295-
296-
if (testOptions.enableLogging) {
297-
arango.PUT("/_admin/log/level", { queries: oldLogLevel });
298-
}
299-
300-
/* Create a simple hash value from the query results, so that we don't have to
301-
* load the entire result set into memory and work with it */
302295
let hash = "";
303-
let count = 0;
304-
while (result.hasNext()) {
305-
let row = JSON.stringify(result.next());
306-
hash = md5(hash + row);
307-
// invoke cleanup
308-
count += 1;
309-
if (count % 5 === 0) {
310-
require("internal").wait(0, true);
296+
try {
297+
const result = db._createStatement({query: query.queryString, batchSize, options: queryOptions, ttl: 600})
298+
.execute();
299+
300+
if (testOptions.enableLogging) {
301+
arango.PUT("/_admin/log/level", { queries: oldLogLevel });
311302
}
303+
304+
/* Create a simple hash value from the query results, so that we don't have to
305+
* load the entire result set into memory and work with it */
306+
let count = 0;
307+
while (result.hasNext()) {
308+
let row = JSON.stringify(result.next());
309+
hash = md5(hash + row);
310+
// invoke cleanup
311+
count += 1;
312+
if (count % 5 === 0) {
313+
internal.wait(0, true);
314+
}
315+
}
316+
} catch (ex) {
317+
if (ex.errorNum !== errors.ERROR_RESOURCE_LIMIT) {
318+
throw ex;
319+
}
320+
print(`Ignoring ${ex.message}`);
312321
}
313322

314323
/* Cleanup */
@@ -327,7 +336,6 @@ function testQuery(query, testOptions) {
327336

328337
/* Run query with all optimizations */
329338
const result1 = runQuery(query, {batchSize}, testOptions);
330-
331339
/* Run query with full count */
332340
const result2 = runQuery(
333341
query,

0 commit comments

Comments
 (0)