Skip to content

Commit b57b250

Browse files
authored
chore(scripts): add support for running ai accuracy tests vs local mms (#4973)
1 parent 8d97006 commit b57b250

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

scripts/ai-accuracy-tests/index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
'use strict';
2-
// To run these tests locally:
2+
// To run these tests against cloud-dev:
33
// > ATLAS_PUBLIC_KEY="..." \
44
// ATLAS_PRIVATE_KEY="..." \
55
// AI_TESTS_ATTEMPTS_PER_TEST=100 \
66
// node scripts/ai-accuracy-tests/index.js
77

8+
// To run these tests with local mms:
9+
// First create an API key in your Atlas organization with
10+
// the permissions "Organization Member".
11+
// Then using that key run:
12+
// > ATLAS_PUBLIC_KEY="..." \
13+
// ATLAS_PRIVATE_KEY="..." \
14+
// AI_TESTS_BACKEND=atlas-local \
15+
// node scripts/ai-accuracy-tests/index.js
16+
817
const { MongoCluster } = require('mongodb-runner');
918
const fs = require('fs').promises;
1019
const os = require('os');
@@ -32,12 +41,12 @@ const USE_SAMPLE_DOCS = process.env.AI_TESTS_USE_SAMPLE_DOCS === 'true';
3241

3342
const BACKEND = process.env.AI_TESTS_BACKEND || 'atlas-dev';
3443

35-
if (!['atlas-dev', 'compass'].includes(BACKEND)) {
44+
if (!['atlas-dev', 'atlas-local', 'compass'].includes(BACKEND)) {
3645
throw new Error('Unknown backend');
3746
}
3847

3948
const fetch = (() => {
40-
if (BACKEND === 'atlas-dev') {
49+
if (BACKEND === 'atlas-dev' || BACKEND === 'atlas-local') {
4150
const ATLAS_PUBLIC_KEY = process.env.ATLAS_PUBLIC_KEY;
4251
const ATLAS_PRIVATE_KEY = process.env.ATLAS_PRIVATE_KEY;
4352

@@ -59,6 +68,8 @@ const backendBaseUrl =
5968
process.env.AI_TESTS_BACKEND_URL ||
6069
(BACKEND === 'atlas-dev'
6170
? 'https://cloud-dev.mongodb.com/api/private'
71+
: BACKEND === 'atlas-local'
72+
? 'http://localhost:8080/api/private'
6273
: 'http://localhost:8080');
6374

6475
let httpErrors = 0;

0 commit comments

Comments
 (0)