Skip to content

Commit

Permalink
chore(scripts): add support for running ai accuracy tests vs local mms (
Browse files Browse the repository at this point in the history
  • Loading branch information
Anemy authored Oct 10, 2023
1 parent 8d97006 commit b57b250
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions scripts/ai-accuracy-tests/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
'use strict';
// To run these tests locally:
// To run these tests against cloud-dev:
// > ATLAS_PUBLIC_KEY="..." \
// ATLAS_PRIVATE_KEY="..." \
// AI_TESTS_ATTEMPTS_PER_TEST=100 \
// node scripts/ai-accuracy-tests/index.js

// To run these tests with local mms:
// First create an API key in your Atlas organization with
// the permissions "Organization Member".
// Then using that key run:
// > ATLAS_PUBLIC_KEY="..." \
// ATLAS_PRIVATE_KEY="..." \
// AI_TESTS_BACKEND=atlas-local \
// node scripts/ai-accuracy-tests/index.js

const { MongoCluster } = require('mongodb-runner');
const fs = require('fs').promises;
const os = require('os');
Expand Down Expand Up @@ -32,12 +41,12 @@ const USE_SAMPLE_DOCS = process.env.AI_TESTS_USE_SAMPLE_DOCS === 'true';

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

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

const fetch = (() => {
if (BACKEND === 'atlas-dev') {
if (BACKEND === 'atlas-dev' || BACKEND === 'atlas-local') {
const ATLAS_PUBLIC_KEY = process.env.ATLAS_PUBLIC_KEY;
const ATLAS_PRIVATE_KEY = process.env.ATLAS_PRIVATE_KEY;

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

let httpErrors = 0;
Expand Down

0 comments on commit b57b250

Please sign in to comment.