From 911035ca8906094148e732a94ab6085c0439f52c Mon Sep 17 00:00:00 2001 From: Hao Hu Date: Tue, 19 Sep 2023 11:34:51 +1000 Subject: [PATCH] STREAMS-576: do not show MDB version for SPI --- packages/cli-repl/src/mongosh-repl.spec.ts | 24 ++++++++++++++++++++++ packages/cli-repl/src/mongosh-repl.ts | 21 +++++++++++-------- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/packages/cli-repl/src/mongosh-repl.spec.ts b/packages/cli-repl/src/mongosh-repl.spec.ts index 0df89c472..7f356ac27 100644 --- a/packages/cli-repl/src/mongosh-repl.spec.ts +++ b/packages/cli-repl/src/mongosh-repl.spec.ts @@ -1309,4 +1309,28 @@ describe('MongoshNodeRepl', function () { expect(output).to.not.match(/Using MongoDB/); }); }); + + context('with is_stream: true', function () { + beforeEach(async function () { + sp.getConnectionInfo.resolves({ + extraInfo: { + uri: 'mongodb://localhost:27017/test', + is_localhost: true, + is_stream: true, + }, + buildInfo: { + version: '4.4.1', + }, + }); + mongoshReplOptions.shellCliOptions = { + nodb: false, + }; + mongoshRepl = new MongoshNodeRepl(mongoshReplOptions); + await mongoshRepl.initialize(serviceProvider); + }); + + it('shows Atlas Stream Processing', function () { + expect(output).to.match(/Using MongoDB:\t\tAtlas Stream Processing/); + }); + }); }); diff --git a/packages/cli-repl/src/mongosh-repl.ts b/packages/cli-repl/src/mongosh-repl.ts index 38517c597..c72bb8cc7 100644 --- a/packages/cli-repl/src/mongosh-repl.ts +++ b/packages/cli-repl/src/mongosh-repl.ts @@ -173,12 +173,17 @@ class MongoshNodeRepl implements EvaluationListener { instanceState.setEvaluationListener(this); await instanceState.fetchConnectionInfo(); - let mongodVersion = instanceState.connectionInfo.buildInfo?.version; - const apiVersion = serviceProvider.getRawClient()?.serverApi?.version; - if (apiVersion) { - mongodVersion = - (mongodVersion ? mongodVersion + ' ' : '') + - `(API Version ${apiVersion})`; + const { buildInfo, extraInfo } = instanceState.connectionInfo; + let mongodVersion = extraInfo?.is_stream + ? 'Atlas Stream Processing' + : buildInfo?.version; + if (!extraInfo?.is_stream) { + const apiVersion = serviceProvider.getRawClient()?.serverApi?.version; + if (apiVersion) { + mongodVersion = + (mongodVersion ? mongodVersion + ' ' : '') + + `(API Version ${apiVersion})`; + } } await this.greet(mongodVersion, moreRecentMongoshVersion); await this.printBasicConnectivityWarning(instanceState); @@ -456,7 +461,7 @@ class MongoshNodeRepl implements EvaluationListener { * The greeting for the shell, showing server and shell version. */ async greet( - mongodVersion: string, + mongodVersion?: string, moreRecentMongoshVersion?: string | null ): Promise { if (this.shellCliOptions.quiet) { @@ -464,7 +469,7 @@ class MongoshNodeRepl implements EvaluationListener { } const { version } = require('../package.json'); let text = ''; - if (!this.shellCliOptions.nodb) { + if (mongodVersion && !this.shellCliOptions.nodb) { text += `Using MongoDB:\t\t${mongodVersion}\n`; } text += `${this.clr(