Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qa-588: add vector index test #46

Merged
merged 6 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test_data/checkdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ let {
mainTestLoop
} = require(fs.join(PWD, 'common'));

const {
assertTrue,
assertFalse,
assertEqual
} = require("jsunity").jsUnity.assertions;

const {
createAnalyzerSet,
checkAnalyzerSet,
Expand Down
6 changes: 6 additions & 0 deletions test_data/cleardata.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ let {
mainTestLoop
} = require(fs.join(PWD, 'common'));

const {
assertTrue,
assertFalse,
assertEqual
} = require("jsunity").jsUnity.assertions;

const {
createAnalyzerSet,
checkAnalyzerSet,
Expand Down
7 changes: 7 additions & 0 deletions test_data/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ function makeRandomDoc() {
}
return {
Type: makeRandomNumber(1000, 65535),
TypeVec: [
makeRandomNumber(1000, 65535),
makeRandomNumber(1000, 65535),
makeRandomNumber(1000, 65535),
makeRandomNumber(1000, 65535),
makeRandomNumber(1000, 65535),
],
ID: makeRandomString(40),
OptOut: rand() > 0 ? 1 : 0,
Source: makeRandomString(14),
Expand Down
6 changes: 6 additions & 0 deletions test_data/makedata.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ let {
resetRCount,
} = require(fs.join(PWD, 'common'));

const {
assertTrue,
assertFalse,
assertEqual
} = require("jsunity").jsUnity.assertions;

const {
createAnalyzerSet,
checkAnalyzerSet,
Expand Down
8 changes: 1 addition & 7 deletions test_data/makedata_suites/070_foxx.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
/* global print, fs, db, internal, arango, assertTrue */
/* global print, fs, db, internal, arango, assertTrue, assertEqual, assertFalse */

// inspired by shell-foxx-api-spec.js

const utils = require('@arangodb/foxx/manager-utils');
const download = internal.download;
const path = require('path');

const {
assertTrue,
assertFalse,
assertEqual
} = require("jsunity").jsUnity.assertions;

function loadFoxxIntoZip (path) {
let zip = utils.zipDirectory(path);
let content = fs.readFileSync(zip);
Expand Down
89 changes: 89 additions & 0 deletions test_data/makedata_suites/107_vector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/* global print, db, progress, createCollectionSafe, createIndexSafe, time, runAqlQueryResultCount, aql, semver, resetRCount, writeData */

(function () {
return {
isSupported: function (currentVersion, oldVersion, options, enterprise, cluster) {
let currentVersionSemver = semver.parse(semver.coerce(currentVersion));
let oldVersionSemver = semver.parse(semver.coerce(oldVersion));
return semver.gt(oldVersionSemver, "3.12.4");
},
makeDataDB: function (options, isCluster, isEnterprise, database, dbCount) {
progress('107: createCollection');
let c_vector = createCollectionSafe(`c_vector_${dbCount}`, 3, 2);
progress('107: createIndexHash');
},
makeData: function (options, isCluster, isEnterprise, dbCount, loopCount) {
progress(`107: Makedata ${dbCount} ${loopCount}`);
let c_vector = db[`c_vector_${dbCount}`];

// Now the actual data writing:
resetRCount();
writeData(c_vector, 1000);
if (c_vector.indexes().length === 1) {
createIndexSafe({
col: c_vector,
name: `i_vector_dbcount`,
type: "vector",
fields: ["TypeVec"],
inBackground: false,
params: {
metric: "l2",
dimension: 5,
nLists: 1
},
});
}
progress('107: writeData1');
},
checkDataDB: function (options, isCluster, isEnterprise, database, dbCount, readOnly) {
print(`${Date()} 107: checking data ${dbCount}`);
let cols = db._collections();
let allFound = true;
[`c_vector_${dbCount}`].forEach(colname => {
let foundOne = false;
cols.forEach(oneCol => {
if (oneCol.name() === colname) {
foundOne = true;
}
});
if (!foundOne) {
print(`${Date()} 107: Didn't find this collection: ${colname}`);
allFound = false;
}
});
if (!allFound) {
throw new Error("107: not all collections were present on the system!");
}

let c_vector = db._collection(`c_vector_${dbCount}`);

// Check indexes:
progress("107: checking indices");

if (c_vector.getIndexes().length !== 2 || c_vector.getIndexes()[1].type !== "vector") {
throw new Error(`Banana ${c_vector.getIndexes().length} `);
}

// Check data:
progress("107: checking data");
if (c_vector.count() !== 1000 * options.dataMultiplier) { throw new Error(`Audi ${c_vector.count()} !== 1000`); }

// Check a few queries:
progress("107: query 1");
runAqlQueryResultCount(aql`
FOR d IN ${c_vector}
SORT APPROX_NEAR_L2(d.TypeVec, [1,2,3,4,5], {nProbe: 5})
LIMIT 5 RETURN d`, 5);
progress("107: queries done");
progress("107: done");
},
clearData: function (options, isCluster, isEnterprise, dbCount, loopCount, readOnly) {
print(`${Date()} 107: clearing data ${dbCount} ${loopCount}`);
progress("107: drop 1");
try {
db._drop(`c_vector_${loopCount}`);
} catch (ex) {}
progress("107: drop done");
}
};
}());