8000 fix failing test, next attempt (#17960) · cloudhub-js/arangodb@949f01c · GitHub
[go: up one dir, main page]

Skip to content

Commit 949f01c

Browse files
authored
fix failing test, next attempt (arangodb#17960)
1 parent 809183f commit 949f01c

File tree

2 files changed

+187
-104
lines changed

2 files changed

+187
-104
lines changed

tests/js/client/server_parameters/auto-refill-index-caches-on-modify-noncluster-off.js

Lines changed: 96 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ if (getOptions === true) {
3737
const db = require('@arangodb').db;
3838
const jsunity = require('jsunity');
3939
const getMetric = require('@arangodb/test-helper').getMetricSingle;
40-
const time = require('internal').time;
4140

4241
const cn = 'UnitTestsCollection';
4342
const n = 5000;
@@ -46,6 +45,31 @@ const waitForPendingRefills = () => {
4645
// wait for pending refill operations to have finished, using an informal API
4746
arango.POST('/_api/index/sync-caches', {});
4847
};
48+
49+
const runWithRetry = (cb) => {
50+
let tries = 0;
51+
while (true) {
52+
try {
53+
cb();
54+
// return upon first successful execution of the callback function
55+
return;
56+
} catch (err) {
57+
// if it fails, check how many failures we got. fail only if we failed
58+
// 3 times in a row
59+
if (tries++ === 3) {
60+
throw err;
61+
}
62+
// attempt failed. this can happen because inserting data into
63+
// the cache can fail under the following circumstances:
64+
// - cache global budget exceeded
65+
// - cache hash table migration in progress
66+
67+
// start over...
68+
db[cn].truncate();
69+
require("internal").sleep(2);
70+
}
71+
}
72+
};
4973

5074
function AutoRefillIndexCachesEdge() {
5175
'use strict';
@@ -142,12 +166,14 @@ function AutoRefillIndexCachesEdge() {
142166
},
143167

144168
testInsertEdgeEnabled: function() {
145-
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
146-
db._query(`FOR i IN 0..${n - 1} INSERT {_from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
147-
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
148-
149-
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
150-
runCheck(true);
169+
runWithRetry(() => {
170+
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
171+
db._query(`FOR i IN 0..${n - 1} INSERT {_from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
172+
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
173+
174+
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
175+
runCheck(true);
176+
});
151177
},
152178

153179
testUpdateEdgeDefault: function() {
@@ -177,14 +203,16 @@ function AutoRefillIndexCachesEdge() {
177203
},
178204

179205
testUpdateEdgeEnabled: function() {
180-
insertInitialEdges();
206+
runWithRetry(() => {
207+
insertInitialEdges();
181208

182-
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
183-
db._query(`FOR doc IN ${cn} UPDATE doc WITH {value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
184-
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
209+
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
210+
db._query(`FOR doc IN ${cn} UPDATE doc WITH {value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
211+
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
185212

186-
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
187-
runCheck(true);
213+
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
214+
runCheck(true);
215+
});
188216
},
189217

190218
testReplaceEdgeDefault: function() {
@@ -214,14 +242,16 @@ function AutoRefillIndexCachesEdge() {
214242
},
215243

216244
testReplaceEdgeEnabled: function() {
217-
insertInitialEdges();
245+
runWithRetry(() => {
246+
insertInitialEdges();
218247

219-
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
220-
db._query(`FOR doc IN ${cn} REPLACE doc WITH {_from: doc._from, _to: doc._to, value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
221-
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
248+
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
249+
db._query(`FOR doc IN ${cn} REPLACE doc WITH {_from: doc._from, _to: doc._to, value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
250+
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
222251

223-
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
224-
runCheck(true);
252+
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
253+
runCheck(true);
254+
});
225255
},
226256

227257
testRemoveEdgeDefault: function() {
@@ -251,14 +281,16 @@ function AutoRefillIndexCachesEdge() {
251281
},
252282

253283
testRemoveEdgeEnabled: function() {
254-
insertInitialEdges();
284+
runWithRetry(() => {
285+
insertInitialEdges();
255286

256-
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
257-
db._query(`FOR i IN 0..${n / 2 - 1} REMOVE CONCAT('test', i) INTO ${cn} OPTIONS { refillIndexCaches: true }`);
258-
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
287+
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
288+
db._query(`FOR i IN 0..${n / 2 - 1} REMOVE CONCAT('test', i) INTO ${cn} OPTIONS { refillIndexCaches: true }`);
289+
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
259290

260-
assertTrue(newValue - oldValue >= n / 2, { oldValue, newValue });
261-
runRemoveCheck(true);
291+
assertTrue(newValue - oldValue >= n / 2, { oldValue, newValue });
292+
runRemoveCheck(true);
293+
});
262294
},
263295

264296
};
@@ -327,13 +359,15 @@ function AutoRefillIndexCachesVPack() {
327359
},
328360

329361
testInsertVPackEnabled: function() {
330-
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
331-
db._query(`FOR i IN 0..${n - 1} INSERT {value: i} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
332-
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
333-
334-
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
335-
waitForPendingRefills();
336-
runCheck(0, true);
362+
runWithRetry(() => {
363+
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
364+
db._query(`FOR i IN 0..${n - 1} INSERT {value: i} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
365+
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
366+
367+
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
368+
waitForPendingRefills();
369+
runCheck(0, true);
370+
});
337371
},
338372

339373
testUpdateVPackDefault: function() {
@@ -363,14 +397,16 @@ function AutoRefillIndexCachesVPack() {
363397
},
364398

365399
testUpdateVPackEnabled: function() {
366-
db._query(`FOR i IN 0..${n - 1} INSERT {value: i} INTO ${cn}`);
367-
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
368-
db._query(`FOR doc IN ${cn} UPDATE doc WITH {value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
369-
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
370-
371-
assertTrue(newValue - oldValue >= n, { oldValue, newValue }< 10000 span class=pl-kos>);
372-
waitForPendingRefills();
373-
runCheck(1, true);
400+
runWithRetry(() => {
401+
db._query(`FOR i IN 0..${n - 1} INSERT {value: i} INTO ${cn}`);
402+
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
403+
db._query(`FOR doc IN ${cn} UPDATE doc WITH {value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
404+
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
405+
406+
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
407+
waitForPendingRefills();
408+
runCheck(1, true);
409+
});
374410
},
375411

376412
testReplaceVPackDefault: function() {
@@ -398,14 +434,16 @@ function AutoRefillIndexCachesVPack() {
398434
},
399435

400436
testReplaceVPackEnabled: function() {
401-
db._query(`FOR i IN 0..${n - 1} INSERT {value: i} INTO ${cn}`);
402-
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
403-
db._query(`FOR doc IN ${cn} REPLACE doc WITH {value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
404-
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
405-
406-
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
407-
waitForPendingRefills();
408-
runCheck(1, true);
437+
runWithRetry(() => {
438+
db._query(`FOR i IN 0..${n - 1} INSERT {value: i} INTO ${cn}`);
439+
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
440+
db._query(`FOR doc IN ${cn} REPLACE doc WITH {value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
441+
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
442+
443+
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
444+
waitForPendingRefills();
445+
runCheck(1, true);
446+
});
409447
},
410448

411449
testRemoveVPackDefault: function() {
@@ -433,14 +471,16 @@ function AutoRefillIndexCachesVPack() {
433471
},
434472

435473
testRemoveVPackEnabled: function() {
436-
db._query(`FOR i IN 0..${n - 1} INSERT {_key: CONCAT('test', i), value: i} INTO ${cn}`);
437-
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
438-
db._query(`FOR i IN 0..${n / 2 - 1} REMOVE CONCAT('test', i) INTO ${cn} OPTIONS { refillIndexCaches: true }`);
439-
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
440-
441-
assertTrue(newValue - oldValue >= n / 2, { oldValue, newValue });
442-
waitForPendingRefills();
443-
runRemoveCheck(true);
474+
runWithRetry(() => {
475+
db._query(`FOR i IN 0..${n - 1} INSERT {_key: CONCAT('test', i), value: i} INTO ${cn}`);
476+
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
477+
db._query(`FOR i IN 0..${n / 2 - 1} REMOVE CONCAT('test', i) INTO ${cn} OPTIONS { refillIndexCaches: true }`);
478+
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
479+
480+
assertTrue(newValue - oldValue >= n / 2, { oldValue, newValue });
481+
waitForPendingRefills();
482+
runRemoveCheck(true);
483+
});
444484
},
445485

446486
};

0 commit comments

Comments
 (0)
0