Skip to content

Commit 71f9884

Browse files
Merge remote-tracking branch 'origin/beta-releases' into ga-releases
2 parents 0571c9b + b4b5864 commit 71f9884

File tree

184 files changed

+5388
-4409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+5388
-4409
lines changed

.evergreen/functions.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,11 +683,8 @@ functions:
683683
env:
684684
<<: *compass-env
685685
DEBUG: ${debug|}
686-
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_CLOUD_CONFIG: 'qa'
687686
COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME: ${e2e_tests_compass_web_atlas_username}
688687
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}
691688
MCLI_PUBLIC_API_KEY: ${e2e_tests_mcli_public_api_key}
692689
MCLI_PRIVATE_API_KEY: ${e2e_tests_mcli_private_api_key}
693690
MCLI_ORG_ID: ${e2e_tests_mcli_org_id}
Lines changed: 101 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,65 @@
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+
6+
# This script helps to automatically provision Atlas cluster for running the e2e
7+
# tests against. In CI this will always create a new cluster and delete it when
8+
# the test run is finished. You can also use this script locally to run e2e
9+
# tests against a "logged in" Atlas Cloud experience in compass-web sandbox.
10+
#
11+
# While the provisioning of clusters is automated, you should be aware that it
12+
# requires some extra environmental variables to be available when you are
13+
# running it. If you want to be able to run these e2e tests locally, following
14+
# steps are required:
15+
#
16+
# - Create a test Atlas user on one of the testing environments (-dev / -qa).
17+
# You can only use your work emails with a subaddress to create those (e.g,
18+
19+
#
20+
# - Setup a new org and project. Save the org id and project id for later.
21+
#
22+
# - Add test payment details within the organization (Billing) to be able to
23+
# create clusters.
24+
#
25+
# - Create a new API key (Access Manager > Project Access > Create Application >
26+
# API Key) for the project you created and save the public and private keys.
27+
#
28+
# - (Optional) Deploy a cluster with a required configuration through Atlas
29+
# Cloud UI. If you skip the step, the script will deploy a default cluster for
30+
# you.
31+
#
32+
# - Make sure that you have the following environmental variables provided to
33+
# the script below:
34+
#
35+
# MCLI_OPS_MANAGER_URL API base url matching the environment you used to
36+
# create your user (https://cloud{-dev,-qa}.mongodb.com/)
37+
# MCLI_PUBLIC_API_KEY Public API key
38+
# MCLI_PRIVATE_API_KEY Private API key
39+
# MCLI_ORG_ID Org ID
40+
# MCLI_PROJECT_ID Project ID
41+
#
42+
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME Cloud user you created
43+
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD Cloud user password
44+
#
45+
# - Source the script followed by running the tests to make sure that some
46+
# variables exported from this script are available for the test env:
47+
#
48+
# (ATLAS_CLOUD_TEST_CLUSTER_NAME="TestCluster" source .evergreen/start-atlas-cloud-cluster.sh \
49+
# && npm run -w compass-e2e-tests test web -- --test-atlas-cloud-sandbox --test-filter="atlas-cloud/**/*")
50+
51+
_ATLAS_CLOUD_TEST_CLUSTER_NAME=${ATLAS_CLOUD_TEST_CLUSTER_NAME:-""}
52+
353
# Atlas limits the naming to something like /^[\w\d-]{,23}$/ (and will auto
454
# truncate if it's too long) so we're very limited in terms of how unique this
555
# name can be. Hopefully the epoch + part of git hash is enough for these to not
656
# overlap when tests are running
7-
ATLAS_CLOUD_TEST_CLUSTER_NAME="e2e-$(date +"%s")-$(git rev-parse HEAD)"
57+
DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME="e2e-$RUN_ID"
58+
59+
ATLAS_CLUSTER_NAME="${_ATLAS_CLOUD_TEST_CLUSTER_NAME:-$DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME}"
60+
61+
ATLAS_TEST_DB_USERNAME="testuser-$RUN_ID"
62+
ATLAS_TEST_DB_PASSWORD="$(head -c 32 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9')"
863

