Skip to content

Commit c166c8a

Browse files
committed
tmp
1 parent d127c23 commit c166c8a

File tree

16 files changed

+310
-40
lines changed

16 files changed

+310
-40
lines changed

.evergreen/buildvariants-and-tasks.in.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ buildvariants:
275275
<% } %>
276276
<% } %>
277277

278+
- name: test-web-sandbox-atlas-cloud
279+
display_name: Test Web Sandbox (w/ Atlas Cloud login)
280+
run_on: ubuntu2004-large
281+
tasks:
282+
- name: test-web-sandbox-atlas-cloud
283+
278284
- name: generate-vulnerability-report
279285
display_name: Vulnerability Report
280286
run_on: ubuntu2004-large
@@ -504,6 +510,21 @@ tasks:
504510
<% } %>
505511
<% } %>
506512

513+
- name: test-web-sandbox-atlas-cloud
514+
tags:
515+
- required-for-publish
516+
- run-on-pr
517+
- assigned_to_jira_team_compass_compass
518+
- foliage_check_task_only
519+
commands:
520+
- func: prepare
521+
- func: install
522+
- func: bootstrap
523+
- func: test-web-sandbox-atlas-cloud
524+
vars:
525+
compass_distribution: compass
526+
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
527+
507528
- name: create_static_analysis_report
508529
tags: ['required-for-publish', 'run-on-pr']
509530
depends_on:

.evergreen/buildvariants-and-tasks.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ buildvariants:
257257
- name: test-web-sandbox-firefox-1
258258
- name: test-web-sandbox-firefox-2
259259
- name: test-web-sandbox-firefox-3
260+
- name: test-web-sandbox-atlas-cloud
261+
display_name: Test Web Sandbox (w/ Atlas Cloud login)
262+
run_on: ubuntu2004-large
263+
tasks:
264+
- name: test-web-sandbox-atlas-cloud
260265
- name: generate-vulnerability-report
261266
display_name: Vulnerability Report
262267
run_on: ubuntu2004-large
@@ -1715,6 +1720,20 @@ tasks:
17151720
e2e_test_groups: 3
17161721
e2e_test_group: 3
17171722
debug: compass-e2e-tests*,electron*,hadron*,mongo*
1723+
- name: test-web-sandbox-atlas-cloud
1724+
tags:
1725+
- required-for-publish
1726+
- run-on-pr
1727+
- assigned_to_jira_team_compass_compass
1728+
- foliage_check_task_only
1729+
commands:
1730+
- func: prepare
1731+
- func: install
1732+
- func: bootstrap
1733+
- func: test-web-sandbox-atlas-cloud
1734+
vars:
1735+
compass_distribution: compass
1736+
debug: compass-e2e-tests*,electron*,hadron*,mongo*
17181737
- name: create_static_analysis_report
17191738
tags:
17201739
- required-for-publish

.evergreen/create-atlas-cluster.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
export E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME="test-cluster-$(date +"%s")"
4+
5+
function atlascli() {
6+
docker run \
7+
-e MCLI_PUBLIC_API_KEY="$MCLI_PUBLIC_API_KEY" \
8+
-e MCLI_PRIVATE_API_KEY="$MCLI_PRIVATE_API_KEY" \
9+
-e MCLI_ORG_ID="$MCLI_ORG_ID" \
10+
-e MCLI_PROJECT_ID="$MCLI_PROJECT_ID" \
11+
-e MCLI_OPS_MANAGER_URL="$MCLI_OPS_MANAGER_URL" \
12+
mongodb/atlas atlas $@
13+
}
14+
15+
cleanup() {
16+
echo "Scheduling Atlas deployment \`$E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME\` for deletion..."
17+
atlascli clusters delete $E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME --force
18+
}
19+
20+
trap cleanup EXIT
21+
22+
echo "Creating Atlas deployment \`$E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME\` to test against..."
23+
atlascli clusters create $E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME \
24+
--provider AWS \
25+
--region US_EAST_1 \
26+
--tier M10
27+
28+
echo "Waiting for the deployment to be provisioned..."
29+
atlascli clusters watch "$E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME"
30+
31+
echo "Getting connection string for provisioned cluster..."
32+
export E2E_ATLAS_CLOUD_TEST_CLUSTER_CONNECTION_STRING_JSON="$(atlascli clusters connectionStrings describe $E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME -o json)"
33+
echo "Cluster connection string: $E2E_ATLAS_CLOUD_TEST_CLUSTER_CONNECTION_STRING_JSON"

