Skip to content

Fix flaky test #1108

@delvedor

Description

@delvedor

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.

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)
})
})

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions