From 90fbc555402c45e862d1c4048e837bab77fa227a Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Fri, 1 Nov 2024 11:40:33 +0100 Subject: [PATCH 01/15] global writes tests --- .evergreen/start-atlas-cloud-cluster.sh | 7 +- .../helpers/commands/collection-workspaces.ts | 38 ++--- .../compass-e2e-tests/helpers/selectors.ts | 19 +++ .../tests/atlas-cloud/global-writes.test.ts | 157 ++++++++++++++++++ .../src/components/create-shard-key-form.tsx | 3 + .../src/components/index.tsx | 5 +- 6 files changed, 202 insertions(+), 27 deletions(-) create mode 100644 packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts diff --git a/.evergreen/start-atlas-cloud-cluster.sh b/.evergreen/start-atlas-cloud-cluster.sh index 0b1b48bd540..0f5fe2bdd60 100644 --- a/.evergreen/start-atlas-cloud-cluster.sh +++ b/.evergreen/start-atlas-cloud-cluster.sh @@ -46,6 +46,10 @@ # # (ATLAS_CLOUD_TEST_CLUSTER_NAME="TestCluster" source .evergreen/start-atlas-cloud-cluster.sh \ # && npm run -w compass-e2e-tests test web -- --test-atlas-cloud-sandbox --test-filter="atlas-cloud/**/*") +# +# When setting up for the first time, make sure you: +# - Add payment details to be able to create clusters. You can use stripe test card. +# - Allow network access to the project for your IP address. _ATLAS_CLOUD_TEST_CLUSTER_NAME=${ATLAS_CLOUD_TEST_CLUSTER_NAME:-""} @@ -87,7 +91,8 @@ echo "Creating Atlas deployment \`$ATLAS_CLUSTER_NAME\` to test against..." atlascli clusters create $ATLAS_CLUSTER_NAME \ --provider AWS \ --region US_EAST_1 \ - --tier M10 + --tier M10 \ + --type GEOSHARDED echo "Waiting for the deployment to be provisioned..." atlascli clusters watch $ATLAS_CLUSTER_NAME diff --git a/packages/compass-e2e-tests/helpers/commands/collection-workspaces.ts b/packages/compass-e2e-tests/helpers/commands/collection-workspaces.ts index 8ca6d89c0c3..1b2bb502ccc 100644 --- a/packages/compass-e2e-tests/helpers/commands/collection-workspaces.ts +++ b/packages/compass-e2e-tests/helpers/commands/collection-workspaces.ts @@ -2,6 +2,14 @@ import type { CompassBrowser } from '../compass-browser'; import * as Selectors from '../selectors'; import type { WorkspaceTabSelectorOptions } from '../selectors'; +type CollectionWorkspaceSubTab = + | 'Documents' + | 'Aggregations' + | 'Schema' + | 'Indexes' + | 'Validation' + | 'GlobalWrites'; + async function navigateToCollection( browser: CompassBrowser, connectionName: string, @@ -50,12 +58,8 @@ export async function navigateToCollectionTab( connectionName: string, dbName: string, collectionName: string, - tabName: - | 'Documents' - | 'Aggregations' - | 'Schema' - | 'Indexes' - | 'Validation' = 'Documents', + tabName: CollectionWorkspaceSubTab = 'Documents', + closeExistingTabs = true ): Promise { await navigateToCollection( @@ -83,12 +87,7 @@ export async function navigateToCollectionTab( export async function navigateWithinCurrentCollectionTabs( browser: CompassBrowser, - tabName: - | 'Documents' - | 'Aggregations' - | 'Schema' - | 'Indexes' - | 'Validation' = 'Documents' + tabName: CollectionWorkspaceSubTab = 'Documents' ): Promise { const tab = browser.$(Selectors.collectionSubTab(tabName)); const selectedTab = browser.$(Selectors.collectionSubTab(tabName, true)); @@ -108,13 +107,7 @@ async function waitUntilActiveCollectionTab( connectionName: string, dbName: string, collectionName: string, - tabName: - | 'Documents' - | 'Aggregations' - | 'Schema' - | 'Indexes' - | 'Validation' - | null = null + tabName: CollectionWorkspaceSubTab | null = null ) { const options: WorkspaceTabSelectorOptions = { type: 'Collection', @@ -132,12 +125,7 @@ async function waitUntilActiveCollectionTab( export async function waitUntilActiveCollectionSubTab( browser: CompassBrowser, - tabName: - | 'Documents' - | 'Aggregations' - | 'Schema' - | 'Indexes' - | 'Validation' = 'Documents' + tabName: CollectionWorkspaceSubTab = 'Documents' ) { await browser.$(Selectors.collectionSubTab(tabName, true)).waitForDisplayed(); } diff --git a/packages/compass-e2e-tests/helpers/selectors.ts b/packages/compass-e2e-tests/helpers/selectors.ts index 0d4532ea4c1..67291f93153 100644 --- a/packages/compass-e2e-tests/helpers/selectors.ts +++ b/packages/compass-e2e-tests/helpers/selectors.ts @@ -1400,3 +1400,22 @@ export const ProxyCustomButton = // Close tab confirmation export const ConfirmTabCloseModal = '[data-testid="confirm-tab-close"]'; + +export const GlobalWrites = { + tabStatus: (status: string) => + `[data-testid="${status.toLowerCase()}-status"]`, + + ShardKeyFormSecondKeyInputCombobox: + '[data-testid="second-shard-key"] [role="combobox"] input', + ShardKeyFormAdvancedOptionsToggle: + '[data-testid="advanced-shard-key-configuration"]', + shardKeyFormIndexType: (type: 'UNIQUE' | 'HASHED') => + `[data-testid="${type.toLowerCase()}-index"]`, + ShardKeyFormSubmitButton: '[data-testid="shard-collection-button"]', + + CancelShardingButton: '[data-testid="cancel-sharding-btn"]', + UnmanageNamespaceButton: '[data-testid="unmanage-collection-button"]', + + SampleFindingDocuments: '[data-testid="sample-finding-documents"]', + SampleInsertingDocuments: '[data-testid="sample-inserting-documents"]', +}; diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts new file mode 100644 index 00000000000..51cda604c6e --- /dev/null +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -0,0 +1,157 @@ +import { expect } from 'chai'; +import type { Compass } from '../../helpers/compass'; +import { cleanup, init, Selectors } from '../../helpers/compass'; +import type { CompassBrowser } from '../../helpers/compass-browser'; +import { createGeospatialCollection } from '../../helpers/insert-data'; +import { + DEFAULT_CONNECTION_NAMES, + isTestingAtlasCloudSandbox, +} from '../../helpers/test-runner-context'; + +type GeoShardingFormData = { + secondShardKey: string; + keyType?: 'UNIQUE' | 'HASHED'; +}; + +type GeoShardingState = 'UNSHARDED' | 'SHARDING' | 'SHARD_KEY_CORRECT'; + +async function createGeoShardKey( + browser: CompassBrowser, + formData: GeoShardingFormData +) { + // shard-collection-form + await browser.setComboBoxValue( + Selectors.GlobalWrites.ShardKeyFormSecondKeyInputCombobox, + formData.secondShardKey + ); + + if (formData.keyType) { + await browser.clickVisible( + Selectors.GlobalWrites.ShardKeyFormAdvancedOptionsToggle + ); + await browser.clickParent( + Selectors.GlobalWrites.shardKeyFormIndexType(formData.keyType) + ); + } + await browser.clickVisible(Selectors.GlobalWrites.ShardKeyFormSubmitButton); +} + +async function waitForState( + browser: CompassBrowser, + nextState: GeoShardingState +) { + await browser.waitUntil(async () => { + const content = await browser.$( + Selectors.GlobalWrites.tabStatus(nextState) + ); + return await content.isDisplayed(); + }); +} + +async function clickConfirmationAction( + browser: CompassBrowser, + actionSelector: string +) { + await browser.clickVisible(actionSelector); + + const modalElement = await browser.$(Selectors.ConfirmationModal); + await modalElement.waitForDisplayed(); + + await browser.clickVisible(Selectors.confirmationModalConfirmButton()); + await modalElement.waitForDisplayed({ reverse: true }); +} + +describe('Global writes', function () { + let compass: Compass; + let browser: CompassBrowser; + + before(async function () { + compass = await init(this.test?.fullTitle()); + browser = compass.browser; + await browser.setupDefaultConnections(); + }); + + before(function () { + if (!isTestingAtlasCloudSandbox()) { + this.skip(); + } + }); + + after(async function () { + await cleanup(compass); + }); + + it('should be able to shard an unsharded namespace and also unmanage it', async function () { + // Sharding a collection takes a bit longer + this.timeout(60_000); + + await createGeospatialCollection(); + await browser.connectToDefaults(); + await browser.navigateToCollectionTab( + DEFAULT_CONNECTION_NAMES[0], + 'test', + 'geospatial', + 'GlobalWrites' + ); + + // Initial state is loading + await waitForState(browser, 'UNSHARDED'); + + await createGeoShardKey(browser, { + secondShardKey: 'country', + keyType: 'HASHED', + }); + + // Wait for the shard key to be correct. + await waitForState(browser, 'SHARD_KEY_CORRECT'); + + // Expectations to see the shard key in the UI + const findingDocumentsText = await browser + .$(Selectors.GlobalWrites.SampleFindingDocuments) + .getText(); + + const insertedDocumentsText = await browser + .$(Selectors.GlobalWrites.SampleInsertingDocuments) + .getText(); + + expect(findingDocumentsText).to.include('country'); + expect(insertedDocumentsText).to.include('country'); + + // Unmanage the namespace + await browser.clickVisible(Selectors.GlobalWrites.UnmanageNamespaceButton); + + // It transitions to the unmanaging state + await waitForState(browser, 'UNSHARDED'); + }); + + it('should be able to shard an unsharded namespace and cancel the operation', async function () { + await createGeospatialCollection(); + await browser.connectToDefaults(); + await browser.navigateToCollectionTab( + DEFAULT_CONNECTION_NAMES[0], + 'test', + 'geospatial', + 'GlobalWrites' + ); + + // Initial state is loading + await waitForState(browser, 'UNSHARDED'); + + await createGeoShardKey(browser, { + secondShardKey: 'country', + keyType: 'UNIQUE', + }); + + // Wait for the shard key to be correct. + await waitForState(browser, 'SHARDING'); + + // Cancel the sharding operation. + await clickConfirmationAction( + browser, + Selectors.GlobalWrites.CancelShardingButton + ); + + // After its cancelled, it should transition back to the unsharded state + await waitForState(browser, 'UNSHARDED'); + }); +}); diff --git a/packages/compass-global-writes/src/components/create-shard-key-form.tsx b/packages/compass-global-writes/src/components/create-shard-key-form.tsx index 19c801e7b1d..34fe299ad69 100644 --- a/packages/compass-global-writes/src/components/create-shard-key-form.tsx +++ b/packages/compass-global-writes/src/components/create-shard-key-form.tsx @@ -190,6 +190,7 @@ export function CreateShardKeyForm({ @@ -255,6 +257,7 @@ export function CreateShardKeyForm({ diff --git a/packages/compass-global-writes/src/components/index.tsx b/packages/compass-global-writes/src/components/index.tsx index f27f9c2a989..71efe3bde3c 100644 --- a/packages/compass-global-writes/src/components/index.tsx +++ b/packages/compass-global-writes/src/components/index.tsx @@ -98,7 +98,10 @@ function ShardingStateView({ export function GlobalWrites({ shardingStatus }: GlobalWritesProps) { return ( -
+
From 84cdf1c06e80226addced579ed4bc89057795ccd Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Fri, 1 Nov 2024 11:52:51 +0100 Subject: [PATCH 02/15] clean up confirmation action --- .../commands/click-confirmation-action.ts | 28 +++++++++++++++++++ .../helpers/commands/hide-index.ts | 18 +++--------- .../helpers/commands/index.ts | 1 + .../helpers/commands/unhide-index.ts | 17 +++-------- .../tests/atlas-cloud/global-writes.test.ts | 16 +---------- .../tests/collection-aggregations-tab.test.ts | 22 ++------------- .../tests/connection-form.test.ts | 9 +----- .../tests/my-queries-tab.test.ts | 8 ++---- .../tests/protect-connection-strings.test.ts | 5 +--- .../tests/search-indexes.test.ts | 12 +++----- 10 files changed, 50 insertions(+), 86 deletions(-) create mode 100644 packages/compass-e2e-tests/helpers/commands/click-confirmation-action.ts diff --git a/packages/compass-e2e-tests/helpers/commands/click-confirmation-action.ts b/packages/compass-e2e-tests/helpers/commands/click-confirmation-action.ts new file mode 100644 index 00000000000..9524c4ef5a3 --- /dev/null +++ b/packages/compass-e2e-tests/helpers/commands/click-confirmation-action.ts @@ -0,0 +1,28 @@ +import type { CompassBrowser } from '../compass-browser'; +import * as Selectors from '../selectors'; + +export async function clickConfirmationAction( + browser: CompassBrowser, + actionButtonSelector: string, + confirmationText?: string, + screenshot?: string +) { + await browser.clickVisible(actionButtonSelector); + + const confirmationModal = await browser.$(Selectors.ConfirmationModal); + await confirmationModal.waitForDisplayed(); + + if (confirmationText) { + await browser.setValueVisible( + Selectors.ConfirmationModalInput, + confirmationText + ); + } + + if (screenshot) { + await browser.screenshot(screenshot); + } + + await browser.clickVisible(Selectors.confirmationModalConfirmButton()); + await confirmationModal.waitForDisplayed({ reverse: true }); +} diff --git a/packages/compass-e2e-tests/helpers/commands/hide-index.ts b/packages/compass-e2e-tests/helpers/commands/hide-index.ts index ed1d0e5b6c6..d082ab91a98 100644 --- a/packages/compass-e2e-tests/helpers/commands/hide-index.ts +++ b/packages/compass-e2e-tests/helpers/commands/hide-index.ts @@ -11,21 +11,11 @@ export async function hideIndex( await indexComponent.waitForDisplayed(); await browser.hover(indexComponentSelector); - await browser.clickVisible( - `${indexComponentSelector} ${Selectors.HideIndexButton}` + await browser.clickConfirmationAction( + `${indexComponentSelector} ${Selectors.HideIndexButton}`, + undefined, + screenshotName ); - - const hideModal = await browser.$(Selectors.ConfirmationModal); - await hideModal.waitForDisplayed(); - - if (screenshotName) { - await browser.screenshot(screenshotName); - } - - await browser.clickVisible(Selectors.confirmationModalConfirmButton()); - - await hideModal.waitForDisplayed({ reverse: true }); - const hiddenBadge = await browser.$(Selectors.HiddenIndexBadge(indexName)); await hiddenBadge.waitForDisplayed(); } diff --git a/packages/compass-e2e-tests/helpers/commands/index.ts b/packages/compass-e2e-tests/helpers/commands/index.ts index 2ad04e81f01..080501905f9 100644 --- a/packages/compass-e2e-tests/helpers/commands/index.ts +++ b/packages/compass-e2e-tests/helpers/commands/index.ts @@ -64,3 +64,4 @@ export * from './hide-visible-toasts'; export * from './sidebar-collection'; export * from './read-first-document-content'; export * from './read-stage-operators'; +export * from './click-confirmation-action'; diff --git a/packages/compass-e2e-tests/helpers/commands/unhide-index.ts b/packages/compass-e2e-tests/helpers/commands/unhide-index.ts index 305ce3cea96..4d7e3905b7f 100644 --- a/packages/compass-e2e-tests/helpers/commands/unhide-index.ts +++ b/packages/compass-e2e-tests/helpers/commands/unhide-index.ts @@ -11,21 +11,12 @@ export async function unhideIndex( await indexComponent.waitForDisplayed(); await browser.hover(indexComponentSelector); - await browser.clickVisible( - `${indexComponentSelector} ${Selectors.UnhideIndexButton}` + await browser.clickConfirmationAction( + `${indexComponentSelector} ${Selectors.UnhideIndexButton}`, + undefined, + screenshotName ); - const unhideModal = await browser.$(Selectors.ConfirmationModal); - await unhideModal.waitForDisplayed(); - - if (screenshotName) { - await browser.screenshot(screenshotName); - } - - await browser.clickVisible(Selectors.confirmationModalConfirmButton()); - - await unhideModal.waitForDisplayed({ reverse: true }); - const hiddenBadge = await browser.$(Selectors.HiddenIndexBadge(indexName)); await hiddenBadge.waitForDisplayed({ reverse: true }); } diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index 51cda604c6e..a08135eac57 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -48,19 +48,6 @@ async function waitForState( }); } -async function clickConfirmationAction( - browser: CompassBrowser, - actionSelector: string -) { - await browser.clickVisible(actionSelector); - - const modalElement = await browser.$(Selectors.ConfirmationModal); - await modalElement.waitForDisplayed(); - - await browser.clickVisible(Selectors.confirmationModalConfirmButton()); - await modalElement.waitForDisplayed({ reverse: true }); -} - describe('Global writes', function () { let compass: Compass; let browser: CompassBrowser; @@ -146,8 +133,7 @@ describe('Global writes', function () { await waitForState(browser, 'SHARDING'); // Cancel the sharding operation. - await clickConfirmationAction( - browser, + await browser.clickConfirmationAction( Selectors.GlobalWrites.CancelShardingButton ); diff --git a/packages/compass-e2e-tests/tests/collection-aggregations-tab.test.ts b/packages/compass-e2e-tests/tests/collection-aggregations-tab.test.ts index 2dd52fbe505..f4db128dfd3 100644 --- a/packages/compass-e2e-tests/tests/collection-aggregations-tab.test.ts +++ b/packages/compass-e2e-tests/tests/collection-aggregations-tab.test.ts @@ -1011,13 +1011,7 @@ describe('Collection aggregations tab', function () { it('shows confirmation modal when create new pipeline is clicked and aggregation is modified', async function () { await browser.selectStageOperator(0, '$match'); - - await browser.clickVisible(Selectors.CreateNewPipelineButton); - const modalElement = await browser.$(Selectors.ConfirmationModal); - await modalElement.waitForDisplayed(); - - await browser.clickVisible(Selectors.confirmationModalConfirmButton()); - await modalElement.waitForDisplayed({ reverse: true }); + await browser.clickConfirmationAction(Selectors.CreateNewPipelineButton); }); describe('aggregation builder in text mode', function () { @@ -1258,14 +1252,9 @@ describe('Collection aggregations tab', function () { ); await browser.hover(Selectors.AggregationSavedPipelineCard(name)); - await browser.clickVisible( + await browser.clickConfirmationAction( Selectors.AggregationSavedPipelineCardOpenButton(name) ); - - const confirmOpenModal = await browser.$(Selectors.ConfirmationModal); - await confirmOpenModal.waitForDisplayed(); - await browser.clickVisible(Selectors.confirmationModalConfirmButton()); - await confirmOpenModal.waitForDisplayed({ reverse: true }); }); it('deletes an aggregation', async function () { @@ -1278,14 +1267,9 @@ describe('Collection aggregations tab', function () { ); await browser.hover(Selectors.AggregationSavedPipelineCard(name)); - await browser.clickVisible( + await browser.clickConfirmationAction( Selectors.AggregationSavedPipelineCardDeleteButton(name) ); - - const confirmDeleteModal = await browser.$(Selectors.ConfirmationModal); - await confirmDeleteModal.waitForDisplayed(); - await browser.clickVisible(Selectors.confirmationModalConfirmButton()); - await confirmDeleteModal.waitForDisplayed({ reverse: true }); }); }); diff --git a/packages/compass-e2e-tests/tests/connection-form.test.ts b/packages/compass-e2e-tests/tests/connection-form.test.ts index 111c074f761..98a53f17563 100644 --- a/packages/compass-e2e-tests/tests/connection-form.test.ts +++ b/packages/compass-e2e-tests/tests/connection-form.test.ts @@ -670,14 +670,7 @@ describe('Connection form', function () { // toggle the edit connection string toggle twice await browser.clickVisible(Selectors.EditConnectionStringToggle); expect(await toggle.getAttribute('aria-checked')).to.equal('false'); - await browser.clickVisible(Selectors.EditConnectionStringToggle); - - const confirmModal = await browser.$(Selectors.ConfirmationModal); - await confirmModal.waitForDisplayed(); - - await browser.clickVisible(Selectors.confirmationModalConfirmButton()); - - await confirmModal.waitForDisplayed({ reverse: true }); + await browser.clickConfirmationAction(Selectors.EditConnectionStringToggle); // the toggle should now be on expect(await toggle.getAttribute('aria-checked')).to.equal('true'); diff --git a/packages/compass-e2e-tests/tests/my-queries-tab.test.ts b/packages/compass-e2e-tests/tests/my-queries-tab.test.ts index 58d833dfdf1..2b57d35e2c1 100644 --- a/packages/compass-e2e-tests/tests/my-queries-tab.test.ts +++ b/packages/compass-e2e-tests/tests/my-queries-tab.test.ts @@ -301,11 +301,9 @@ describe('My Queries tab', function () { await openMenuForQueryItem(browser, newFavoriteQueryName); // delete it - await browser.clickVisible(Selectors.SavedItemMenuItemDelete); - const deleteModal = await browser.$(Selectors.ConfirmationModal); - await deleteModal.waitForDisplayed(); - await browser.clickVisible(Selectors.confirmationModalConfirmButton()); - await renameModal.waitForDisplayed({ reverse: true }); + await browser.clickConfirmationAction( + Selectors.SavedItemMenuItemDelete + ); }); it('opens a saved aggregation', async function () { diff --git a/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts b/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts index c20ebc3476f..69197382d29 100644 --- a/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts +++ b/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts @@ -87,10 +87,7 @@ describe('protectConnectionStrings', function () { ); // Enter edit connection string mode - await browser.clickVisible(Selectors.EditConnectionStringToggle); - const confirmModal = await browser.$(Selectors.ConfirmationModal); - await confirmModal.waitForDisplayed(); - await browser.clickVisible(Selectors.confirmationModalConfirmButton()); + await browser.clickConfirmationAction(Selectors.EditConnectionStringToggle); expect( await browser.getConnectFormConnectionString(), diff --git a/packages/compass-e2e-tests/tests/search-indexes.test.ts b/packages/compass-e2e-tests/tests/search-indexes.test.ts index dbe41df9ada..264ecbc40ec 100644 --- a/packages/compass-e2e-tests/tests/search-indexes.test.ts +++ b/packages/compass-e2e-tests/tests/search-indexes.test.ts @@ -108,15 +108,11 @@ async function dropSearchIndex(browser: CompassBrowser, indexName: string) { await indexRow.waitForDisplayed(); await browser.hover(indexRowSelector); - await browser.clickVisible(Selectors.searchIndexDropButton(indexName)); - const modal = await browser.$(Selectors.ConfirmationModal); - await modal.waitForDisplayed(); - - await browser.setValueVisible(Selectors.ConfirmationModalInput, indexName); - - await browser.clickVisible(Selectors.confirmationModalConfirmButton()); - await modal.waitForDisplayed({ reverse: true }); + await browser.clickConfirmationAction( + Selectors.searchIndexDropButton(indexName), + indexName + ); await indexRow.waitForExist({ reverse: true, From 28b6724a7dd745cf24d634cd6d4d501f66a2148d Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Fri, 1 Nov 2024 11:56:33 +0100 Subject: [PATCH 03/15] rename func --- .../tests/atlas-cloud/global-writes.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index a08135eac57..93d88da8e71 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -36,7 +36,7 @@ async function createGeoShardKey( await browser.clickVisible(Selectors.GlobalWrites.ShardKeyFormSubmitButton); } -async function waitForState( +async function waitForGlobalWritesStatus( browser: CompassBrowser, nextState: GeoShardingState ) { @@ -82,7 +82,7 @@ describe('Global writes', function () { ); // Initial state is loading - await waitForState(browser, 'UNSHARDED'); + await waitForGlobalWritesStatus(browser, 'UNSHARDED'); await createGeoShardKey(browser, { secondShardKey: 'country', @@ -90,7 +90,7 @@ describe('Global writes', function () { }); // Wait for the shard key to be correct. - await waitForState(browser, 'SHARD_KEY_CORRECT'); + await waitForGlobalWritesStatus(browser, 'SHARD_KEY_CORRECT'); // Expectations to see the shard key in the UI const findingDocumentsText = await browser @@ -108,7 +108,7 @@ describe('Global writes', function () { await browser.clickVisible(Selectors.GlobalWrites.UnmanageNamespaceButton); // It transitions to the unmanaging state - await waitForState(browser, 'UNSHARDED'); + await waitForGlobalWritesStatus(browser, 'UNSHARDED'); }); it('should be able to shard an unsharded namespace and cancel the operation', async function () { @@ -122,7 +122,7 @@ describe('Global writes', function () { ); // Initial state is loading - await waitForState(browser, 'UNSHARDED'); + await waitForGlobalWritesStatus(browser, 'UNSHARDED'); await createGeoShardKey(browser, { secondShardKey: 'country', @@ -130,7 +130,7 @@ describe('Global writes', function () { }); // Wait for the shard key to be correct. - await waitForState(browser, 'SHARDING'); + await waitForGlobalWritesStatus(browser, 'SHARDING'); // Cancel the sharding operation. await browser.clickConfirmationAction( @@ -138,6 +138,6 @@ describe('Global writes', function () { ); // After its cancelled, it should transition back to the unsharded state - await waitForState(browser, 'UNSHARDED'); + await waitForGlobalWritesStatus(browser, 'UNSHARDED'); }); }); From 271ceda52d40327b1b40dad0982a475885890550 Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Fri, 1 Nov 2024 14:59:26 +0100 Subject: [PATCH 04/15] cr feedback --- .evergreen/start-atlas-cloud-cluster.sh | 7 +++---- packages/compass-e2e-tests/helpers/selectors.ts | 3 +-- .../tests/atlas-cloud/global-writes.test.ts | 3 --- packages/compass-global-writes/src/components/index.tsx | 5 +---- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.evergreen/start-atlas-cloud-cluster.sh b/.evergreen/start-atlas-cloud-cluster.sh index 0f5fe2bdd60..ae7e59043f6 100644 --- a/.evergreen/start-atlas-cloud-cluster.sh +++ b/.evergreen/start-atlas-cloud-cluster.sh @@ -16,6 +16,9 @@ # # - Setup a new org and project. Save the org id and project id for later. # +# - Add payment details within the organization (Billing) to be able to create +# clusters. You can use test stripe card for that (4242 4242 4242 4242). +# # - Create new db user with username / password auth and admin role. This user # will be used to prepopulate dbs with data in tests. Save the credentials. # @@ -47,10 +50,6 @@ # (ATLAS_CLOUD_TEST_CLUSTER_NAME="TestCluster" source .evergreen/start-atlas-cloud-cluster.sh \ # && npm run -w compass-e2e-tests test web -- --test-atlas-cloud-sandbox --test-filter="atlas-cloud/**/*") # -# When setting up for the first time, make sure you: -# - Add payment details to be able to create clusters. You can use stripe test card. -# - Allow network access to the project for your IP address. - _ATLAS_CLOUD_TEST_CLUSTER_NAME=${ATLAS_CLOUD_TEST_CLUSTER_NAME:-""} # Atlas limits the naming to something like /^[\w\d-]{,23}$/ (and will auto diff --git a/packages/compass-e2e-tests/helpers/selectors.ts b/packages/compass-e2e-tests/helpers/selectors.ts index 67291f93153..f9d323bbd43 100644 --- a/packages/compass-e2e-tests/helpers/selectors.ts +++ b/packages/compass-e2e-tests/helpers/selectors.ts @@ -1402,8 +1402,7 @@ export const ProxyCustomButton = export const ConfirmTabCloseModal = '[data-testid="confirm-tab-close"]'; export const GlobalWrites = { - tabStatus: (status: string) => - `[data-testid="${status.toLowerCase()}-status"]`, + tabStatus: (status: string) => `[data-status="${status.toLowerCase()}"]`, ShardKeyFormSecondKeyInputCombobox: '[data-testid="second-shard-key"] [role="combobox"] input', diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index 93d88da8e71..2665441a854 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -69,9 +69,6 @@ describe('Global writes', function () { }); it('should be able to shard an unsharded namespace and also unmanage it', async function () { - // Sharding a collection takes a bit longer - this.timeout(60_000); - await createGeospatialCollection(); await browser.connectToDefaults(); await browser.navigateToCollectionTab( diff --git a/packages/compass-global-writes/src/components/index.tsx b/packages/compass-global-writes/src/components/index.tsx index 71efe3bde3c..2156be1b1ff 100644 --- a/packages/compass-global-writes/src/components/index.tsx +++ b/packages/compass-global-writes/src/components/index.tsx @@ -98,10 +98,7 @@ function ShardingStateView({ export function GlobalWrites({ shardingStatus }: GlobalWritesProps) { return ( -
+
From cd12414352f227149fdaeeca5f4a5ecf9fed3bf0 Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Fri, 1 Nov 2024 15:09:31 +0100 Subject: [PATCH 05/15] timeout --- .../compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index 2665441a854..b58e474d655 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -52,7 +52,9 @@ describe('Global writes', function () { let compass: Compass; let browser: CompassBrowser; - before(async function () { + beforeEach(async function () { + // Sharding a collection takes a bit longer + this.timeout(1000 * 60 * 20); compass = await init(this.test?.fullTitle()); browser = compass.browser; await browser.setupDefaultConnections(); From 8b3da4a6e434ce0e723493ab4221e570e2f8b360 Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Fri, 1 Nov 2024 15:10:42 +0100 Subject: [PATCH 06/15] fix doc --- .evergreen/start-atlas-cloud-cluster.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.evergreen/start-atlas-cloud-cluster.sh b/.evergreen/start-atlas-cloud-cluster.sh index c4f9f46b8ea..5d70b6712d0 100644 --- a/.evergreen/start-atlas-cloud-cluster.sh +++ b/.evergreen/start-atlas-cloud-cluster.sh @@ -17,7 +17,9 @@ DELETE_AFTER="$(date -u -Iseconds -d '+2 hours' 2>/dev/null || date -u -Iseconds # You can only use your work emails with a subaddress to create those (e.g, # jane.doe+for-testing@mongodb.com). # -# - Setup a new org and project. Save the org id and project id for later.# - Add payment details within the organization (Billing) to be able to create +# - Setup a new org and project. Save the org id and project id for later. +# +# - Add payment details within the organization (Billing) to be able to create # clusters. You can use test stripe card for that (4242 4242 4242 4242). # # - Create a new API key (Access Manager > Project Access > Create Application > @@ -45,6 +47,7 @@ DELETE_AFTER="$(date -u -Iseconds -d '+2 hours' 2>/dev/null || date -u -Iseconds # # (ATLAS_CLOUD_TEST_CLUSTER_NAME="TestCluster" source .evergreen/start-atlas-cloud-cluster.sh \ # && npm run -w compass-e2e-tests test web -- --test-atlas-cloud-sandbox --test-filter="atlas-cloud/**/*") + _ATLAS_CLOUD_TEST_CLUSTER_NAME=${ATLAS_CLOUD_TEST_CLUSTER_NAME:-""} # Atlas limits the naming to something like /^[\w\d-]{,23}$/ (and will auto From 06cea2696cad3c93cd8563eb6626745744329026 Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Fri, 1 Nov 2024 14:59:26 +0100 Subject: [PATCH 07/15] cr feedback --- .evergreen/start-atlas-cloud-cluster.sh | 7 +++---- packages/compass-e2e-tests/helpers/selectors.ts | 3 +-- .../tests/atlas-cloud/global-writes.test.ts | 7 +++---- packages/compass-global-writes/src/components/index.tsx | 5 +---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.evergreen/start-atlas-cloud-cluster.sh b/.evergreen/start-atlas-cloud-cluster.sh index 0f5fe2bdd60..b52ff83370c 100644 --- a/.evergreen/start-atlas-cloud-cluster.sh +++ b/.evergreen/start-atlas-cloud-cluster.sh @@ -16,6 +16,9 @@ # # - Setup a new org and project. Save the org id and project id for later. # +# - Add test payment details within the organization (Billing) to be able to +# create clusters. +# # - Create new db user with username / password auth and admin role. This user # will be used to prepopulate dbs with data in tests. Save the credentials. # @@ -46,10 +49,6 @@ # # (ATLAS_CLOUD_TEST_CLUSTER_NAME="TestCluster" source .evergreen/start-atlas-cloud-cluster.sh \ # && npm run -w compass-e2e-tests test web -- --test-atlas-cloud-sandbox --test-filter="atlas-cloud/**/*") -# -# When setting up for the first time, make sure you: -# - Add payment details to be able to create clusters. You can use stripe test card. -# - Allow network access to the project for your IP address. _ATLAS_CLOUD_TEST_CLUSTER_NAME=${ATLAS_CLOUD_TEST_CLUSTER_NAME:-""} diff --git a/packages/compass-e2e-tests/helpers/selectors.ts b/packages/compass-e2e-tests/helpers/selectors.ts index 67291f93153..f9d323bbd43 100644 --- a/packages/compass-e2e-tests/helpers/selectors.ts +++ b/packages/compass-e2e-tests/helpers/selectors.ts @@ -1402,8 +1402,7 @@ export const ProxyCustomButton = export const ConfirmTabCloseModal = '[data-testid="confirm-tab-close"]'; export const GlobalWrites = { - tabStatus: (status: string) => - `[data-testid="${status.toLowerCase()}-status"]`, + tabStatus: (status: string) => `[data-status="${status.toLowerCase()}"]`, ShardKeyFormSecondKeyInputCombobox: '[data-testid="second-shard-key"] [role="combobox"] input', diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index 93d88da8e71..b58e474d655 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -52,7 +52,9 @@ describe('Global writes', function () { let compass: Compass; let browser: CompassBrowser; - before(async function () { + beforeEach(async function () { + // Sharding a collection takes a bit longer + this.timeout(1000 * 60 * 20); compass = await init(this.test?.fullTitle()); browser = compass.browser; await browser.setupDefaultConnections(); @@ -69,9 +71,6 @@ describe('Global writes', function () { }); it('should be able to shard an unsharded namespace and also unmanage it', async function () { - // Sharding a collection takes a bit longer - this.timeout(60_000); - await createGeospatialCollection(); await browser.connectToDefaults(); await browser.navigateToCollectionTab( diff --git a/packages/compass-global-writes/src/components/index.tsx b/packages/compass-global-writes/src/components/index.tsx index 71efe3bde3c..2156be1b1ff 100644 --- a/packages/compass-global-writes/src/components/index.tsx +++ b/packages/compass-global-writes/src/components/index.tsx @@ -98,10 +98,7 @@ function ShardingStateView({ export function GlobalWrites({ shardingStatus }: GlobalWritesProps) { return ( -
+
From 2d6345df7ce44b12c6ddffc48a23dd005826ea97 Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Fri, 1 Nov 2024 16:43:13 +0100 Subject: [PATCH 08/15] clean up --- .../tests/atlas-cloud/global-writes.test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index b58e474d655..ba5543e9942 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -13,13 +13,12 @@ type GeoShardingFormData = { keyType?: 'UNIQUE' | 'HASHED'; }; -type GeoShardingState = 'UNSHARDED' | 'SHARDING' | 'SHARD_KEY_CORRECT'; +type GeoShardingStatus = 'UNSHARDED' | 'SHARDING' | 'SHARD_KEY_CORRECT'; async function createGeoShardKey( browser: CompassBrowser, formData: GeoShardingFormData ) { - // shard-collection-form await browser.setComboBoxValue( Selectors.GlobalWrites.ShardKeyFormSecondKeyInputCombobox, formData.secondShardKey @@ -38,11 +37,11 @@ async function createGeoShardKey( async function waitForGlobalWritesStatus( browser: CompassBrowser, - nextState: GeoShardingState + nextStatus: GeoShardingStatus ) { await browser.waitUntil(async () => { const content = await browser.$( - Selectors.GlobalWrites.tabStatus(nextState) + Selectors.GlobalWrites.tabStatus(nextStatus) ); return await content.isDisplayed(); }); From 994044d16503a8e41aa2065d1376c7bbad11cbaf Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Mon, 4 Nov 2024 12:10:29 +0100 Subject: [PATCH 09/15] sensable selector --- packages/compass-e2e-tests/helpers/selectors.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/compass-e2e-tests/helpers/selectors.ts b/packages/compass-e2e-tests/helpers/selectors.ts index f9d323bbd43..8e8b9bfcfdb 100644 --- a/packages/compass-e2e-tests/helpers/selectors.ts +++ b/packages/compass-e2e-tests/helpers/selectors.ts @@ -1402,7 +1402,8 @@ export const ProxyCustomButton = export const ConfirmTabCloseModal = '[data-testid="confirm-tab-close"]'; export const GlobalWrites = { - tabStatus: (status: string) => `[data-status="${status.toLowerCase()}"]`, + tabStatus: (status: string) => + `[data-testid="globalwrites-content"] > [data-status="${status.toLowerCase()}"]`, ShardKeyFormSecondKeyInputCombobox: '[data-testid="second-shard-key"] [role="combobox"] input', From ee2ee6dc3a4b16b442750c1d3944cdb3cdc70dbb Mon Sep 17 00:00:00 2001 From: Basit Chonka Date: Mon, 4 Nov 2024 14:28:11 +0100 Subject: [PATCH 10/15] use timeout for wait condition as well --- .../tests/atlas-cloud/global-writes.test.ts | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index ba5543e9942..7e9a29e90cc 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -15,6 +15,9 @@ type GeoShardingFormData = { type GeoShardingStatus = 'UNSHARDED' | 'SHARDING' | 'SHARD_KEY_CORRECT'; +const WEBDRIVER_TIMEOUT = 1000 * 60 * 20; +const MOCHA_TIMEOUT = WEBDRIVER_TIMEOUT * 1.2; + async function createGeoShardKey( browser: CompassBrowser, formData: GeoShardingFormData @@ -39,12 +42,15 @@ async function waitForGlobalWritesStatus( browser: CompassBrowser, nextStatus: GeoShardingStatus ) { - await browser.waitUntil(async () => { - const content = await browser.$( - Selectors.GlobalWrites.tabStatus(nextStatus) - ); - return await content.isDisplayed(); - }); + await browser.waitUntil( + async () => { + const content = await browser.$( + Selectors.GlobalWrites.tabStatus(nextStatus) + ); + return await content.isDisplayed(); + }, + { timeout: WEBDRIVER_TIMEOUT } + ); } describe('Global writes', function () { @@ -53,7 +59,7 @@ describe('Global writes', function () { beforeEach(async function () { // Sharding a collection takes a bit longer - this.timeout(1000 * 60 * 20); + this.timeout(MOCHA_TIMEOUT); compass = await init(this.test?.fullTitle()); browser = compass.browser; await browser.setupDefaultConnections(); From c72a44a67e1e7e7e65ea5db9d8f9fe325bbca6ef Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Fri, 8 Nov 2024 13:10:52 +0100 Subject: [PATCH 11/15] chore(e2e): use different collection names between tests --- .evergreen/start-atlas-cloud-cluster.sh | 4 +- .../compass-e2e-tests/helpers/insert-data.ts | 6 ++- .../helpers/test-runner-context.ts | 2 +- .../tests/atlas-cloud/global-writes.test.ts | 48 +++++++++++-------- .../tests/atlas-cloud/rolling-indexes.test.ts | 5 +- 5 files changed, 37 insertions(+), 28 deletions(-) diff --git a/.evergreen/start-atlas-cloud-cluster.sh b/.evergreen/start-atlas-cloud-cluster.sh index 73a33fb8aa6..5c38b3d1f14 100644 --- a/.evergreen/start-atlas-cloud-cluster.sh +++ b/.evergreen/start-atlas-cloud-cluster.sh @@ -104,11 +104,11 @@ 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 \ +(atlascli clusters create $ATLAS_CLUSTER_NAME \ --provider AWS \ --region US_EAST_1 \ --tier M10 \ - --type GEOSHARDED + --type GEOSHARDED || true) # can error if custom name was provided, will fail on next step if it's not expected failure echo "Waiting for the deployment to be provisioned..." atlascli clusters watch $ATLAS_CLUSTER_NAME diff --git a/packages/compass-e2e-tests/helpers/insert-data.ts b/packages/compass-e2e-tests/helpers/insert-data.ts index ab0fa1894b8..aa17255aad5 100644 --- a/packages/compass-e2e-tests/helpers/insert-data.ts +++ b/packages/compass-e2e-tests/helpers/insert-data.ts @@ -168,13 +168,15 @@ export async function createNumbersStringCollection( ); } -export async function createGeospatialCollection(): Promise { +export async function createGeospatialCollection( + name = 'geospatial' +): Promise { await Promise.all( test_dbs.map(async (db) => { const lon = () => Math.random() * 360 - 180; const lat = () => Math.random() * 180 - 90; - await db.collection('geospatial').insertMany( + await db.collection(name).insertMany( [...Array(1000).keys()].map(() => ({ location: { type: 'Point', coordinates: [lon(), lat()] }, })) diff --git a/packages/compass-e2e-tests/helpers/test-runner-context.ts b/packages/compass-e2e-tests/helpers/test-runner-context.ts index e9ed908a4e4..2c73d855471 100644 --- a/packages/compass-e2e-tests/helpers/test-runner-context.ts +++ b/packages/compass-e2e-tests/helpers/test-runner-context.ts @@ -39,7 +39,7 @@ function buildCommonArgs(yargs: Argv) { .option('webdriver-waitfor-timeout', { type: 'number', description: 'Set a custom default webdriver waitFor timeout', - default: 120_000, // webdriver default is 3000ms + default: 1000 * 60 * 2, // 2min, webdriver default is 3s }) .option('webdriver-waitfor-interval', { type: 'number', diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index 7e9a29e90cc..df30f862ff1 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -1,6 +1,11 @@ import { expect } from 'chai'; import type { Compass } from '../../helpers/compass'; -import { cleanup, init, Selectors } from '../../helpers/compass'; +import { + cleanup, + init, + screenshotIfFailed, + Selectors, +} from '../../helpers/compass'; import type { CompassBrowser } from '../../helpers/compass-browser'; import { createGeospatialCollection } from '../../helpers/insert-data'; import { @@ -15,7 +20,7 @@ type GeoShardingFormData = { type GeoShardingStatus = 'UNSHARDED' | 'SHARDING' | 'SHARD_KEY_CORRECT'; -const WEBDRIVER_TIMEOUT = 1000 * 60 * 20; +const WEBDRIVER_TIMEOUT = 1000 * 60 * 10; const MOCHA_TIMEOUT = WEBDRIVER_TIMEOUT * 1.2; async function createGeoShardKey( @@ -44,44 +49,47 @@ async function waitForGlobalWritesStatus( ) { await browser.waitUntil( async () => { - const content = await browser.$( - Selectors.GlobalWrites.tabStatus(nextStatus) - ); - return await content.isDisplayed(); + return await browser + .$(Selectors.GlobalWrites.tabStatus(nextStatus)) + .isDisplayed(); }, { timeout: WEBDRIVER_TIMEOUT } ); } describe('Global writes', function () { + // Sharding a collection takes a bit longer + this.timeout(MOCHA_TIMEOUT); + let compass: Compass; let browser: CompassBrowser; - beforeEach(async function () { - // Sharding a collection takes a bit longer - this.timeout(MOCHA_TIMEOUT); - compass = await init(this.test?.fullTitle()); - browser = compass.browser; - await browser.setupDefaultConnections(); - }); - before(function () { if (!isTestingAtlasCloudSandbox()) { this.skip(); } }); - after(async function () { + beforeEach(async function () { + compass = await init(this.test?.fullTitle()); + browser = compass.browser; + await browser.setupDefaultConnections(); + }); + + afterEach(async function () { + await screenshotIfFailed(compass, this.currentTest); await cleanup(compass); }); it('should be able to shard an unsharded namespace and also unmanage it', async function () { - await createGeospatialCollection(); + const collName = `global-writes-geospatial-${Date.now()}`; + + await createGeospatialCollection(collName); await browser.connectToDefaults(); await browser.navigateToCollectionTab( DEFAULT_CONNECTION_NAMES[0], 'test', - 'geospatial', + collName, 'GlobalWrites' ); @@ -116,12 +124,14 @@ describe('Global writes', function () { }); it('should be able to shard an unsharded namespace and cancel the operation', async function () { - await createGeospatialCollection(); + const collName = `global-writes-geospatial-${Date.now()}`; + + await createGeospatialCollection(collName); await browser.connectToDefaults(); await browser.navigateToCollectionTab( DEFAULT_CONNECTION_NAMES[0], 'test', - 'geospatial', + collName, 'GlobalWrites' ); diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/rolling-indexes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/rolling-indexes.test.ts index f09b7afcd85..b1c09749fa5 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/rolling-indexes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/rolling-indexes.test.ts @@ -30,15 +30,12 @@ describe('Rolling indexes', function () { afterEach(async function () { await screenshotIfFailed(compass, this.currentTest); - }); - - after(async function () { await cleanup(compass); }); it('should be able to create, list, and delete rolling indexes', async function () { // Building rolling indexes is a slow process - const extendedRollingIndexesTimeout = 1000 * 60 * 20; + const extendedRollingIndexesTimeout = 1000 * 60 * 10; this.timeout(extendedRollingIndexesTimeout * 1.2); From 3ada5f48af6a5e37bd82ed41b66910ba62444f77 Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Mon, 11 Nov 2024 11:50:22 +0100 Subject: [PATCH 12/15] chore(e2e): temporarily skip failing test --- .../tests/atlas-cloud/global-writes.test.ts | 11 +++++++++-- .../tests/atlas-cloud/rolling-indexes.test.ts | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index df30f862ff1..7d4df6ff8a3 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -53,7 +53,12 @@ async function waitForGlobalWritesStatus( .$(Selectors.GlobalWrites.tabStatus(nextStatus)) .isDisplayed(); }, - { timeout: WEBDRIVER_TIMEOUT } + { + timeout: WEBDRIVER_TIMEOUT, + // Sharding is slow process, no need to check too often, just makes the + // logs hard to read + interval: 2_000, + } ); } @@ -81,7 +86,9 @@ describe('Global writes', function () { await cleanup(compass); }); - it('should be able to shard an unsharded namespace and also unmanage it', async function () { + // TODO(COMPASS-8495): This test fails in CI, while we can't reproduce this + // locally, it looks like a real issue that needs investigation + it.skip('should be able to shard an unsharded namespace and also unmanage it', async function () { const collName = `global-writes-geospatial-${Date.now()}`; await createGeospatialCollection(collName); diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/rolling-indexes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/rolling-indexes.test.ts index b1c09749fa5..e3189ba7135 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/rolling-indexes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/rolling-indexes.test.ts @@ -74,7 +74,12 @@ describe('Rolling indexes', function () { await browser .$(Selectors.indexComponent(indexName)) .$('[data-testid="index-ready"]') - .waitForDisplayed({ timeout: extendedRollingIndexesTimeout }); + .waitForDisplayed({ + timeout: extendedRollingIndexesTimeout, + // Building a rolling index is a slow process, no need to check too + // often + interval: 2_000, + }); // Now that it's ready, delete it (it will also check that it's eventually // removed from the list) From 9e279bca27f6e6ddd64a17b85363504f28d07b49 Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Mon, 11 Nov 2024 12:25:21 +0100 Subject: [PATCH 13/15] update test after incomplete sharding status --- packages/compass-e2e-tests/helpers/selectors.ts | 1 + .../tests/atlas-cloud/global-writes.test.ts | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/compass-e2e-tests/helpers/selectors.ts b/packages/compass-e2e-tests/helpers/selectors.ts index 8e8b9bfcfdb..e137f94b4e3 100644 --- a/packages/compass-e2e-tests/helpers/selectors.ts +++ b/packages/compass-e2e-tests/helpers/selectors.ts @@ -1415,6 +1415,7 @@ export const GlobalWrites = { CancelShardingButton: '[data-testid="cancel-sharding-btn"]', UnmanageNamespaceButton: '[data-testid="unmanage-collection-button"]', + ManageNamespaceButton: '[data-testid="manage-collection-button"]', SampleFindingDocuments: '[data-testid="sample-finding-documents"]', SampleInsertingDocuments: '[data-testid="sample-inserting-documents"]', diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index 7d4df6ff8a3..f8db0a2069d 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -18,7 +18,11 @@ type GeoShardingFormData = { keyType?: 'UNIQUE' | 'HASHED'; }; -type GeoShardingStatus = 'UNSHARDED' | 'SHARDING' | 'SHARD_KEY_CORRECT'; +type GeoShardingStatus = + | 'UNSHARDED' + | 'SHARDING' + | 'SHARD_KEY_CORRECT' + | 'INCOMPLETE_SHARDING_SETUP'; const WEBDRIVER_TIMEOUT = 1000 * 60 * 10; const MOCHA_TIMEOUT = WEBDRIVER_TIMEOUT * 1.2; @@ -127,7 +131,15 @@ describe('Global writes', function () { await browser.clickVisible(Selectors.GlobalWrites.UnmanageNamespaceButton); // It transitions to the unmanaging state - await waitForGlobalWritesStatus(browser, 'UNSHARDED'); + await waitForGlobalWritesStatus(browser, 'INCOMPLETE_SHARDING_SETUP'); + + // This time there should be a button to manage the namespace again, but not the form + await browser + .$(Selectors.GlobalWrites.ManageNamespaceButton) + .waitForDisplayed(); + await browser + .$(Selectors.GlobalWrites.ShardKeyFormSecondKeyInputCombobox) + .waitForDisplayed({ reverse: true }); }); it('should be able to shard an unsharded namespace and cancel the operation', async function () { From 27c51b8fae8aeb266fe5fb4034001affeda60c37 Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Mon, 11 Nov 2024 12:54:00 +0100 Subject: [PATCH 14/15] try to re-enable the test --- .../compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index f8db0a2069d..be443052bac 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -92,7 +92,7 @@ describe('Global writes', function () { // TODO(COMPASS-8495): This test fails in CI, while we can't reproduce this // locally, it looks like a real issue that needs investigation - it.skip('should be able to shard an unsharded namespace and also unmanage it', async function () { + it('should be able to shard an unsharded namespace and also unmanage it', async function () { const collName = `global-writes-geospatial-${Date.now()}`; await createGeospatialCollection(collName); From 50dfc27e2772d7ee51825f1f074b08b9a9524b71 Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Mon, 11 Nov 2024 15:15:48 +0100 Subject: [PATCH 15/15] remove comment --- .../compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts index be443052bac..a45d5758761 100644 --- a/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts @@ -90,8 +90,6 @@ describe('Global writes', function () { await cleanup(compass); }); - // TODO(COMPASS-8495): This test fails in CI, while we can't reproduce this - // locally, it looks like a real issue that needs investigation it('should be able to shard an unsharded namespace and also unmanage it', async function () { const collName = `global-writes-geospatial-${Date.now()}`;