.evergreen/functions.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,37 @@ functions:
673673
eval $(.evergreen/print-compass-env.sh)
674674
npm run --unsafe-perm --workspace compass-e2e-tests test-web
675675
676+
test-web-sandbox-atlas-cloud:
677+
- command: shell.exec
678+
# It can take a very long time for Atlas cluster to get deployed
679+
timeout_secs: 2400
680+
params:
681+
working_dir: src
682+
shell: bash
683+
env:
684+
<<: *compass-env
685+
DEBUG: ${debug|}
686+
BROWSER_NAME: chrome
687+
MONGODB_VERSION: latest-enterprise
688+
MONGODB_RUNNER_VERSION: latest-enterprise
689+
E2E_TESTS_COMPASS_WEB_ATLAS_DB_USERNAME: ${e2e_tests_compass_web_atlas_db_username}
690+
E2E_TESTS_COMPASS_WEB_ATLAS_USERNAME: ${e2e_tests_compass_web_atlas_username}
691+
E2E_TESTS_COMPASS_WEB_ATLAS_PASSWORD: ${e2e_tests_compass_web_atlas_password}
692+
MCLI_PUBLIC_API_KEY: ${e2e_tests_mcli_public_api_key}
693+
MCLI_PRIVATE_API_KEY: ${e2e_tests_mcli_private_api_key}
694+
MCLI_ORG_ID: ${e2e_tests_mcli_org_id}
695+
MCLI_PROJECT_ID: ${e2e_tests_mcli_project_id}
696+
MCLI_OPS_MANAGER_URL: ${e2e_tests_mcli_ops_manager_url}
697+
script: |
698+
set -e
699+
# Load environment variables
700+
eval $(.evergreen/print-compass-env.sh)
701+
# Create Atlas cluster for test project
702+
source .evergreen/create-atlas-cluster.sh
703+
# Run the tests
704+
echo "Starting e2e tests..."
705+
npm run --unsafe-perm --workspace compass-e2e-tests test -- --test-compass-web-atlas-cloud
706+
676707
test-connectivity:
677708
- command: shell.exec
678709
# Fail the task if it's idle for 10 mins

package-lock.json

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
"package-compass": "npm run package-compass --workspace=mongodb-compass --",
3333
"package-compass-debug": "npm run package-compass-debug --workspace=mongodb-compass --",
3434
"package-compass-nocompile": "npm run package-compass-nocompile --workspace=mongodb-compass --",
35-
"prestart": "npm run compile --workspace=@mongodb-js/webpack-config-compass",
36-
"prestart-web": "npm run prestart",
3735
"start": "npm run start --workspace=mongodb-compass",
3836
"start-web": "npm run start --workspace=@mongodb-js/compass-web",
3937
"test": "lerna run test --concurrency 1 --stream",

