Put node roles support back (#2759) (#2762)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
This commit is contained in:
github-actions[bot]
2025-04-17 13:55:18 -05:00
committed by GitHub
parent 846c50b8bf
commit a31920b785
3 changed files with 45 additions and 2 deletions

View File

@ -77,6 +77,31 @@ test('Missing node(s)', t => {
t.end()
})
test('multi nodes with roles, using default node filter', async t => {
const client = new Client({
nodes: [
{
url: new URL('http://node1:9200'),
roles: { master: true, data: false, ingest: false, ml: false }
},
{
url: new URL('http://node2:9200'),
roles: { master: true, data: true, ingest: false, ml: false }
},
]
})
const conn = client.connectionPool.getConnection({
now: Date.now() + 1000 * 60 * 3,
requestId: 1,
name: 'elasticsearch-js',
context: null
})
t.equal(conn?.url.hostname, 'node2')
t.end()
})
test('Custom headers', t => {
const client = new Client({
node: 'http://localhost:9200',