(resultKey, testFn)
| 50 | } |
| 51 | |
| 52 | async run(resultKey, testFn) { |
| 53 | const self = this; |
| 54 | let primaryServer = await mock.createServer(32000, 'localhost'); |
| 55 | let firstSecondaryServer = await mock.createServer(32001, 'localhost'); |
| 56 | let arbiterServer = await mock.createServer(32002, 'localhost'); |
| 57 | |
| 58 | primaryServer.setMessageHandler(request => { |
| 59 | const doc = request.document; |
| 60 | if (isHello(doc)) { |
| 61 | request.reply(self.serverStates.primary[0]); |
| 62 | } else if (doc[resultKey]) { |
| 63 | self.commandResult = doc; |
| 64 | request.reply(Object.assign({ ok: 1 }, self.responseDecoration)); |
| 65 | } else if (doc.endSessions) { |
| 66 | request.reply({ ok: 1 }); |
| 67 | } |
| 68 | }); |
| 69 | |
| 70 | firstSecondaryServer.setMessageHandler(request => { |
| 71 | const doc = request.document; |
| 72 | if (isHello(doc)) { |
| 73 | request.reply(self.serverStates.firstSecondary[0]); |
| 74 | } else if (doc.endSessions) { |
| 75 | request.reply({ ok: 1 }); |
| 76 | } |
| 77 | }); |
| 78 | |
| 79 | arbiterServer.setMessageHandler(request => { |
| 80 | const doc = request.document; |
| 81 | if (isHello(doc)) { |
| 82 | request.reply(self.serverStates.arbiter[0]); |
| 83 | } else if (doc.endSessions) { |
| 84 | request.reply({ ok: 1 }); |
| 85 | } |
| 86 | }); |
| 87 | |
| 88 | const client = new MongoClient( |
| 89 | 'mongodb://localhost:32000,localhost:32001,localhost:32002/test?replicaSet=rs' |
| 90 | ); |
| 91 | |
| 92 | await client.connect(); |
| 93 | await testFn(client, client.db('write_concern_db')); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | function writeConcernTest(command, testFn) { |
no test coverage detected