964
function atlascli() {
1065
docker run \
@@ -17,23 +72,60 @@ function atlascli() {
1772
}
1873

1974
cleanup() {
20-
echo "Scheduling Atlas deployment \`$ATLAS_CLOUD_TEST_CLUSTER_NAME\` for deletion..."
21-
atlascli clusters delete $ATLAS_CLOUD_TEST_CLUSTER_NAME --force
75+
# Assuming that we want to preserve the cluster if the name was provided
76+
# outside of script. Helpful when trying to run the tests locally, you can
77+
# automatically create a cluster with a custom name for the first time, but
78+
# then re-use it when running the tests again. Don't forget to clean it up
79+
# after you're done!
80+
if [ -z "$_ATLAS_CLOUD_TEST_CLUSTER_NAME" ]; then
81+
echo "Scheduling Atlas deployment \`$ATLAS_CLUSTER_NAME\` for deletion..."
82+
atlascli clusters delete $ATLAS_CLUSTER_NAME --force
83+
else
84+
echo "Custom cluster name provided ($_ATLAS_CLOUD_TEST_CLUSTER_NAME), skipping cluster cleanup"
85+
fi
86+
echo "Deleting Atlas db user \`$ATLAS_TEST_DB_USERNAME\`..."
87+
atlascli dbusers delete $ATLAS_TEST_DB_USERNAME --force
2288
}
2389

2490
trap cleanup EXIT
2591

26-
echo "Creating Atlas deployment \`$ATLAS_CLOUD_TEST_CLUSTER_NAME\` to test against..."
27-
atlascli clusters create $ATLAS_CLOUD_TEST_CLUSTER_NAME \
92+
echo "Allowing access from current ip..."
93+
atlascli accessList create \
94+
--currentIp \
95+
--deleteAfter "$DELETE_AFTER"
96+
97+
echo "Creating Atlas db user \`$ATLAS_TEST_DB_USERNAME\`..."
98+
atlascli dbusers create atlasAdmin \
99+
--username "$ATLAS_TEST_DB_USERNAME" \
100+
--password "$ATLAS_TEST_DB_PASSWORD" \
101+
--deleteAfter "$DELETE_AFTER" # so that it's autoremoved if cleaning up failed for some reason
102+
103+
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME="$ATLAS_TEST_DB_USERNAME"
104+
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD="$ATLAS_TEST_DB_PASSWORD"
105+
106+
echo "Creating Atlas deployment \`$ATLAS_CLUSTER_NAME\` to test against..."
107+
(atlascli clusters create $ATLAS_CLUSTER_NAME \
28108
--provider AWS \
29109
--region US_EAST_1 \
30-
--tier M10
110+
--tier M10 \
111+
--type GEOSHARDED || true) # can error if custom name was provided, will fail on next step if it's not expected failure
31112

32113
echo "Waiting for the deployment to be provisioned..."
33-
atlascli clusters watch "$ATLAS_CLOUD_TEST_CLUSTER_NAME"
114+
atlascli clusters watch $ATLAS_CLUSTER_NAME
34115

35116
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)"
117+
CONNECTION_STRINGS_JSON="$(atlascli clusters connectionStrings describe $ATLAS_CLUSTER_NAME -o json)"
118+
119+
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_CLOUD_CONFIG=$(
120+
if [[ "$MCLI_OPS_MANAGER_URL" =~ "-dev" ]]; then
121+
echo "dev"
122+
elif [[ "$MCLI_OPS_MANAGER_URL" =~ "-qa" ]]; then
123+
echo "qa"
124+
else
125+
echo "prod"
126+
fi
127+
)
128+
echo "Cloud config: $COMPASS_E2E_ATLAS_CLOUD_SANDBOX_CLOUD_CONFIG"
37129

38-
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DEFAULT_CONNECTIONS="{\"$ATLAS_CLOUD_TEST_CLUSTER_NAME\": $ATLAS_CLOUD_TEST_CLUSTER_CONNECTION_STRING_JSON}"
130+
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DEFAULT_CONNECTIONS="{\"$ATLAS_CLUSTER_NAME\": $CONNECTION_STRINGS_JSON}"
39131
echo "Cluster connections: $COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DEFAULT_CONNECTIONS"

.github/workflows/check-pr-title.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ jobs:
1919
# Skip the JIRA ticket check for PRs opened by bots
2020
if: ${{ !contains(github.event.pull_request.user.login, '[bot]') }}
2121
with:
22-
regex: '[A-Z]{4,10}-[0-9]{1,5}$'
22+
regex: '[A-Z]{4,10}-[0-9]{1,10}$'
2323
error-hint: 'Invalid PR title. Make sure it ends with a JIRA ticket - i.e. COMPASS-1234 or add the no-title-validation label'
2424
ignore-labels: 'no-title-validation'

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,4 @@ Kræn Hansen <[email protected]>
9494
Ruchitha Rajaghatta <[email protected]>
9595
9696
Nikola Irinchev <[email protected]>
97+
djechlin-mongodb <[email protected]>

0 commit comments

Comments
 (0)