-
Notifications
You must be signed in to change notification settings - Fork 245
test(global-writes): add e2e tests COMPASS-8441 #6430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
90fbc55
84cdf1c
28b6724
271ceda
e11116c
cd12414
8b3da4a
06cea26
ad2a360
957f946
2d6345d
994044d
86c73ee
ee2ee6d
c72a44a
b62535d
3ada5f4
9e279bc
9138b22
27c51b8
50dfc27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 }); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| 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 waitForGlobalWritesStatus( | ||
| browser: CompassBrowser, | ||
| nextState: GeoShardingState | ||
| ) { | ||
| await browser.waitUntil(async () => { | ||
| const content = await browser.$( | ||
| Selectors.GlobalWrites.tabStatus(nextState) | ||
| ); | ||
| return await content.isDisplayed(); | ||
| }); | ||
| } | ||
|
|
||
| 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 waitForGlobalWritesStatus(browser, 'UNSHARDED'); | ||
|
|
||
| await createGeoShardKey(browser, { | ||
| secondShardKey: 'country', | ||
| keyType: 'HASHED', | ||
| }); | ||
|
|
||
| // Wait for the shard key to be correct. | ||
| await waitForGlobalWritesStatus(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 waitForGlobalWritesStatus(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 waitForGlobalWritesStatus(browser, 'UNSHARDED'); | ||
|
|
||
| await createGeoShardKey(browser, { | ||
| secondShardKey: 'country', | ||
| keyType: 'UNIQUE', | ||
| }); | ||
|
|
||
| // Wait for the shard key to be correct. | ||
| await waitForGlobalWritesStatus(browser, 'SHARDING'); | ||
|
|
||
| // Cancel the sharding operation. | ||
| await browser.clickConfirmationAction( | ||
| Selectors.GlobalWrites.CancelShardingButton | ||
| ); | ||
|
|
||
| // After its cancelled, it should transition back to the unsharded state | ||
| await waitForGlobalWritesStatus(browser, 'UNSHARDED'); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the documentation here! Can you move this to a more logical place where it would fit if you're doing these actions step by step? Probably either as part of creating a new org / project or as a step after it. The intention for the whole instruction above to be about setting up for the first time, so adding it as notes at the bottom of that is a bit weird 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah will do that!