Skip to content

Commit 775726f

Browse files
Merge branch 'main' into COMPASS-8333
2 parents 1838e19 + 69ac5e8 commit 775726f

Some content is hidden

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

46 files changed

+1712
-677
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: 96 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,62 @@
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+
# - Create a new API key (Access Manager > Project Access > Create Application >
23+
# API Key) for the project you created and save the public and private keys.
24+
#
25+
# - (Optional) Deploy a cluster with a required configuration through Atlas
26+
# Cloud UI. If you skip the step, the script will deploy a default cluster for
27+
# you.
28+
#
29+
# - Make sure that you have the following environmental variables provided to
30+
# the script below:
31+
#
32+
# MCLI_OPS_MANAGER_URL API base url matching the environment you used to
33+
# create your user (https://cloud{-dev,-qa}.mongodb.com/)
34+
# MCLI_PUBLIC_API_KEY Public API key
35+
# MCLI_PRIVATE_API_KEY Private API key
36+
# MCLI_ORG_ID Org ID
37+
# MCLI_PROJECT_ID Project ID
38+
#
39+
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME Cloud user you created
40+
# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD Cloud user password
41+
#
42+
# - Source the script followed by running the tests to make sure that some
43+
# variables exported from this script are available for the test env:
44+
#
45+
# (ATLAS_CLOUD_TEST_CLUSTER_NAME="TestCluster" source .evergreen/start-atlas-cloud-cluster.sh \
46+
# && npm run -w compass-e2e-tests test web -- --test-atlas-cloud-sandbox --test-filter="atlas-cloud/**/*")
47+
48+
_ATLAS_CLOUD_TEST_CLUSTER_NAME=${ATLAS_CLOUD_TEST_CLUSTER_NAME:-""}
49+
350
# Atlas limits the naming to something like /^[\w\d-]{,23}$/ (and will auto
451
# truncate if it's too long) so we're very limited in terms of how unique this
552
# name can be. Hopefully the epoch + part of git hash is enough for these to not
653
# overlap when tests are running
7-
ATLAS_CLOUD_TEST_CLUSTER_NAME="e2e-$(date +"%s")-$(git rev-parse HEAD)"
54+
DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME="e2e-$RUN_ID"
55+
56+
ATLAS_CLUSTER_NAME="${_ATLAS_CLOUD_TEST_CLUSTER_NAME:-$DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME}"
57+
58+
ATLAS_TEST_DB_USERNAME="testuser-$RUN_ID"
59+
ATLAS_TEST_DB_PASSWORD="$(head -c 32 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9')"
860

