Skip to content

Commit 4e465b4

Browse files
committed
Propagate isEndOfLife via BuildInfo on data-service instance
1 parent 1717b95 commit 4e465b4

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

packages/data-service/src/instance-detail-helper.spec.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
getDatabasesByRoles,
88
getPrivilegesByDatabaseAndCollection,
99
getInstance,
10+
isEndOfLifeVersion,
11+
adaptBuildInfo,
1012
} from './instance-detail-helper';
1113

1214
import * as fixtures from '../test/fixtures';
@@ -629,4 +631,53 @@ describe('instance-detail-helper', function () {
629631
).to.deep.equal(['aws', 'local']);
630632
});
631633
});
634+
635+
describe('isEndOfLifeVersion', function () {
636+
it('returns true for v4.4 and below', () => {
637+
expect(isEndOfLifeVersion('4.4.0')).to.equal(true);
638+
expect(isEndOfLifeVersion('4.3.0')).to.equal(true);
639+
expect(isEndOfLifeVersion('4.0')).to.equal(true);
640+
expect(isEndOfLifeVersion('4.0-beta.0')).to.equal(true);
641+
expect(isEndOfLifeVersion('1.0.0')).to.equal(true);
642+
expect(isEndOfLifeVersion('0.0.1')).to.equal(true);
643+
expect(isEndOfLifeVersion('3.999.0')).to.equal(true);
644+
});
645+
646+
it('returns true for v4.5 and above', () => {
647+
expect(isEndOfLifeVersion('4.5.0')).to.equal(false);
648+
expect(isEndOfLifeVersion('5.0.0')).to.equal(false);
649+
expect(isEndOfLifeVersion('5.0.25')).to.equal(false);
650+
expect(isEndOfLifeVersion('6.0.0')).to.equal(false);
651+
expect(isEndOfLifeVersion('7.0.0')).to.equal(false);
652+
expect(isEndOfLifeVersion('8.0.0')).to.equal(false);
653+
});
654+
});
655+
656+
describe('adaptBuildInfo', function () {
657+
it('propagate isEndOfLife as expected', function () {
658+
expect(adaptBuildInfo({ version: '4.4.0' })).to.deep.equal({
659+
version: '4.4.0',
660+
isEndOfLife: true,
661+
isEnterprise: false,
662+
});
663+
// Missing version
664+
expect(adaptBuildInfo({})).to.deep.equal({
665+
version: '',
666+
isEndOfLife: false,
667+
isEnterprise: false,
668+
});
669+
// Malformed version
670+
expect(adaptBuildInfo({ version: 'what?' })).to.deep.equal({
671+
version: 'what?',
672+
isEndOfLife: false,
673+
isEnterprise: false,
674+
});
675+
// Newer version
676+
expect(adaptBuildInfo({ version: '8.0.0' })).to.deep.equal({
677+
version: '8.0.0',
678+
isEndOfLife: false,
679+
isEnterprise: false,
680+
});
681+
});
682+
});
632683
});

packages/data-service/src/instance-detail-helper.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { debug } from './logger';
2828

2929
type BuildInfoDetails = {
3030
isEnterprise: boolean;
31+
isEndOfLife: boolean;
3132
version: string;
3233
};
3334

@@ -350,11 +351,23 @@ function adaptHostInfo(rawHostInfo: Partial<HostInfo>): HostInfoDetails {
350351
};
351352
}
352353

353-
function adaptBuildInfo(rawBuildInfo: Partial<BuildInfo>) {
354+
export function isEndOfLifeVersion(version: string) {
355+
try {
356+
const [major, minor] = version.split('.').map((part) => parseInt(part, 10));
357+
return (major === 4 && minor <= 4) || major < 4;
358+
} catch {
359+
return false;
360+
}
361+
}
362+
363+
export function adaptBuildInfo(rawBuildInfo: Partial<BuildInfo>) {
354364
return {
355365
version: rawBuildInfo.version ?? '',
356366
// Cover both cases of detecting enterprise module, see SERVER-18099.
357367
isEnterprise: isEnterprise(rawBuildInfo),
368+
isEndOfLife: rawBuildInfo.version
369+
? isEndOfLifeVersion(rawBuildInfo.version)
370+
: false,
358371
};
359372
}
360373

0 commit comments

Comments
 (0)