@@ -150,6 +150,34 @@ describe('e2e direct connection', () => {
150150 shell . assertContainsOutput ( `me: '${ await rs0 . hostport ( ) } '` ) ;
151151 shell . assertContainsOutput ( `setName: '${ replSetId } '` ) ;
152152 } ) ;
153+ it ( 'when specifying multiple seeds through --host' , async ( ) => {
154+ const hostlist = replSetId + '/' + await rs2 . hostport ( ) + ',' + await rs1 . hostport ( ) + ',' + await rs0 . hostport ( ) ;
155+ const shell = TestShell . start ( { args : [ '--host' , hostlist ] } ) ;
156+ await shell . waitForPrompt ( ) ;
157+ await shell . executeLine ( 'db.isMaster()' ) ;
158+ await shell . executeLine ( '({ dbname: db.getName() })' ) ;
159+ shell . assertContainsOutput ( 'ismaster: true' ) ;
160+ shell . assertContainsOutput ( `me: '${ await rs0 . hostport ( ) } '` ) ;
161+ shell . assertContainsOutput ( `setName: '${ replSetId } '` ) ;
162+ shell . assertContainsOutput ( "dbname: 'test'" ) ;
163+ } ) ;
164+ it ( 'when specifying multiple seeds through --host with a db name' , async ( ) => {
165+ const hostlist = replSetId + '/' + await rs2 . hostport ( ) + ',' + await rs1 . hostport ( ) + ',' + await rs0 . hostport ( ) ;
166+ const shell = TestShell . start ( { args : [ '--host' , hostlist , 'admin' ] } ) ;
167+ await shell . waitForPrompt ( ) ;
168+ await shell . executeLine ( 'db.isMaster()' ) ;
169+ await shell . executeLine ( '({ dbname: db.getName() })' ) ;
170+ shell . assertContainsOutput ( 'ismaster: true' ) ;
171+ shell . assertContainsOutput ( `me: '${ await rs0 . hostport ( ) } '` ) ;
172+ shell . assertContainsOutput ( `setName: '${ replSetId } '` ) ;
173+ shell . assertContainsOutput ( "dbname: 'admin'" ) ;
174+ } ) ;
175+ it ( 'when specifying multiple seeds through --host with a wrong replsetid' , async ( ) => {
176+ const hostlist = 'wrongreplset/' + await rs2 . hostport ( ) + ',' + await rs1 . hostport ( ) + ',' + await rs0 . hostport ( ) ;
177+ const shell = TestShell . start ( { args : [ '--host' , hostlist , 'admin?serverSelectionTimeoutMS=2000' ] } ) ;
178+ await shell . waitForExit ( ) ;
179+ shell . assertContainsOutput ( 'MongoServerSelectionError' ) ;
180+ } ) ;
153181
154182 it ( 'lists collections and dbs using show by default' , async ( ) => {
155183 const shell = TestShell . start ( { args : [ `${ await rs1 . connectionString ( ) } ` ] } ) ;
0 commit comments