diff --git a/lib/pool/BaseConnectionPool.js b/lib/pool/BaseConnectionPool.js index 6241ace5f..811f2a9a8 100644 --- a/lib/pool/BaseConnectionPool.js +++ b/lib/pool/BaseConnectionPool.js @@ -212,9 +212,9 @@ class BaseConnectionPool { url: new URL(address), id: ids[i], roles: Object.assign({ - [Connection.roles.MASTER]: true, - [Connection.roles.DATA]: true, - [Connection.roles.INGEST]: true, + [Connection.roles.MASTER]: false, + [Connection.roles.DATA]: false, + [Connection.roles.INGEST]: false, [Connection.roles.ML]: false }, roles) }) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 53234d901..8230e6d22 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -474,6 +474,45 @@ test('API', t => { t.end() }) + t.test('Should map roles', t => { + const pool = new ConnectionPool({ Connection }) + const nodes = { + a1: { + http: { + publish_address: 'example.com:9200' + }, + roles: ['master', 'data', 'ingest', 'ml'] + }, + a2: { + http: { + publish_address: 'example.com:9201' + }, + roles: [] + } + } + t.same(pool.nodesToHost(nodes, 'http:'), [{ + url: new URL('http://example.com:9200'), + id: 'a1', + roles: { + master: true, + data: true, + ingest: true, + ml: true + } + }, { + url: new URL('http://example.com:9201'), + id: 'a2', + roles: { + master: false, + data: false, + ingest: false, + ml: false + } + }]) + + t.end() + }) + t.end() })