Add test to verify default node filter function (#2756)

This commit is contained in:
Josh Mock
2025-04-16 13:28:32 -05:00
committed by GitHub
parent c3f987caaf
commit 98b38028aa
4 changed files with 36 additions and 8 deletions

View File

@ -64,6 +64,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',