packages/compass-e2e-tests/helpers/commands/connect.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
DEFAULT_CONNECTION_NAME_1,
33
DEFAULT_CONNECTION_NAME_2,
44
DEFAULT_CONNECTION_STRING_1,
5+
TEST_COMPASS_WEB_ATLAS_CLOUD,
56
TEST_MULTIPLE_CONNECTIONS,
67
connectionNameFromString,
78
} from '../compass';
@@ -53,6 +54,10 @@ export async function connectWithConnectionString(
5354
connectionString = DEFAULT_CONNECTION_STRING_1,
5455
options: ConnectOptions = {}
5556
): Promise<void> {
57+
if (TEST_COMPASS_WEB_ATLAS_CLOUD) {
58+
return connectByName(browser, connectionString);
59+
}
60+
5661
// Use this command when you need to add a new connection with a specific
5762
// connection string. Most test files should just be using
5863
// browser.connectToDefaults()

packages/compass-e2e-tests/helpers/compass.ts

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import { rebuild } from '@electron/rebuild';
1313
import type { RebuildOptions } from '@electron/rebuild';
1414
import type { ConsoleMessageType } from 'puppeteer';
1515
import { run as packageCompass } from 'hadron-build/commands/release';
16-
import { redactConnectionString } from 'mongodb-connection-string-url';
16+
import {
17+
redactConnectionString,
18+
ConnectionString,
19+
} from 'mongodb-connection-string-url';
1720
import { getConnectionTitle } from '@mongodb-js/connection-info';
1821
export * as Selectors from './selectors';
1922
export * as Commands from './commands';
@@ -45,7 +48,11 @@ let MONGODB_USE_ENTERPRISE =
4548
(process.env.MONGODB_VERSION?.endsWith('-enterprise') && 'yes') ?? 'no';
4649

4750
// should we test compass-web (true) or compass electron (false)?
48-
export const TEST_COMPASS_WEB = process.argv.includes('--test-compass-web');
51+
export const TEST_COMPASS_WEB_ATLAS_CLOUD = process.argv.includes(
52+
'--test-compass-web-atlas-cloud'
53+
);
54+
export const TEST_COMPASS_WEB =
55+
process.argv.includes('--test-compass-web') || TEST_COMPASS_WEB_ATLAS_CLOUD;
4956
// multiple connections is now the default
5057
export const TEST_MULTIPLE_CONNECTIONS = true;
5158

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

78-
export const DEFAULT_CONNECTION_STRING_1 = `mongodb://127.0.0.1:${MONGODB_TEST_SERVER_PORT}/test`;
88+
function getAtlasConnectionStringFromEnv() {
89+
const connectionStringJSONString =
90+
process.env.E2E_ATLAS_CLOUD_TEST_CLUSTER_CONNECTION_STRING_JSON;
91+
if (!connectionStringJSONString) {
92+
return undefined;
93+
}
94+
const { standardSrv } = JSON.parse(connectionStringJSONString);
95+
const mongodbConnectionString = new ConnectionString(standardSrv);
96+
mongodbConnectionString.username =
97+
process.env.E2E_TESTS_COMPASS_WEB_ATLAS_DB_USERNAME!;
98+
mongodbConnectionString.password =
99+
process.env.E2E_TESTS_COMPASS_WEB_ATLAS_PASSWORD!;
100+
return mongodbConnectionString.toString();
101+
}
102+
103+
export const DEFAULT_CONNECTION_STRING_1 =
104+
getAtlasConnectionStringFromEnv() ??
105+
`mongodb://127.0.0.1:${MONGODB_TEST_SERVER_PORT}/test`;
79106
// NOTE: in browser.setupDefaultConnections() we don't give the first connection an
80107
// explicit name, so it gets a calculated one based off the connection string
81-
export const DEFAULT_CONNECTION_NAME_1 = connectionNameFromString(
82-
DEFAULT_CONNECTION_STRING_1
83-
);
108+
export const DEFAULT_CONNECTION_NAME_1 =
109+
process.env.E2E_ATLAS_CLOUD_TEST_CLUSTER_NAME ??
110+
connectionNameFromString(DEFAULT_CONNECTION_STRING_1);
84111

85112
// for testing multiple connections
86113
export const DEFAULT_CONNECTION_STRING_2 = `mongodb://127.0.0.1:${

0 commit comments

Comments
 (0)