Skip to content

Commit

Permalink
fixup: add FCV lookup (also TSE request)
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Sep 21, 2021
1 parent 064dab2 commit a05ab99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,8 @@ describe('CliServiceProvider', () => {
const info = await serviceProvider.getConnectionInfo();
expect(info.extraInfo.is_atlas).to.equal(false);
expect(info.extraInfo.is_localhost).to.equal(true);
expect(dbStub.command).to.have.callCount(4);
expect(info.extraInfo.fcv).to.equal(undefined);
expect(dbStub.command).to.have.callCount(5);
});
});
});
12 changes: 8 additions & 4 deletions packages/service-provider-server/src/cli-service-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ type ConnectionInfo = {
topology: any;
extraInfo: ExtraConnectionInfo;
};
type ExtraConnectionInfo = ReturnType<typeof getConnectInfo>;
type ExtraConnectionInfo = ReturnType<typeof getConnectInfo> & { fcv?: string };

/**
* Default driver options we always use.
Expand Down Expand Up @@ -412,9 +412,10 @@ class CliServiceProvider extends ServiceProviderCore implements ServiceProvider
}
const topology = this.getTopology();
const { version } = require('../package.json');
const [cmdLineOpts = null, atlasVersion = null] = await Promise.all([
const [cmdLineOpts = null, atlasVersion = null, fcv = null] = await Promise.all([
this.runCommandWithCheck('admin', { getCmdLineOpts: 1 }, this.baseCmdOptions).catch(() => {}),
this.runCommandWithCheck('admin', { atlasVersion: 1 }, this.baseCmdOptions).catch(() => {})
this.runCommandWithCheck('admin', { atlasVersion: 1 }, this.baseCmdOptions).catch(() => {}),
this.runCommandWithCheck('admin', { getParameter: 1, featureCompatibilityVersion: 1 }, this.baseCmdOptions).catch(() => {})
]);

const extraConnectionInfo = getConnectInfo(
Expand All @@ -429,7 +430,10 @@ class CliServiceProvider extends ServiceProviderCore implements ServiceProvider
return {
buildInfo: buildInfo,
topology: topology,
extraInfo: extraConnectionInfo
extraInfo: {
...extraConnectionInfo,
fcv: fcv?.featureCompatibilityVersion?.version
}
};
}

Expand Down

0 comments on commit a05ab99

Please sign in to comment.