File tree Expand file tree Collapse file tree 2 files changed +36
-5
lines changed Expand file tree Collapse file tree 2 files changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -1250,6 +1250,31 @@ describe('MongoshNodeRepl', function () {
1250
1250
expect ( output ) . to . not . contain ( 'Error' ) ;
1251
1251
expect ( error ) . to . be . instanceof ( MongoshCommandFailed ) ;
1252
1252
} ) ;
1253
+
1254
+ it ( 'does not show anything if connecting to local Atlas' , async function ( ) {
1255
+ // Make sure the startupWarnings resolves with errors
1256
+ sp . runCommandWithCheck
1257
+ . withArgs (
1258
+ ADMIN_DB ,
1259
+ {
1260
+ getLog : 'startupWarnings' ,
1261
+ } ,
1262
+ { }
1263
+ )
1264
+ . resolves ( { ok : 1 , log : logLines } ) ;
1265
+ // Make sure the connection info indicates a local Atlas server
1266
+ sp . getConnectionInfo . resolves ( {
1267
+ extraInfo : {
1268
+ uri : 'mongodb://localhost:27017/test' ,
1269
+ is_local_atlas : true ,
1270
+ } ,
1271
+ buildInfo : { } ,
1272
+ } ) ;
1273
+ await mongoshRepl . initialize ( serviceProvider ) ;
1274
+ expect ( output ) . to . not . contain (
1275
+ 'The server generated these startup warnings when booting'
1276
+ ) ;
1277
+ } ) ;
1253
1278
} ) ;
1254
1279
}
1255
1280
} ) ;
Original file line number Diff line number Diff line change @@ -355,11 +355,17 @@ class MongoshNodeRepl implements EvaluationListener {
355
355
// cf. legacy shell:
356
356
// https://github.com/mongodb/mongo/blob/a6df396047a77b90bf1ce9463eecffbee16fb864/src/mongo/shell/mongo_main.cpp#L1003-L1026
357
357
const { shellApi } = instanceState ;
358
- const banners = await Promise . all ( [
359
- ( async ( ) => await shellApi . _untrackedShow ( 'startupWarnings' ) ) ( ) ,
360
- ( async ( ) => await shellApi . _untrackedShow ( 'automationNotices' ) ) ( ) ,
361
- ( async ( ) => await shellApi . _untrackedShow ( 'nonGenuineMongoDBCheck' ) ) ( ) ,
362
- ] ) ;
358
+ // Assuming `instanceState.fetchConnectionInfo()` was already called above
359
+ const connectionInfo = instanceState . cachedConnectionInfo ( ) ;
360
+ // Skipping startup warnings (see https://jira.mongodb.org/browse/MONGOSH-1776)
361
+ const bannerCommands = connectionInfo ?. extraInfo ?. is_local_atlas
362
+ ? [ 'automationNotices' , 'nonGenuineMongoDBCheck' ]
363
+ : [ 'startupWarnings' , 'automationNotices' , 'nonGenuineMongoDBCheck' ] ;
364
+ const banners = await Promise . all (
365
+ bannerCommands . map (
366
+ async ( command ) => await shellApi . _untrackedShow ( command )
367
+ )
368
+ ) ;
363
369
for ( const banner of banners ) {
364
370
if ( banner . value ) {
365
371
await shellApi . print ( banner ) ;
You can’t perform that action at this time.
0 commit comments