Skip to content

Commit 64d2c20

Browse files
authored
re-use vector collection, cleanup (#65)
1 parent 2c0c88d commit 64d2c20

File tree

1 file changed

+53
-46
lines changed

1 file changed

+53
-46
lines changed

simple/test.js

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
"use strict";
2+
/* jshint globalstrict:false, strict:false, maxlen: 500 */
3+
/* global GLOBAL, makeGraph, makeTree */
4+
25
const internal = require("internal");
36
const arango = internal.arango;
47
const AsciiTable = require("ascii-table");
58
const fs = require("fs");
69
const semver = require("semver");
710
const _ = require("lodash");
811
const db = require("org/arangodb").db;
9-
require("internal").load("simple/BIGvertices.js");
12+
require("internal").load("simple/BIGvertices.js");// makeGraph, makeTree
1013

1114
GLOBAL.returnValue = 0;
1215

@@ -19,8 +22,8 @@ function sum (values) {
1922
}
2023
}
2124

22-
function randomNumberGeneratorFloat(seed) {
23-
const rng = (function* (seed) {
25+
function randomNumberGeneratorFloat (seed) {
26+
const rng = (function *(seed) {
2427
while (true) {
2528
const nextVal = Math.cos(seed++);
2629
yield nextVal;
@@ -200,6 +203,10 @@ exports.test = function (testParams) {
200203
let results = [];
201204
const runs = options.runs > 0 ? options.runs : 1;
202205

206+
if (typeof options.setupAll === "function") {
207+
let params = buildParams(test, collection);
208+
options.setup(params);
209+
}
203210
for (let i = 0; i < runs + 1; ++i) {
204211
let params = buildParams(test, collection);
205212
if (typeof options.setup === "function") {
@@ -238,12 +245,12 @@ exports.test = function (testParams) {
238245
let test = tests[i];
239246
print(test);
240247
try {
241-
if (!(test['version'] === undefined || semver.satisfies(serverVersion, test['version']))) {
242-
print(`skipping test ${test['name']}, requires version ${test['version']}`);
243-
} else if (test['legacy'] && !testParams.legacy) {
244-
print(`skipping legacy test ${test['name']}`);
248+
if (!(test["version"] === undefined || semver.satisfies(serverVersion, test["version"]))) {
249+
print(`skipping test ${test["name"]}, requires version ${test["version"]}`);
250+
} else if (test["legacy"] && !testParams.legacy) {
251+
print(`skipping legacy test ${test["name"]}`);
245252
} else {
246-
print(`running test ${test['name']}`);
253+
print(`running test ${test["name"]}`);
247254
for (let j = 0; j < options.collections.length; ++j) {
248255
let collection = options.collections[j];
249256

@@ -253,7 +260,7 @@ exports.test = function (testParams) {
253260
const stats = calc(results, options);
254261

255262
const result = {
256-
name: test['name'],
263+
name: test["name"],
257264
runs: options.runs,
258265
min: stats.min.toFixed(options.digits),
259266
max: stats.max.toFixed(options.digits),
@@ -275,8 +282,8 @@ exports.test = function (testParams) {
275282
} // for j
276283
}
277284
} catch (ex) {
278-
print(`exception in test ${test['name']}: ${String(ex)}\n${String(ex.stack)}`);
279-
errors.push({ name: test['name'], error: ex });
285+
print(`exception in test ${test["name"]}: ${String(ex)}\n${String(ex.stack)}`);
286+
errors.push({ name: test["name"], error: ex });
280287
GLOBAL.returnValue = 1;
281288
}
282289
} // for i
@@ -860,15 +867,15 @@ exports.test = function (testParams) {
860867
}
861868
}
862869
},
863-
870+
864871
// /////////////////////////////////////////////////////////////////////////////
865872
// indexes tests
866873
// /////////////////////////////////////////////////////////////////////////////
867874

868875
insertIndexOne = function (params) {
869876
let c = db._collection(params.collection),
870877
n = parseInt(params.collection.replace(/[a-z]+/g, ""), 10);
871-
878+
872879
// perform small batch document operations
873880
const batchSize = params.batchSize || 100;
874881
let docs = [];
@@ -890,11 +897,11 @@ exports.test = function (testParams) {
890897
}
891898
}
892899
},
893-
900+
894901
insertIndexTwo = function (params) {
895902
let c = db._collection(params.collection),
896903
n = parseInt(params.collection.replace(/[a-z]+/g, ""), 10);
897-
904+
898905
// perform small batch document operations
899906
const batchSize = params.batchSize || 100;
900907
let docs = [];
@@ -1024,7 +1031,7 @@ exports.test = function (testParams) {
10241031
// edgeTests
10251032
// /////////////////////////////////////////////////////////////////////////////
10261033

1027-
traversalProjections = function(params) {
1034+
traversalProjections = function (params) {
10281035
// Note that depth 8 is good for all three sizes small (6), medium (7)
10291036
// and big (8). Depending on the size, we create a different tree.
10301037
db._query(`FOR v IN 0..8 OUTBOUND "TreeV/S1:K1" GRAPH "Tree" RETURN v.data`, {}, {}, {silent});
@@ -2412,7 +2419,7 @@ exports.test = function (testParams) {
24122419
setup: function (params) {
24132420
drop(params);
24142421
create(params);
2415-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
2422+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
24162423
},
24172424
type: "number",
24182425
teardown: drop
@@ -2425,7 +2432,7 @@ exports.test = function (testParams) {
24252432
setup: function (params) {
24262433
drop(params);
24272434
create(params);
2428-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
2435+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
24292436
},
24302437
type: "number",
24312438
teardown: drop
@@ -2438,7 +2445,7 @@ exports.test = function (testParams) {
24382445
setup: function (params) {
24392446
drop(params);
24402447
create(params);
2441-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
2448+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
24422449
},
24432450
type: "string",
24442451
teardown: drop
@@ -2451,7 +2458,7 @@ exports.test = function (testParams) {
24512458
setup: function (params) {
24522459
drop(params);
24532460
create(params);
2454-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
2461+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
24552462
},
24562463
type: "string",
24572464
teardown: drop
@@ -2464,8 +2471,8 @@ exports.test = function (testParams) {
24642471
setup: function (params) {
24652472
drop(params);
24662473
create(params);
2467-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
2468-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"] });
2474+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
2475+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"] });
24692476
},
24702477
type: "number",
24712478
teardown: drop
@@ -2478,8 +2485,8 @@ exports.test = function (testParams) {
24782485
setup: function (params) {
24792486
drop(params);
24802487
create(params);
2481-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
2482-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"], estimates: false });
2488+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
2489+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"], estimates: false });
24832490
},
24842491
type: "number",
24852492
teardown: drop
@@ -2492,8 +2499,8 @@ exports.test = function (testParams) {
24922499
setup: function (params) {
24932500
drop(params);
24942501
create(params);
2495-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
2496-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"] });
2502+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
2503+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"] });
24972504
},
24982505
type: "string",
24992506
teardown: drop
@@ -2506,13 +2513,13 @@ exports.test = function (testParams) {
25062513
setup: function (params) {
25072514
drop(params);
25082515
create(params);
2509-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
2510-
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"], estimates: false });
2516+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
2517+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"], estimates: false });
25112518
},
25122519
type: "string",
25132520
teardown: drop
25142521
}
2515-
},
2522+
}
25162523
];
25172524

25182525
// Tests without collections/IO, to focus on aql block performance.
@@ -2571,7 +2578,7 @@ exports.test = function (testParams) {
25712578
{
25722579
name: "traversal-projections",
25732580
params: { func: traversalProjections }
2574-
},
2581+
},
25752582
{
25762583
name: "traversal-outbound-1",
25772584
params: { func: outbound, minDepth: 1, maxDepth: 1, loops: 1000 }
@@ -3298,7 +3305,7 @@ exports.test = function (testParams) {
32983305
}
32993306
db._query(
33003307
params.queryString,
3301-
bindParam,
3308+
bindParam
33023309
);
33033310
}
33043311

@@ -3352,33 +3359,33 @@ exports.test = function (testParams) {
33523359
FILTER d.x == 9 and d.y >= 52
33533360
RETURN d`
33543361
}
3355-
},
3362+
}
33563363
];
33573364

3358-
function vectorTest (params) {
3365+
function vectorTest (params) {
33593366
let bindParam = { "@col": params.collection, "qp": params.extras.queryPoint };
33603367
if ("bindParamModifier" in params) {
33613368
params.bindParamModifier(params, bindParam);
33623369
}
33633370
db._query(
33643371
params.queryString,
3365-
bindParam,
3372+
bindParam
33663373
);
33673374
}
33683375

3369-
function vectorTestNoParams (params) {
3376+
function vectorTestNoParams (params) {
33703377
let bindParam = { "@col": params.collection };
33713378
if ("bindParamModifier" in params) {
33723379
params.bindParamModifier(params, bindParam);
33733380
}
33743381
db._query(
33753382
params.queryString,
3376-
bindParam,
3383+
bindParam
33773384
);
33783385
}
33793386

33803387
let VectorTests = [
3381-
{
3388+
{
33823389
name: "aql-vector-top-k",
33833390
params: {
33843391
func: vectorTest,
@@ -3388,8 +3395,8 @@ exports.test = function (testParams) {
33883395
LIMIT 5
33893396
RETURN d`
33903397
}
3391-
},
3392-
{
3398+
},
3399+
{
33933400
name: "aql-vector-subquery-10-points",
33943401
params: {
33953402
func: vectorTestNoParams,
@@ -3405,7 +3412,7 @@ exports.test = function (testParams) {
34053412
)
34063413
RETURN {doc: docOuter._key, neibhours: neibhours}`
34073414
}
3408-
},
3415+
}
34093416
];
34103417

34113418
const runSatelliteGraphTests = (testParams.satelliteGraphTests && isEnterprise && isCluster);
@@ -3489,7 +3496,7 @@ exports.test = function (testParams) {
34893496
setup: function (params) {
34903497
db._drop(params.collection);
34913498
let col = db._create(params.collection);
3492-
let type = (testParams.zkdMdiRenamed) ? "mdi":"zkd";
3499+
let type = (testParams.zkdMdiRenamed) ? "mdi" : "zkd";
34933500
col.ensureIndex({type: type, name: "mdiIndex", fields: ["x", "y"], fieldValueTypes: "double"});
34943501
db._query(`
34953502
FOR i IN 0..${params.collectionSize}
@@ -3521,11 +3528,11 @@ exports.test = function (testParams) {
35213528
const dimension = 500;
35223529
let gen = randomNumberGeneratorFloat(3243758343);
35233530
let randomPoint = Array.from({ length: dimension }, () => gen());
3524-
3531+
35253532
options = {
35263533
runs: testParams.runs,
35273534
digits: testParams.digits,
3528-
setup: function (params) {
3535+
setupAll: function (params) {
35293536
db._drop(params.collection);
35303537
let col = db._create(params.collection);
35313538

@@ -3540,7 +3547,7 @@ exports.test = function (testParams) {
35403547
if (i * batchSize + j === 2000) {
35413548
randomPoint = vector;
35423549
}
3543-
docs.push({_key: "test_" + (j + i* batchSize), vector: vector });
3550+
docs.push({_key: "test_" + (j + i * batchSize), vector: vector });
35443551
}
35453552
col.insert(docs);
35463553
}
@@ -3552,7 +3559,7 @@ exports.test = function (testParams) {
35523559
type: "vector",
35533560
fields: ["vector"],
35543561
inBackground: false,
3555-
params: { metric: "l2", dimension: dimension, nLists: params.extras.nLists },
3562+
params: { metric: "l2", dimension: dimension, nLists: params.extras.nLists }
35563563
});
35573564
print("Vector index created: " + JSON.stringify(col.indexes()));
35583565
},
@@ -3726,7 +3733,7 @@ exports.test = function (testParams) {
37263733

37273734
runTestSuite("Arango Search No Materialization", arangosearchNoMaterializationTests, options);
37283735
}
3729-
3736+
37303737
// indexes tests
37313738
if (testParams.indexes) {
37323739
options = {

0 commit comments

Comments
 (0)