Skip to content
Closed
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
21 changes: 21 additions & 0 deletions .evergreen/buildvariants-and-tasks.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ buildvariants:
<% } %>
<% } %>

- name: test-web-sandbox-atlas-cloud
display_name: Test Web Sandbox (w/ Atlas Cloud login)
run_on: ubuntu2004-large
tasks:
- name: test-web-sandbox-atlas-cloud

- name: generate-vulnerability-report
display_name: Vulnerability Report
run_on: ubuntu2004-large
Expand Down Expand Up @@ -504,6 +510,21 @@ tasks:
<% } %>
<% } %>

- name: test-web-sandbox-atlas-cloud
tags:
- required-for-publish
- run-on-pr
- assigned_to_jira_team_compass_compass
- foliage_check_task_only
commands:
- func: prepare
- func: install
- func: bootstrap
- func: test-web-sandbox-atlas-cloud
vars:
compass_distribution: compass
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'

- name: create_static_analysis_report
tags: ['required-for-publish', 'run-on-pr']
depends_on:
Expand Down
19 changes: 19 additions & 0 deletions .evergreen/buildvariants-and-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ buildvariants:
- name: test-web-sandbox-firefox-1
- name: test-web-sandbox-firefox-2
- name: test-web-sandbox-firefox-3
- name: test-web-sandbox-atlas-cloud
display_name: Test Web Sandbox (w/ Atlas Cloud login)
run_on: ubuntu2004-large
tasks:
- name: test-web-sandbox-atlas-cloud
- name: generate-vulnerability-report
display_name: Vulnerability Report
run_on: ubuntu2004-large
Expand Down Expand Up @@ -1715,6 +1720,20 @@ tasks:
e2e_test_groups: 3
e2e_test_group: 3
debug: compass-e2e-tests*,electron*,hadron*,mongo*
- name: test-web-sandbox-atlas-cloud
tags:
- required-for-publish
- run-on-pr
- assigned_to_jira_team_compass_compass
- foliage_check_task_only
commands:
- func: prepare
- func: install
- func: bootstrap
- func: test-web-sandbox-atlas-cloud
vars:
compass_distribution: compass
debug: compass-e2e-tests*,electron*,hadron*,mongo*
- name: create_static_analysis_report
tags:
- required-for-publish
Expand Down
33 changes: 33 additions & 0 deletions .evergreen/create-atlas-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

export E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME="test-cluster-$(date +"%s")"

function atlascli() {
docker run \
-e MCLI_PUBLIC_API_KEY="$MCLI_PUBLIC_API_KEY" \
-e MCLI_PRIVATE_API_KEY="$MCLI_PRIVATE_API_KEY" \
-e MCLI_ORG_ID="$MCLI_ORG_ID" \
-e MCLI_PROJECT_ID="$MCLI_PROJECT_ID" \
-e MCLI_OPS_MANAGER_URL="$MCLI_OPS_MANAGER_URL" \
mongodb/atlas atlas $@
}

cleanup() {
echo "Scheduling Atlas deployment \`$E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME\` for deletion..."
atlascli clusters delete $E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME --force
}

trap cleanup EXIT

echo "Creating Atlas deployment \`$E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME\` to test against..."
atlascli clusters create $E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME \
--provider AWS \
--region US_EAST_1 \
--tier M10

echo "Waiting for the deployment to be provisioned..."
atlascli clusters watch "$E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME"

echo "Getting connection string for provisioned cluster..."
export E2E_ATLAS_CLOUD_TEST_CLUSTER_CONNECTION_STRING_JSON="$(atlascli clusters connectionStrings describe $E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME -o json)"
echo "Cluster connection string: $E2E_ATLAS_CLOUD_TEST_CLUSTER_CONNECTION_STRING_JSON"
31 changes: 31 additions & 0 deletions .evergreen/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,37 @@ functions:
eval $(.evergreen/print-compass-env.sh)
npm run --unsafe-perm --workspace compass-e2e-tests test-web

test-web-sandbox-atlas-cloud:
- command: shell.exec
# It can take a very long time for Atlas cluster to get deployed
timeout_secs: 2400
params:
working_dir: src
shell: bash
env:
<<: *compass-env
DEBUG: ${debug|}
BROWSER_NAME: chrome
MONGODB_VERSION: latest-enterprise
MONGODB_RUNNER_VERSION: latest-enterprise
E2E_TESTS_COMPASS_WEB_ATLAS_DB_USERNAME: ${e2e_tests_compass_web_atlas_db_username}
E2E_TESTS_COMPASS_WEB_ATLAS_USERNAME: ${e2e_tests_compass_web_atlas_username}
E2E_TESTS_COMPASS_WEB_ATLAS_PASSWORD: ${e2e_tests_compass_web_atlas_password}
MCLI_PUBLIC_API_KEY: ${e2e_tests_mcli_public_api_key}
MCLI_PRIVATE_API_KEY: ${e2e_tests_mcli_private_api_key}
MCLI_ORG_ID: ${e2e_tests_mcli_org_id}
MCLI_PROJECT_ID: ${e2e_tests_mcli_project_id}
MCLI_OPS_MANAGER_URL: ${e2e_tests_mcli_ops_manager_url}
script: |
set -e
# Load environment variables
eval $(.evergreen/print-compass-env.sh)
# Create Atlas cluster for test project
source .evergreen/create-atlas-cluster.sh
# Run the tests
echo "Starting e2e tests..."
npm run --unsafe-perm --workspace compass-e2e-tests test -- --test-compass-web-atlas-cloud

