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

chore(scripts): add support for running ai accuracy tests vs local mms #4973

Merged
merged 1 commit into from
Oct 10, 2023
Merged
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
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