-
Notifications
You must be signed in to change notification settings - Fork 726
Closed
Labels
Description
The following test passes consistently in localhost, but it's flaky on CI. It should be refactored to avoid this issue. Very likely the problem is caused due to the use of timers.
elasticsearch-js/test/behavior/sniff.test.js
Lines 114 to 149 in 94d4ac7
| test('Sniff interval', { skip: 'Flaky on CI' }, t => { | |
| t.plan(10) | |
| buildCluster(({ nodes, shutdown, kill }) => { | |
| const client = new Client({ | |
| node: nodes[Object.keys(nodes)[0]].url, | |
| sniffInterval: 50 | |
| }) | |
| // this event will be triggered by api calls | |
| client.on(events.SNIFF, (err, request) => { | |
| t.error(err) | |
| const { hosts, reason } = request.meta.sniff | |
| t.strictEqual( | |
| client.connectionPool.size, | |
| hosts.length | |
| ) | |
| t.strictEqual(reason, Transport.sniffReasons.SNIFF_INTERVAL) | |
| }) | |
| t.strictEqual(client.connectionPool.size, 1) | |
| setTimeout(() => client.info(t.error), 60) | |
| setTimeout(() => { | |
| // let's kill a node | |
| kill('node1') | |
| client.info(t.error) | |
| }, 150) | |
| setTimeout(() => { | |
| t.strictEqual(client.connectionPool.size, 3) | |
| }, 200) | |
| t.teardown(shutdown) | |
| }) | |
| }) |