Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ const mockConnections: ConnectionInfo[] = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'host',
metricsType: 'replicaSet',
instanceSize: 'M10',
clusterType: 'REPLICASET',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: false,
},
},
},
{
Expand All @@ -36,12 +41,17 @@ const mockConnections: ConnectionInfo[] = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'replicaSet',
instanceSize: 'M0',
clusterType: 'REPLICASET',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: false,
},
},
},
{
Expand All @@ -53,12 +63,17 @@ const mockConnections: ConnectionInfo[] = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'serverless',
instanceSize: 'SERVERLESS_V2',
clusterType: 'REPLICASET',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: false,
},
},
},
{
Expand All @@ -70,12 +85,17 @@ const mockConnections: ConnectionInfo[] = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'replicaSet',
instanceSize: 'M10',
clusterType: 'REPLICASET',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: true,
},
},
},
{
Expand All @@ -87,12 +107,17 @@ const mockConnections: ConnectionInfo[] = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'cluster',
instanceSize: 'M10',
clusterType: 'SHARDED',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: true,
},
},
},
{
Expand All @@ -104,12 +129,17 @@ const mockConnections: ConnectionInfo[] = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'cluster',
instanceSize: 'M30',
clusterType: 'GEOSHARDED',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: true,
rollingIndexes: true,
},
},
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ const mockConnections = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'host',
metricsType: 'replicaSet',
instanceSize: 'M10',
clusterType: 'REPLICASET',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: false,
},
},
},
{
Expand All @@ -35,12 +40,17 @@ const mockConnections = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'replicaSet',
instanceSize: 'M0',
clusterType: 'REPLICASET',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: false,
},
},
},
{
Expand All @@ -52,12 +62,17 @@ const mockConnections = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'serverless',
instanceSize: 'SERVERLESS_V2',
clusterType: 'REPLICASET',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: false,
},
},
},
{
Expand All @@ -69,12 +84,17 @@ const mockConnections = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'replicaSet',
instanceSize: 'M10',
clusterType: 'REPLICASET',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: true,
},
},
},
{
Expand All @@ -86,14 +106,16 @@ const mockConnections = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'cluster',
instanceSize: 'M10',
clusterType: 'SHARDED',
clusterUniqueId: 'clusterUniqueId',
geoSharding: {
selfManagedSharding: false,
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: true,
},
},
},
Expand All @@ -106,12 +128,17 @@ const mockConnections = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'cluster',
instanceSize: 'M30',
clusterType: 'GEOSHARDED',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: true,
rollingIndexes: true,
},
},
},
{
Expand All @@ -123,14 +150,16 @@ const mockConnections = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'cluster',
instanceSize: 'M30',
clusterType: 'GEOSHARDED',
clusterUniqueId: 'clusterUniqueId',
geoSharding: {
selfManagedSharding: true,
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: true,
},
},
},
Expand All @@ -143,12 +172,17 @@ const mockConnections = [
orgId: 'orgId',
projectId: 'projectId',
clusterName: 'clusterName',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'flex',
instanceSize: 'FLEX',
clusterType: 'REPLICASET',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: false,
},
},
},
] as const;
Expand Down
19 changes: 2 additions & 17 deletions packages/compass-connections/src/utils/connection-supports.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
import type { ConnectionInfo } from '@mongodb-js/connection-info';
export type ConnectionFeature = 'rollingIndexCreation' | 'globalWrites';

function isFreeOrSharedTierCluster(instanceSize: string | undefined): boolean {
if (!instanceSize) {
return false;
}

return ['M0', 'M2', 'M5'].includes(instanceSize);
}

function supportsRollingIndexCreation(connectionInfo: ConnectionInfo) {
const atlasMetadata = connectionInfo.atlasMetadata;

if (!atlasMetadata) {
return false;
}

const { metricsType, instanceSize } = atlasMetadata;
return (
(metricsType === 'cluster' || metricsType === 'replicaSet') &&
!isFreeOrSharedTierCluster(instanceSize)
);
return atlasMetadata.supports.rollingIndexes;
}

function supportsGlobalWrites(connectionInfo: ConnectionInfo) {
Expand All @@ -30,10 +18,7 @@ function supportsGlobalWrites(connectionInfo: ConnectionInfo) {
return false;
}

return (
atlasMetadata.clusterType === 'GEOSHARDED' &&
!atlasMetadata.geoSharding?.selfManagedSharding
);
return atlasMetadata.supports.globalWrites;
}

export function connectionSupports(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ const mockConnectionInfo: ConnectionInfo = {
orgId: 'testOrg',
projectId: 'testProject',
clusterName: 'pineapple',
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
metricsId: 'metricsId',
metricsType: 'replicaSet',
instanceSize: 'M10',
clusterType: 'REPLICASET',
clusterUniqueId: 'clusterUniqueId',
clusterState: 'IDLE',
supports: {
globalWrites: false,
rollingIndexes: false,
},
},
};

Expand Down
3 changes: 3 additions & 0 deletions packages/compass-indexes/src/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ describe('CompassIndexesPlugin', function () {
atlasMetadata: {
instanceSize: 'VERY BIG',
metricsType: 'replicaSet',
supports: {
rollingIndexes: true,
},
} as any,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ describe('regular-indexes module', function () {
atlasMetadata: {
metricsType: 'cluster',
instanceSize: 'M10',
supports: {
rollingIndexes: true,
},
},
},
} as ConnectionInfoRef;
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-schema/src/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ describe('compass-schema utils', function () {
expect(
getAtlasPerformanceAdvisorLink({
metricsId: '123456',
metricsType: 'host',
metricsType: 'replicaSet',
clusterName: 'Cluster0',
})
).to.equal('#/metrics/host/123456/advisor');
).to.equal('#/metrics/replicaSet/123456/advisor');
});
it('encodes the parameters', function () {
expect(
Expand Down
12 changes: 7 additions & 5 deletions packages/compass-web/src/connection-storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ describe('buildConnectionInfoFromClusterDescription', function () {
clusterDescription.replicationSpecList?.[0].regionConfigs.slice().pop()
?.electableSpecs.instanceSize;

// We test these separately in another test
if (connectionInfo.atlasMetadata?.supports) {
delete (connectionInfo.atlasMetadata as { supports?: any }).supports;
}

expect(connectionInfo)
.to.have.property('atlasMetadata')
.deep.eq({
Expand All @@ -199,12 +204,9 @@ describe('buildConnectionInfoFromClusterDescription', function () {
clusterUniqueId: '123abc',
metricsType: type === 'sharded' ? 'cluster' : type,
instanceSize: expectedInstanceSize,
regionalBaseUrl: 'https://example.com',
regionalBaseUrl: null,
clusterType: clusterDescription.clusterType,
geoSharding: {
selfManagedSharding:
clusterDescription.geoSharding?.selfManagedSharding,
},
clusterState: 'IDLE',
});
});
}
Expand Down
Loading