961
function atlascli() {
1062
docker run \
@@ -17,23 +69,59 @@ function atlascli() {
1769
}
1870

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

2487
trap cleanup EXIT
2588

26-
echo "Creating Atlas deployment \`$ATLAS_CLOUD_TEST_CLUSTER_NAME\` to test against..."
27-
atlascli clusters create $ATLAS_CLOUD_TEST_CLUSTER_NAME \
89+
echo "Allowing access from current ip..."
90+
atlascli accessList create \
91+
--currentIp \
92+
--deleteAfter "$DELETE_AFTER"
93+
94+
echo "Creating Atlas db user \`$ATLAS_TEST_DB_USERNAME\`..."
95+
atlascli dbusers create atlasAdmin \
96+
--username "$ATLAS_TEST_DB_USERNAME" \
97+
--password "$ATLAS_TEST_DB_PASSWORD" \
98+
--deleteAfter "$DELETE_AFTER" # so that it's autoremoved if cleaning up failed for some reason
99+
100+
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME="$ATLAS_TEST_DB_USERNAME"
101+
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD="$ATLAS_TEST_DB_PASSWORD"
102+
103+
echo "Creating Atlas deployment \`$ATLAS_CLUSTER_NAME\` to test against..."
104+
atlascli clusters create $ATLAS_CLUSTER_NAME \
28105
--provider AWS \
29106
--region US_EAST_1 \
30107
--tier M10
31108

32109
echo "Waiting for the deployment to be provisioned..."
33-
atlascli clusters watch "$ATLAS_CLOUD_TEST_CLUSTER_NAME"
110+
atlascli clusters watch $ATLAS_CLUSTER_NAME
34111

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

38-
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DEFAULT_CONNECTIONS="{\"$ATLAS_CLOUD_TEST_CLUSTER_NAME\": $ATLAS_CLOUD_TEST_CLUSTER_CONNECTION_STRING_JSON}"
126+
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DEFAULT_CONNECTIONS="{\"$ATLAS_CLUSTER_NAME\": $CONNECTION_STRINGS_JSON}"
39127
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'

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 Tue Oct 29 2024.
2+
This document was automatically generated on Wed Nov 06 2024.
33

44
## List of dependencies
55

docs/tracking-plan.md

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

22
# Compass Tracking Plan
33

4-
Generated on Tue, Oct 29, 2024 at 05:29 PM
4+
Generated on Wed, Nov 6, 2024 at 02:20 PM
55

66
## Table of Contents
77

@@ -148,6 +148,7 @@ Generated on Tue, Oct 29, 2024 at 05:29 PM
148148

149149
### Schema
150150
- [Schema Analyzed](#event--SchemaAnalyzedEvent)
151+
- [Schema Exported](#event--SchemaExportedEvent)
151152

152153
### Schema Validation
153154
- [Schema Validation Added](#event--SchemaValidationAddedEvent)
@@ -1801,6 +1802,25 @@ This event is fired when user analyzes the schema.
18011802
- **connection_id** (optional): `string | undefined`
18021803
- The id of the connection associated to this event.
18031804

1805+
<a name="event--SchemaExportedEvent"></a>
1806+
1807+
### Schema Exported
1808+
1809+
This event is fired when user shares the schema.
1810+
1811+
**Properties**:
1812+
1813+
- **has_schema** (required): `boolean`
1814+
- Indicates whether the schema was analyzed before sharing.
1815+
- **schema_width** (required): `number`
1816+
- The number of fields at the top level.
1817+
- **schema_depth** (required): `number`
1818+
- The number of nested levels.
1819+
- **geo_data** (required): `boolean`
1820+
- Indicates whether the schema contains geospatial data.
1821+
- **connection_id** (optional): `string | undefined`
1822+
- The id of the connection associated to this event.
1823+
18041824

18051825
## Schema Validation
18061826

package-lock.json

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

packages/atlas-service/src/atlas-service.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,8 @@ export class AtlasService {
2929
) {
3030
this.config = getAtlasConfig(preferences);
3131
}
32-
adminApiEndpoint(path?: string, requestId?: string): string {
33-
const uri = `${this.config.atlasApiBaseUrl}${normalizePath(path)}`;
34-
const query = requestId
35-
? `?request_id=${encodeURIComponent(requestId)}`
36-
: '';
37-
return `${uri}${query}`;
32+
adminApiEndpoint(path?: string): string {
33+
return `${this.config.atlasApiBaseUrl}${normalizePath(path)}`;
3834
}
3935
cloudEndpoint(path?: string): string {
4036
return `${this.config.cloudBaseUrl}${normalizePath(path)}`;

packages/compass-aggregations/src/modules/pipeline-builder/pipeline-ai.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -281,20 +281,23 @@ export const runAIPipelineGeneration = (
281281

282282
const { collection: collectionName, database: databaseName } =
283283
toNS(namespace);
284-
jsonResponse = await atlasAiService.getAggregationFromUserInput({
285-
signal: abortController.signal,
286-
userInput,
287-
collectionName,
288-
databaseName,
289-
schema,
290-
// Provide sample documents when the user has opted in in their settings.
291-
...(provideSampleDocuments
292-
? {
293-
sampleDocuments,
294-
}
295-
: undefined),
296-
requestId,
297-
});
284+
jsonResponse = await atlasAiService.getAggregationFromUserInput(
285+
{
286+
signal: abortController.signal,
287+
userInput,
288+
collectionName,
289+
databaseName,
290+
schema,
291+
// Provide sample documents when the user has opted in in their settings.
292+
...(provideSampleDocuments
293+
? {
294+
sampleDocuments,
295+
}
296+
: undefined),
297+
requestId,
298+
},
299+
connectionInfo
300+
);
298301
} catch (err: any) {
299302
if (signal.aborted) {
300303
// If we already aborted so we ignore the error.

packages/compass-components/src/components/document-list/document-actions-group.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ const actionsGroupContainer = css({
99
position: 'absolute',
1010
display: 'flex',
1111
alignItems: 'center',
12-
gap: spacing[2],
12+
gap: spacing[200],
1313
width: '100%',
14-
top: spacing[2] + spacing[1],
15-
paddingLeft: spacing[3],
16-
paddingRight: spacing[3],
14+
top: spacing[300],
15+
paddingLeft: spacing[300],
16+
paddingRight: spacing[300],
1717
pointerEvents: 'none',
1818
});
1919

@@ -44,6 +44,13 @@ const actionsGroupSignalPopover = css({
4444
display: 'block !important',
4545
});
4646

47+
const expandButton = css({
48+
'& > div:has(svg)': {
49+
paddingLeft: 3,
50+
paddingRight: 3,
51+
},
52+
});
53+
4754
function useElementParentHoverState<T extends HTMLElement>(
4855
ref: React.RefObject<T>
4956
): boolean {
@@ -159,7 +166,7 @@ const DocumentActionsGroup: React.FunctionComponent<
159166
aria-pressed={expanded}
160167
data-testid="expand-document-button"
161168
onClick={onExpand}
162-
className={actionsGroupItem}
169+
className={cx(actionsGroupItem, expandButton)}
163170
tooltipText={expanded ? 'Collapse all' : 'Expand all'}
164171
/>
165172
)}

packages/compass-components/src/components/document-list/element.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ const expandButton = css({
192192

193193
const hadronElement = css({
194194
display: 'flex',
195-
paddingLeft: spacing[2],
196-
paddingRight: spacing[2],
195+
paddingLeft: spacing[50],
196+
paddingRight: spacing[50],
197197
marginTop: 1,
198198
});
199199

@@ -239,7 +239,7 @@ const elementRemovedDarkMode = css({
239239

240240
const elementActions = css({
241241
flex: 'none',
242-
width: spacing[3],
242+
width: spacing[300],
243243
position: 'relative',
244244
});
245245

@@ -364,7 +364,7 @@ const elementKeyDarkMode = css({
364364
});
365365

366366
const calculateElementSpacerWidth = (editable: boolean, level: number) => {
367-
return (editable ? spacing[200] : 0) + spacing[400] * level;
367+
return (editable ? spacing[100] : 0) + spacing[400] * level;
368368
};
369369

370370
export const calculateShowMoreToggleOffset = ({
@@ -377,10 +377,10 @@ export const calculateShowMoreToggleOffset = ({
377377
alignWithNestedExpandIcon: boolean;
378378
}) => {
379379
// the base padding that we have on all elements rendered in the document
380-
const BASE_PADDING_LEFT = spacing[200];
380+
const BASE_PADDING_LEFT = spacing[50];
381381
const OFFSET_WHEN_EDITABLE = editable
382382
? // space taken by element actions
383-
spacing[400] +
383+
spacing[300] +
384384
// space and margin taken by line number element
385385
spacing[400] +
386386
spacing[100] +

0 commit comments

Comments
 (0)