test-connectivity:
- command: shell.exec
# Fail the task if it's idle for 10 mins
Expand Down
5 changes: 4 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
"package-compass": "npm run package-compass --workspace=mongodb-compass --",
"package-compass-debug": "npm run package-compass-debug --workspace=mongodb-compass --",
"package-compass-nocompile": "npm run package-compass-nocompile --workspace=mongodb-compass --",
"prestart": "npm run compile --workspace=@mongodb-js/webpack-config-compass",
"prestart-web": "npm run prestart",
"start": "npm run start --workspace=mongodb-compass",
"start-web": "npm run start --workspace=@mongodb-js/compass-web",
"test": "lerna run test --concurrency 1 --stream",
Expand Down
5 changes: 5 additions & 0 deletions packages/compass-e2e-tests/helpers/commands/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
DEFAULT_CONNECTION_NAME_1,
DEFAULT_CONNECTION_NAME_2,
DEFAULT_CONNECTION_STRING_1,
TEST_COMPASS_WEB_ATLAS_CLOUD,
TEST_MULTIPLE_CONNECTIONS,
connectionNameFromString,
} from '../compass';
Expand Down Expand Up @@ -53,6 +54,10 @@ export async function connectWithConnectionString(
connectionString = DEFAULT_CONNECTION_STRING_1,
options: ConnectOptions = {}
): Promise<void> {
if (TEST_COMPASS_WEB_ATLAS_CLOUD) {
return connectByName(browser, connectionString);
}

// Use this command when you need to add a new connection with a specific
// connection string. Most test files should just be using
// browser.connectToDefaults()
Expand Down
41 changes: 34 additions & 7 deletions packages/compass-e2e-tests/helpers/compass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { rebuild } from '@electron/rebuild';
import type { RebuildOptions } from '@electron/rebuild';
import type { ConsoleMessageType } from 'puppeteer';
import { run as packageCompass } from 'hadron-build/commands/release';
import { redactConnectionString } from 'mongodb-connection-string-url';
import {
redactConnectionString,
ConnectionString,
} from 'mongodb-connection-string-url';
import { getConnectionTitle } from '@mongodb-js/connection-info';
export * as Selectors from './selectors';
export * as Commands from './commands';
Expand Down Expand Up @@ -45,7 +48,11 @@ let MONGODB_USE_ENTERPRISE =
(process.env.MONGODB_VERSION?.endsWith('-enterprise') && 'yes') ?? 'no';

// should we test compass-web (true) or compass electron (false)?
export const TEST_COMPASS_WEB = process.argv.includes('--test-compass-web');
export const TEST_COMPASS_WEB_ATLAS_CLOUD = process.argv.includes(
'--test-compass-web-atlas-cloud'
);
export const TEST_COMPASS_WEB =
process.argv.includes('--test-compass-web') || TEST_COMPASS_WEB_ATLAS_CLOUD;
// multiple connections is now the default
export const TEST_MULTIPLE_CONNECTIONS = true;

Expand All @@ -56,10 +63,13 @@ in a scannable manner. It is not being output at present because the tests will
be logged as pending anyway.
*/
export function skipForWeb(
test: Mocha.Runnable | Mocha.Context,
test: Mocha.Context,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
reason: string
) {
if (test?.currentTest?.title) {
test.currentTest.title += ` - skipped with reason: ${reason}`;
}
if (TEST_COMPASS_WEB) {
test.skip();
}
Expand All @@ -75,12 +85,29 @@ export const MONGODB_TEST_SERVER_PORT = Number(
process.env.MONGODB_TEST_SERVER_PORT ?? 27091
);

export const DEFAULT_CONNECTION_STRING_1 = `mongodb://127.0.0.1:${MONGODB_TEST_SERVER_PORT}/test`;
function getAtlasConnectionStringFromEnv() {
const connectionStringJSONString =
process.env.E2E_ATLAS_CLOUD_TEST_CLUSTER_CONNECTION_STRING_JSON;
if (!connectionStringJSONString) {
return undefined;
}
const { standardSrv } = JSON.parse(connectionStringJSONString);
const mongodbConnectionString = new ConnectionString(standardSrv);
mongodbConnectionString.username =
process.env.E2E_TESTS_COMPASS_WEB_ATLAS_DB_USERNAME!;
mongodbConnectionString.password =
process.env.E2E_TESTS_COMPASS_WEB_ATLAS_PASSWORD!;
return mongodbConnectionString.toString();
}

export const DEFAULT_CONNECTION_STRING_1 =
getAtlasConnectionStringFromEnv() ??
`mongodb://127.0.0.1:${MONGODB_TEST_SERVER_PORT}/test`;
// NOTE: in browser.setupDefaultConnections() we don't give the first connection an
// explicit name, so it gets a calculated one based off the connection string
export const DEFAULT_CONNECTION_NAME_1 = connectionNameFromString(
DEFAULT_CONNECTION_STRING_1
);
export const DEFAULT_CONNECTION_NAME_1 =
process.env.E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME ??
connectionNameFromString(DEFAULT_CONNECTION_STRING_1);

// for testing multiple connections
export const DEFAULT_CONNECTION_STRING_2 = `mongodb://127.0.0.1:${
Expand Down
Loading
Loading