8000 attempt to fix unstable test (#17932) · cloudhub-js/arangodb@9c6b1d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c6b1d8

Browse files
authored
attempt to fix unstable test (arangodb#17932)
* fix unstable test === server_parameters === * Test "server_parameters" [FAILED] tests/js/client/server_parameters/auto-refill-index-caches-on-modify-noncluster-on.js "testUpdateEdgeDisbled" failed: Error: at assertion arangodb#5003: { "writesExecuted" : 0, "writesIgnored" : 0, "scannedFull" : 0, "scannedIndex" : 5000, "cursorsCreated" : 1, "cursorsRearmed" : 4999, "cacheHits" : 1147, "cacheMisses" : 3853, "filtered" : 0, "httpRequests" : 0, "executionTime" : 0.02600592700036941, "peakMemoryUsage" : 98304 }: (1147) is not equal to (0) (Error at assertEqual (/work/ArangoDB/js/common/modules/jsunity/jsunity.js:108:19) at runCheck (tests/js/client/server_parameters/auto-refill-index-caches-on-modify-noncluster-on.js:64:7) at Object.testUpdateEdgeDisbled (tests/js/client/server_parameters/auto-refill-index-caches-on-modify-noncluster-on.js:151:7) at Object.run (/work/ArangoDB/js/common/modules/jsunity/jsunity.js:552:27)
1 parent ad71715 commit 9c6b1d8

File tree

2 files changed

+104
-52
lines changed

2 files changed

+104
-52
lines changed

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

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,20 @@ const time = require('internal').time;
4242
const cn = 'UnitTestsCollection';
4343
const n = 5000;
4444

45-
const waitForMetrics = () => {
46-
// wait for metrics to settle, using an informal API
45+
const waitForPendingRefills = () => {
46+
// wait for pending refill operations to have finished, using an informal API
4747
arango.POST('/_api/index/sync-caches', {});
4848
};
4949

5050
function AutoRefillIndexCachesEdge() {
5151
'use strict';
5252

5353
let runCheck = (expectHits) => {
54+
// need to wait here for all pending index cache refill ops to finish.
55+
// if we wouldn't wait here, there would be a race between the refill background
56+
// thread and the query executed here.
57+
waitForPendingRefills();
58+
5459
let crsr = db._query(`FOR i IN 0..${n - 1} FOR doc IN ${cn} FILTER doc._from == CONCAT('v/test', i) RETURN doc._from`);
5560
let res = crsr.toArray();
5661
assertEqual(n, res.length);
@@ -79,6 +84,11 @@ function AutoRefillIndexCachesEdge() {
7984
};
8085

8186
let runRemoveCheck = (expectHits) => {
87+
// need to wait here for all pending index cache refill ops to finish.
88+
// if we wouldn't wait here, there would be a race between the refill background
89+
// thread and the query executed here.
90+
waitForPendingRefills();
91+
8292
let crsr = db._query(`FOR i IN 0..${n - 1} FOR doc IN ${cn} FILTER doc._from == CONCAT('v/test', i) RETURN doc._from`);
8393
let res = crsr.toArray();
8494
assertTrue(res.length > 0, res.length);
@@ -95,6 +105,10 @@ function AutoRefillIndexCachesEdge() {
95105
assertTrue(stats.cacheHits > 0, stats);
96106
}
97107
};
108+
109+
let insertInitialEdges = () => {
110+
db._query(`FOR i IN 0..${n - 1} INSERT {_key: CONCAT('test', i), _from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn} OPTIONS { refillIndexCaches: false }`);
111+
};
98112

99113
return {
100114
setUp: function() {
@@ -133,12 +147,12 @@ function AutoRefillIndexCachesEdge() {
133147
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
134148

135149
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
136-
waitForMetrics();
137150
runCheck(true);
138151
},
139152

140153
testUpdateEdgeDefault: function() {
141-
db._query(`FOR i IN 0..${n - 1} INSERT {_from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn}`);
154+
insertInitialEdges();
155+
142156
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
143157
db._query(`FOR doc IN ${cn} UPDATE doc WITH {value: doc.value + 1} INTO ${cn}`);
144158
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
@@ -150,7 +164,8 @@ function AutoRefillIndexCachesEdge() {
150164
},
151165

152166
testUpdateEdgeDisabled: function() {
153-
db._query(`FOR i IN 0..${n - 1} INSERT {_from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn}`);
167+
insertInitialEdges();
168+
154169
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
155170
db._query(`FOR doc IN ${cn} UPDATE doc WITH {value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: false }`);
156171
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
@@ -162,18 +177,19 @@ function AutoRefillIndexCachesEdge() {
162177
},
163178

164179
testUpdateEdgeEnabled: function() {
165-
db._query(`FOR i IN 0..${n - 1} INSERT {_from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn}`);
180+
insertInitialEdges();
181+
166182
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
167183
db._query(`FOR doc IN ${cn} UPDATE doc WITH {value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
168184
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
169185

170186
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
171-
waitForMetrics( B41A );
172187
runCheck(true);
173188
},
174189

175190
testReplaceEdgeDefault: function() {
176-
db._query(`FOR i IN 0..${n - 1} INSERT {_from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn}`);
191+
insertInitialEdges();
192+
177193
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
178194
db._query(`FOR doc IN ${cn} REPLACE doc WITH {_from: doc._from, _to: doc._to, value: doc.value + 1} INTO ${cn}`);
179195
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
@@ -185,7 +201,8 @@ function AutoRefillIndexCachesEdge() {
185201
},
186202

187203
testReplaceEdgeDisabled: function() {
188-
db._query(`FOR i IN 0..${n - 1} INSERT {_from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn}`);
204+
insertInitialEdges();
205+
189206
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
190207
db._query(`FOR doc IN ${cn} REPLACE doc WITH {_from: doc._from, _to: doc._to, value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: false }`);
191208
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
@@ -197,18 +214,19 @@ function AutoRefillIndexCachesEdge() {
197214
},
198215

199216
testReplaceEdgeEnabled: function() {
200-
db._query(`FOR i IN 0..${n - 1} INSERT {_from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn}`);
217+
insertInitialEdges();
218+
201219
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
202220
db._query(`FOR doc IN ${cn} REPLACE doc WITH {_from: doc._from, _to: doc._to, value: doc.value + 1} INTO ${cn} OPTIONS { refillIndexCaches: true }`);
203221
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
204222

205223
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
206-
waitForMetrics();
207224
runCheck(true);
208225
},
209226

210227
testRemoveEdgeDefault: function() {
211-
db._query(`FOR i IN 0..${n - 1} INSERT {_key: CONCAT('test', i), _from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn}`);
228+
insertInitialEdges();
229+
212230
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
213231
db._query(`FOR i IN 0..${n / 2 - 1} REMOVE CONCAT('test', i) INTO ${cn}`);
214232
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
@@ -220,7 +238,8 @@ function AutoRefillIndexCachesEdge() {
220238
},
221239

222240
testRemoveEdgeDisabled: function() {
223-
db._query(`FOR i IN 0..${n - 1} INSERT {_key: CONCAT('test', i), _from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn}`);
241+
insertInitialEdges();
242+
224243
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
225244
db._query(`FOR i IN 0..${n / 2 - 1} REMOVE CONCAT('test', i) INTO ${cn} OPTIONS { refillIndexCaches: false }`);
226245
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
@@ -232,13 +251,13 @@ function AutoRefillIndexCachesEdge() {
232251
},
233252

234253
testRemoveEdgeEnabled: function() {
235-
db._query(`FOR i IN 0..${n - 1} INSERT {_key: CONCAT('test', i), _from: CONCAT('v/test', i), _to: CONCAT('v/test', (i % 25))} INTO ${cn}`);
254+
insertInitialEdges();
255+
236256
const oldValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
237257
db._query(`FOR i IN 0..${n / 2 - 1} REMOVE CONCAT('test', i) INTO ${cn} OPTIONS { refillIndexCaches: true }`);
238258
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
239259

240260
assertTrue(newValue - oldValue >= n / 2, { oldValue, newValue });
241-
waitForMetrics();
242261
runRemoveCheck(true);
243262
},
244263

@@ -313,7 +332,7 @@ function AutoRefillIndexCachesVPack() {
313332
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
314333

315334
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
316-
waitForMetrics();
335+
waitForPendingRefills();
317336
runCheck(0, true);
318337
},
319338

@@ -326,7 +345,7 @@ function AutoRefillIndexCachesVPack() {
326345
// 10 here because there may be background operations running that
327346
// could affect the metrics
328347
assertTrue(newValue - oldValue <= 10, { oldValue, newValue });
329-
waitForMetrics();
348+
waitForPendingRefills();
330349
runCheck(1, false);
331350
},
332351

@@ -339,7 +358,7 @@ function AutoRefillIndexCachesVPack() {
339358
// 10 here because there may be background operations running that
340359
// could affect the metrics
341360
assertTrue(newValue - oldValue <= 10, { oldValue, newValue });
342-
waitForMetrics();
361+
waitForPendingRefills();
343362
runCheck(1, false);
344363
},
345364

@@ -350,7 +369,7 @@ function AutoRefillIndexCachesVPack() {
350369
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
351370

352371
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
353-
waitForMetrics();
372+
waitForPendingRefills();
354373
runCheck(1, true);
355374
},
356375

@@ -385,7 +404,7 @@ function AutoRefillIndexCachesVPack() {
385404
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
386405

387406
assertTrue(newValue - oldValue >= n, { oldValue, newValue });
388-
waitForMetrics();
407+
waitForPendingRefills();
389408
runCheck(1, true);
390409
},
391410

@@ -420,7 +439,7 @@ function AutoRefillIndexCachesVPack() {
420439
const newValue = getMetric("rocksdb_cache_auto_refill_loaded_total");
421440

422441
assertTrue(newValue - oldValue >= n / 2, { oldValue, newValue });
423-
waitForMetrics();
442+
waitForPendingRefills();
424443
runRemoveCheck(true);
425444
},
426445

0 commit comments

Comments
 (0)
0