Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into COMPASS-8441-global0=…
Browse files Browse the repository at this point in the history
…-writes-tests
  • Loading branch information
gribnoysup committed Nov 1, 2024
2 parents 06cea26 + d01d076 commit ad2a360
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .evergreen/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,6 @@ functions:
DEBUG: ${debug|}
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME: ${e2e_tests_compass_web_atlas_username}
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD: ${e2e_tests_compass_web_atlas_password}
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME: ${e2e_tests_compass_web_atlas_db_username}
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_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}
Expand Down
26 changes: 23 additions & 3 deletions .evergreen/start-atlas-cloud-cluster.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

RUN_ID="$(date +"%s")-$(git rev-parse --short HEAD)"
DELETE_AFTER="$(date -u -Iseconds -d '+2 hours' 2>/dev/null || date -u -Iseconds -v '+2H')"

# This script helps to automatically provision Atlas cluster for running the e2e
# tests against. In CI this will always create a new cluster and delete it when
# the test run is finished. You can also use this script locally to run e2e
Expand Down Expand Up @@ -41,8 +44,6 @@
#
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME Cloud user you created
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD Cloud user password
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME Db user for the project
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD Db user password
#
# - Source the script followed by running the tests to make sure that some
# variables exported from this script are available for the test env:
Expand All @@ -56,10 +57,13 @@ _ATLAS_CLOUD_TEST_CLUSTER_NAME=${ATLAS_CLOUD_TEST_CLUSTER_NAME:-""}
# truncate if it's too long) so we're very limited in terms of how unique this
# name can be. Hopefully the epoch + part of git hash is enough for these to not
# overlap when tests are running
DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME="e2e-$(date +"%s")-$(git rev-parse HEAD)"
DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME="e2e-$RUN_ID"

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

ATLAS_TEST_DB_USERNAME="testuser-$RUN_ID"
ATLAS_TEST_DB_PASSWORD="$(head -c 32 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9')"

function atlascli() {
docker run \
-e MCLI_PUBLIC_API_KEY \
Expand All @@ -82,10 +86,26 @@ cleanup() {
else
echo "Custom cluster name provided ($_ATLAS_CLOUD_TEST_CLUSTER_NAME), skipping cluster cleanup"
fi
echo "Deleting Atlas db user \`$ATLAS_TEST_DB_USERNAME\`..."
atlascli dbusers delete $ATLAS_TEST_DB_USERNAME --force
}

trap cleanup EXIT

echo "Allowing access from current ip..."
atlascli accessList create \
--currentIp \
--deleteAfter "$DELETE_AFTER"

echo "Creating Atlas db user \`$ATLAS_TEST_DB_USERNAME\`..."
atlascli dbusers create atlasAdmin \
--username "$ATLAS_TEST_DB_USERNAME" \
--password "$ATLAS_TEST_DB_PASSWORD" \
--deleteAfter "$DELETE_AFTER" # so that it's autoremoved if cleaning up failed for some reason

export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME="$ATLAS_TEST_DB_USERNAME"
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD="$ATLAS_TEST_DB_PASSWORD"

echo "Creating Atlas deployment \`$ATLAS_CLUSTER_NAME\` to test against..."
atlascli clusters create $ATLAS_CLUSTER_NAME \
--provider AWS \
Expand Down
2 changes: 1 addition & 1 deletion THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The following third-party software is used by and included in **Mongodb Compass**.
This document was automatically generated on Wed Oct 30 2024.
This document was automatically generated on Fri Nov 01 2024.

## List of dependencies

Expand Down
2 changes: 1 addition & 1 deletion docs/tracking-plan.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Compass Tracking Plan

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

## Table of Contents

Expand Down
39 changes: 38 additions & 1 deletion packages/compass-e2e-tests/helpers/compass-web-sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,44 @@ export async function spawnCompassWebSandboxAndSignInToAtlas(

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

const res = await authenticatePromise;
let authenticatedPromiseSettled = false;

// Atlas Cloud will periodically remind user to enable MFA (which we can't
// enable in e2e CI environment), so to account for that, in parallel to
// waiting for auth to finish, we'll wait for the MFA screen to show up and
// skip it if it appears
const [, settledRes] = await Promise.allSettled([
(async () => {
const remindMeLaterButton = 'button*=Remind me later';

await electronProxyRemote.waitUntil(
async () => {
return (
authenticatedPromiseSettled ||
(await electronProxyRemote.$(remindMeLaterButton).isDisplayed())
);
},
// Takes awhile for the redirect to land on this reminder page when it
// happens, so no need to bombard the browser with displayed checks
{ interval: 2000 }
);

if (authenticatedPromiseSettled) {
return;
}

await electronProxyRemote.$(remindMeLaterButton).click();
})(),
authenticatePromise.finally(() => {
authenticatedPromiseSettled = true;
}),
]);

if (settledRes.status === 'rejected') {
throw settledRes.reason;
}

const res = settledRes.value;

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

0 comments on commit ad2a360

Please sign in to comment.