Skip to content

Commit e1b0308

Browse files
authored
chore(e2e): add a new mode to e2e tests to run against logged in sandbox; add rolling index build e2e tests COMPASS-8361 (#6411)
chore(e2e): add a new mode to e2e tests to run against logged in sandbox; add rolling index build e2e tests
1 parent 08aadc8 commit e1b0308

File tree

17 files changed

+607
-101
lines changed

17 files changed

+607
-101
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/functions.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,42 @@ functions:
672672
eval $(.evergreen/print-compass-env.sh)
673673
npm run --unsafe-perm --workspace compass-e2e-tests test-ci web
674674
675+
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+
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_CLOUD_CONFIG: 'qa'
687+
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME: ${e2e_tests_compass_web_atlas_username}
688+
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD: ${e2e_tests_compass_web_atlas_password}
689+
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME: ${e2e_tests_compass_web_atlas_db_username}
690+
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD: ${e2e_tests_compass_web_atlas_password}
691+
MCLI_PUBLIC_API_KEY: ${e2e_tests_mcli_public_api_key}
692+
MCLI_PRIVATE_API_KEY: ${e2e_tests_mcli_private_api_key}
693+
MCLI_ORG_ID: ${e2e_tests_mcli_org_id}
694+
MCLI_PROJECT_ID: ${e2e_tests_mcli_project_id}
695+
MCLI_OPS_MANAGER_URL: ${e2e_tests_mcli_ops_manager_url}
696+
script: |
697+
set -e
698+
# Load environment variables
699+
eval $(.evergreen/print-compass-env.sh)
700+
# Create Atlas cluster for test project
701+
source .evergreen/start-atlas-cloud-cluster.sh
702+
# Run the tests
703+
echo "Starting e2e tests..."
704+
# We're only running a special subset of tests as provisioning atlas
705+
# clusters in CI is both pricey and flakey, so we want to limit the
706+
# coverage to reduce those factors (at least for now)
707+
npm run --unsafe-perm --workspace compass-e2e-tests test-ci -- -- web \
708+
--test-atlas-cloud-sandbox \
709+
--test-filter="atlas-cloud/**/*"
710+
675711
test-connectivity:
676712
- command: shell.exec
677713
# Fail the task if it's idle for 10 mins
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Atlas limits the naming to something like /^[\w\d-]{,23}$/ (and will auto
4+
# truncate if it's too long) so we're very limited in terms of how unique this
5+
# name can be. Hopefully the epoch + part of git hash is enough for these to not
6+
# overlap when tests are running
7+
ATLAS_CLOUD_TEST_CLUSTER_NAME="e2e-$(date +"%s")-$(git rev-parse HEAD)"
8+
9+
function atlascli() {
10+
docker run \
11+
-e MCLI_PUBLIC_API_KEY \
12+
-e MCLI_PRIVATE_API_KEY \
13+
-e MCLI_ORG_ID \
14+
-e MCLI_PROJECT_ID \
15+
-e MCLI_OPS_MANAGER_URL \
16+
mongodb/atlas atlas $@
17+
}
18+
19+
cleanup() {
20+
echo "Scheduling Atlas deployment \`$ATLAS_CLOUD_TEST_CLUSTER_NAME\` for deletion..."
21+
atlascli clusters delete $ATLAS_CLOUD_TEST_CLUSTER_NAME --force
22+
}
23+
24+
trap cleanup EXIT
25+
26+
echo "Creating Atlas deployment \`$ATLAS_CLOUD_TEST_CLUSTER_NAME\` to test against..."
27+
atlascli clusters create $ATLAS_CLOUD_TEST_CLUSTER_NAME \
28+
--provider AWS \
29+
--region US_EAST_1 \
30+
--tier M10
31+
32+
echo "Waiting for the deployment to be provisioned..."
33+
atlascli clusters watch "$ATLAS_CLOUD_TEST_CLUSTER_NAME"
34+
35+
echo "Getting connection string for provisioned cluster..."
36+
ATLAS_CLOUD_TEST_CLUSTER_CONNECTION_STRING_JSON="$(atlascli clusters connectionStrings describe $ATLAS_CLOUD_TEST_CLUSTER_NAME -o json)"
37+
38+
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DEFAULT_CONNECTIONS="{\"$ATLAS_CLOUD_TEST_CLUSTER_NAME\": $ATLAS_CLOUD_TEST_CLUSTER_CONNECTION_STRING_JSON}"
39+
echo "Cluster connections: $COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DEFAULT_CONNECTIONS"

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Debug from 'debug';
77
import {
88
DEFAULT_CONNECTIONS,
99
isTestingAtlasCloudExternal,
10+
isTestingAtlasCloudSandbox,
1011
} from '../test-runner-context';
1112
import { getConnectionTitle } from '@mongodb-js/connection-info';
1213
const debug = Debug('compass-e2e-tests');
@@ -930,7 +931,7 @@ export async function saveConnection(
930931
export async function setupDefaultConnections(browser: CompassBrowser) {
931932
// When running tests against Atlas Cloud, connections can't be added or
932933
// removed from the UI manually, so we skip setup for default connections
933-
if (isTestingAtlasCloudExternal()) {
934+
if (isTestingAtlasCloudExternal() || isTestingAtlasCloudSandbox()) {
934935
return;
935936
}
936937

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

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import {
2-
DEFAULT_CONNECTION_NAME_1,
3-
DEFAULT_CONNECTION_NAME_2,
42
DEFAULT_CONNECTION_STRING_1,
3+
DEFAULT_CONNECTION_NAME_1,
54
connectionNameFromString,
65
} from '../compass';
76
import type { CompassBrowser } from '../compass-browser';
87
import type { ConnectFormState } from '../connect-form-state';
98
import * as Selectors from '../selectors';
109
import Debug from 'debug';
10+
import {
11+
DEFAULT_CONNECTION_NAMES,
12+
isTestingAtlasCloudExternal,
13+
isTestingAtlasCloudSandbox,
14+
} from '../test-runner-context';
1115

1216
const debug = Debug('compass-e2e-tests');
1317

@@ -35,14 +39,27 @@ type ConnectOptions = ConnectionResultOptions & {
3539
removeConnections?: boolean;
3640
};
3741

42+
/**
43+
* Use this command when you need to add a new connection with a specific
44+
* connection string. Most test files should just be using
45+
* browser.connectToDefaults()
46+
*/
3847
export async function connectWithConnectionString(
3948
browser: CompassBrowser,
40-
connectionString = DEFAULT_CONNECTION_STRING_1,
49+
connectionStringOrName?: string,
4150
options: ConnectOptions = {}
4251
): Promise<void> {
43-
// Use this command when you need to add a new connection with a specific
44-
// connection string. Most test files should just be using
45-
// browser.connectToDefaults()
52+
// When testing Atlas Cloud, we can't really create a new connection, so just
53+
// assume a connection name was passed (with a fallback to a default one) and
54+
// try to use it
55+
if (isTestingAtlasCloudExternal() || isTestingAtlasCloudSandbox()) {
56+
await browser.connectByName(
57+
connectionStringOrName ?? DEFAULT_CONNECTION_NAME_1
58+
);
59+
return;
60+
}
61+
62+
connectionStringOrName ??= DEFAULT_CONNECTION_STRING_1;
4663

4764
// if the modal is still animating away when we're connecting again, things
4865
// are going to get confused
@@ -52,7 +69,7 @@ export async function connectWithConnectionString(
5269

5370
// if a connection with this name already exists, remove it otherwise we'll
5471
// add a duplicate and things will get complicated fast
55-
const connectionName = connectionNameFromString(connectionString);
72+
const connectionName = connectionNameFromString(connectionStringOrName);
5673
if (await browser.removeConnection(connectionName)) {
5774
debug('Removing existing connection so we do not create a duplicate', {
5875
connectionName,
@@ -64,7 +81,7 @@ export async function connectWithConnectionString(
6481

6582
await browser.setValueVisible(
6683
Selectors.ConnectionFormStringInput,
67-
connectionString
84+
connectionStringOrName
6885
);
6986

7087
await browser.doConnect(connectionName, options);
@@ -173,9 +190,10 @@ export async function connectByName(
173190
}
174191

175192
export async function connectToDefaults(browser: CompassBrowser) {
176-
// See setupDefaultConnections() for the details behind the thinking here.
177-
await browser.connectByName(DEFAULT_CONNECTION_NAME_1);
178-
await browser.connectByName(DEFAULT_CONNECTION_NAME_2);
193+
for (const name of DEFAULT_CONNECTION_NAMES) {
194+
// See setupDefaultConnections() for the details behind the thinking here.
195+
await browser.connectByName(name);
196+
}
179197

180198
// We assume that we connected successfully, so just close the success toasts
181199
// early to make sure they aren't in the way of tests. Tests that care about

packages/compass-e2e-tests/helpers/commands/create-index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type CreateIndexOptions = {
99
wildcardProjection?: string;
1010
customCollation?: string;
1111
sparseIndex?: boolean;
12+
rollingIndex?: boolean;
1213
};
1314

1415
type IndexType = '1' | '-1' | '2dsphere' | 'text';
@@ -78,7 +79,14 @@ export async function createIndex(
7879
// Select extra options
7980
if (extraOptions) {
8081
await browser.clickVisible(Selectors.IndexToggleOptions);
81-
const { wildcardProjection } = extraOptions;
82+
const { wildcardProjection, rollingIndex, indexName } = extraOptions;
83+
84+
if (indexName) {
85+
await browser.clickVisible(Selectors.indexToggleOption('name'));
86+
await browser
87+
.$(Selectors.indexOptionInput('name', 'text'))
88+
.setValue(indexName);
89+
}
8290

8391
if (wildcardProjection) {
8492
await browser.clickVisible(
@@ -91,6 +99,12 @@ export async function createIndex(
9199
wildcardProjection
92100
);
93101
}
102+
103+
if (rollingIndex) {
104+
await browser.clickVisible(
105+
Selectors.indexToggleOption('buildInRollingProcess')
106+
);
107+
}
94108
}
95109

96110
if (screenshotName) {

0 commit comments

Comments
 (0)