Skip to content

Commit c72a44a

Browse files
committed
chore(e2e): use different collection names between tests
1 parent ee2ee6d commit c72a44a

File tree

5 files changed

+37
-28
lines changed

5 files changed

+37
-28
lines changed

.evergreen/start-atlas-cloud-cluster.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME="$ATLAS_TEST_DB_USERNAME"
104104
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD="$ATLAS_TEST_DB_PASSWORD"
105105

106106
echo "Creating Atlas deployment \`$ATLAS_CLUSTER_NAME\` to test against..."
107-
atlascli clusters create $ATLAS_CLUSTER_NAME \
107+
(atlascli clusters create $ATLAS_CLUSTER_NAME \
108108
--provider AWS \
109109
--region US_EAST_1 \
110110
--tier M10 \
111-
--type GEOSHARDED
111+
--type GEOSHARDED || true) # can error if custom name was provided, will fail on next step if it's not expected failure
112112

113113
echo "Waiting for the deployment to be provisioned..."
114114
atlascli clusters watch $ATLAS_CLUSTER_NAME

packages/compass-e2e-tests/helpers/insert-data.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ export async function createNumbersStringCollection(
168168
);
169169
}
170170

171-
export async function createGeospatialCollection(): Promise<void> {
171+
export async function createGeospatialCollection(
172+
name = 'geospatial'
173+
): Promise<void> {
172174
await Promise.all(
173175
test_dbs.map(async (db) => {
174176
const lon = () => Math.random() * 360 - 180;
175177
const lat = () => Math.random() * 180 - 90;
176178

177-
await db.collection('geospatial').insertMany(
179+
await db.collection(name).insertMany(
178180
[...Array(1000).keys()].map(() => ({
179181
location: { type: 'Point', coordinates: [lon(), lat()] },
180182
}))

packages/compass-e2e-tests/helpers/test-runner-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function buildCommonArgs(yargs: Argv) {
3939
.option('webdriver-waitfor-timeout', {
4040
type: 'number',
4141
description: 'Set a custom default webdriver waitFor timeout',
42-
default: 120_000, // webdriver default is 3000ms
42+
default: 1000 * 60 * 2, // 2min, webdriver default is 3s
4343
})
4444
.option('webdriver-waitfor-interval', {
4545
type: 'number',

packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { expect } from 'chai';
22
import type { Compass } from '../../helpers/compass';
3-
import { cleanup, init, Selectors } from '../../helpers/compass';
3+
import {
4+
cleanup,
5+
init,
6+
screenshotIfFailed,
7+
Selectors,
8+
} from '../../helpers/compass';
49
import type { CompassBrowser } from '../../helpers/compass-browser';
510
import { createGeospatialCollection } from '../../helpers/insert-data';
611
import {
@@ -15,7 +20,7 @@ type GeoShardingFormData = {
1520

1621
type GeoShardingStatus = 'UNSHARDED' | 'SHARDING' | 'SHARD_KEY_CORRECT';
1722

18-
const WEBDRIVER_TIMEOUT = 1000 * 60 * 20;
23+
const WEBDRIVER_TIMEOUT = 1000 * 60 * 10;
1924
const MOCHA_TIMEOUT = WEBDRIVER_TIMEOUT * 1.2;
2025

2126
async function createGeoShardKey(
@@ -44,44 +49,47 @@ async function waitForGlobalWritesStatus(
4449
) {
4550
await browser.waitUntil(
4651
async () => {
47-
const content = await browser.$(
48-
Selectors.GlobalWrites.tabStatus(nextStatus)
49-
);
50-
return await content.isDisplayed();
52+
return await browser
53+
.$(Selectors.GlobalWrites.tabStatus(nextStatus))
54+
.isDisplayed();
5155
},
5256
{ timeout: WEBDRIVER_TIMEOUT }
5357
);
5458
}
5559

5660
describe('Global writes', function () {
61+
// Sharding a collection takes a bit longer
62+
this.timeout(MOCHA_TIMEOUT);
63+
5764
let compass: Compass;
5865
let browser: CompassBrowser;
5966

60-
beforeEach(async function () {
61-
// Sharding a collection takes a bit longer
62-
this.timeout(MOCHA_TIMEOUT);
63-
compass = await init(this.test?.fullTitle());
64-
browser = compass.browser;
65-
await browser.setupDefaultConnections();
66-
});
67-
6867
before(function () {
6968
if (!isTestingAtlasCloudSandbox()) {
7069
this.skip();
7170
}
7271
});
7372

74-
after(async function () {
73+
beforeEach(async function () {
74+
compass = await init(this.test?.fullTitle());
75+
browser = compass.browser;
76+
await browser.setupDefaultConnections();
77+
});
78+
79+
afterEach(async function () {
80+
await screenshotIfFailed(compass, this.currentTest);
7581
await cleanup(compass);
7682
});
7783

7884
it('should be able to shard an unsharded namespace and also unmanage it', async function () {
79-
await createGeospatialCollection();
85+
const collName = `global-writes-geospatial-${Date.now()}`;
86+
87+
await createGeospatialCollection(collName);
8088
await browser.connectToDefaults();
8189
await browser.navigateToCollectionTab(
8290
DEFAULT_CONNECTION_NAMES[0],
8391
'test',
84-
'geospatial',
92+
collName,
8593
'GlobalWrites'
8694
);
8795

@@ -116,12 +124,14 @@ describe('Global writes', function () {
116124
});
117125

118126
it('should be able to shard an unsharded namespace and cancel the operation', async function () {
119-
await createGeospatialCollection();
127+
const collName = `global-writes-geospatial-${Date.now()}`;
128+
129+
await createGeospatialCollection(collName);
120130
await browser.connectToDefaults();
121131
await browser.navigateToCollectionTab(
122132
DEFAULT_CONNECTION_NAMES[0],
123133
'test',
124-
'geospatial',
134+
collName,
125135
'GlobalWrites'
126136
);
127137

packages/compass-e2e-tests/tests/atlas-cloud/rolling-indexes.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@ describe('Rolling indexes', function () {
3030

3131
afterEach(async function () {
3232
await screenshotIfFailed(compass, this.currentTest);
33-
});
34-
35-
after(async function () {
3633
await cleanup(compass);
3734
});
3835

3936
it('should be able to create, list, and delete rolling indexes', async function () {
4037
// Building rolling indexes is a slow process
41-
const extendedRollingIndexesTimeout = 1000 * 60 * 20;
38+
const extendedRollingIndexesTimeout = 1000 * 60 * 10;
4239

4340
this.timeout(extendedRollingIndexesTimeout * 1.2);
4441

0 commit comments

Comments
 (0)