Skip to content

Commit ad2a360

Browse files
committed
Merge remote-tracking branch 'origin/main' into COMPASS-8441-global0=-writes-tests
2 parents 06cea26 + d01d076 commit ad2a360

File tree

5 files changed

+63
-8
lines changed

5 files changed

+63
-8
lines changed

.evergreen/functions.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,6 @@ functions:
685685
DEBUG: ${debug|}
686686
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME: ${e2e_tests_compass_web_atlas_username}
687687
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD: ${e2e_tests_compass_web_atlas_password}
688-
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME: ${e2e_tests_compass_web_atlas_db_username}
689-
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD: ${e2e_tests_compass_web_atlas_password}
690688
MCLI_PUBLIC_API_KEY: ${e2e_tests_mcli_public_api_key}
691689
MCLI_PRIVATE_API_KEY: ${e2e_tests_mcli_private_api_key}
692690
MCLI_ORG_ID: ${e2e_tests_mcli_org_id}

.evergreen/start-atlas-cloud-cluster.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
RUN_ID="$(date +"%s")-$(git rev-parse --short HEAD)"
4+
DELETE_AFTER="$(date -u -Iseconds -d '+2 hours' 2>/dev/null || date -u -Iseconds -v '+2H')"
5+
36
# This script helps to automatically provision Atlas cluster for running the e2e
47
# tests against. In CI this will always create a new cluster and delete it when
58
# the test run is finished. You can also use this script locally to run e2e
@@ -41,8 +44,6 @@
4144
#
4245
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME Cloud user you created
4346
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD Cloud user password
44-
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME Db user for the project
45-
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD Db user password
4647
#
4748
# - Source the script followed by running the tests to make sure that some
4849
# variables exported from this script are available for the test env:
@@ -56,10 +57,13 @@ _ATLAS_CLOUD_TEST_CLUSTER_NAME=${ATLAS_CLOUD_TEST_CLUSTER_NAME:-""}
5657
# truncate if it's too long) so we're very limited in terms of how unique this
5758
# name can be. Hopefully the epoch + part of git hash is enough for these to not
5859
# overlap when tests are running
59-
DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME="e2e-$(date +"%s")-$(git rev-parse HEAD)"
60+
DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME="e2e-$RUN_ID"
6061

6162
ATLAS_CLUSTER_NAME="${_ATLAS_CLOUD_TEST_CLUSTER_NAME:-$DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME}"
6263

64+
ATLAS_TEST_DB_USERNAME="testuser-$RUN_ID"
65+
ATLAS_TEST_DB_PASSWORD="$(head -c 32 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9')"
66+
6367
function atlascli() {
6468
docker run \
6569
-e MCLI_PUBLIC_API_KEY \
@@ -82,10 +86,26 @@ cleanup() {
8286
else
8387
echo "Custom cluster name provided ($_ATLAS_CLOUD_TEST_CLUSTER_NAME), skipping cluster cleanup"
8488
fi
89+
echo "Deleting Atlas db user \`$ATLAS_TEST_DB_USERNAME\`..."
90+
atlascli dbusers delete $ATLAS_TEST_DB_USERNAME --force
8591
}
8692

8793
trap cleanup EXIT
8894

95+
echo "Allowing access from current ip..."
96+
atlascli accessList create \
97+
--currentIp \
98+
--deleteAfter "$DELETE_AFTER"
99+
100+
echo "Creating Atlas db user \`$ATLAS_TEST_DB_USERNAME\`..."
101+
atlascli dbusers create atlasAdmin \
102+
--username "$ATLAS_TEST_DB_USERNAME" \
103+
--password "$ATLAS_TEST_DB_PASSWORD" \
104+
--deleteAfter "$DELETE_AFTER" # so that it's autoremoved if cleaning up failed for some reason
105+
106+
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME="$ATLAS_TEST_DB_USERNAME"
107+
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD="$ATLAS_TEST_DB_PASSWORD"
108+
89109
echo "Creating Atlas deployment \`$ATLAS_CLUSTER_NAME\` to test against..."
90110
atlascli clusters create $ATLAS_CLUSTER_NAME \
91111
--provider AWS \

THIRD-PARTY-NOTICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The following third-party software is used by and included in **Mongodb Compass**.
2-
This document was automatically generated on Wed Oct 30 2024.
2+
This document was automatically generated on Fri Nov 01 2024.
33

44
## List of dependencies
55

docs/tracking-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Compass Tracking Plan
33

4-
Generated on Wed, Oct 30, 2024 at 02:38 PM
4+
Generated on Fri, Nov 1, 2024 at 01:56 PM
55

66
## Table of Contents
77

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

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,44 @@ export async function spawnCompassWebSandboxAndSignInToAtlas(
132132

133133
debug('Waiting for the auth to finish ...');
134134

135-
const res = await authenticatePromise;
135+
let authenticatedPromiseSettled = false;
136+
137+
// Atlas Cloud will periodically remind user to enable MFA (which we can't
138+
// enable in e2e CI environment), so to account for that, in parallel to
139+
// waiting for auth to finish, we'll wait for the MFA screen to show up and
140+
// skip it if it appears
141+
const [, settledRes] = await Promise.allSettled([
142+
(async () => {
143+
const remindMeLaterButton = 'button*=Remind me later';
144+
145+
await electronProxyRemote.waitUntil(
146+
async () => {
147+
return (
148+
authenticatedPromiseSettled ||
149+
(await electronProxyRemote.$(remindMeLaterButton).isDisplayed())
150+
);
151+
},
152+
// Takes awhile for the redirect to land on this reminder page when it
153+
// happens, so no need to bombard the browser with displayed checks
154+
{ interval: 2000 }
155+
);
156+
157+
if (authenticatedPromiseSettled) {
158+
return;
159+
}
160+
161+
await electronProxyRemote.$(remindMeLaterButton).click();
162+
})(),
163+
authenticatePromise.finally(() => {
164+
authenticatedPromiseSettled = true;
165+
}),
166+
]);
167+
168+
if (settledRes.status === 'rejected') {
169+
throw settledRes.reason;
170+
}
171+
172+
const res = settledRes.value;
136173

137174
if (res.ok === false || !(await res.json()).projectId) {
138175
throw new Error(

0 commit comments

Comments
 (0)