Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Investigate flaky tests #53

Open
mcollina opened this issue Jan 24, 2023 · 5 comments · Fixed by #54
Open

Investigate flaky tests #53

mcollina opened this issue Jan 24, 2023 · 5 comments · Fixed by #54

Comments

@mcollina
Copy link
Contributor

Tests are really flaky in this project.
I think most of them are because of I/O, timers and reconnects.

They should be investigated and fixed

@mcollina
Copy link
Contributor Author

cc @marco-ippolito

@marco-ippolito
Copy link
Member

marco-ippolito commented Jan 24, 2023

Ill look into it, this one seems to be the culprit:

test('gateway - should log error if retry throws', async t => {
t.plan(1)
const service1 = await createTestService(
0,
userService.schema,
userService.resolvers
)
let service2 = null
t.context.clock.setTimeout(async () => {
service2 = await createTestService(
5114,
postService.schema,
postService.resolvers
)
}, 2000)
const gateway = Fastify()
let errCount = 0
gateway.log.error = error => {
if (error.message.includes('kaboom') && errCount === 0) {
errCount++
t.pass()
}
}
t.teardown(async () => {
await gateway.close()
await service1.close()
await service2.close()
})
await gateway.register(plugin, {
gateway: {
services: [
{
name: 'user',
url: `http://localhost:${service1.server.address().port}/graphql`,
mandatory: false
},
{
name: 'post',
url: 'http://localhost:5114/graphql',
mandatory: true
}
],
retryServicesCount: 1,
retryServicesInterval: 3000
},
jit: 1
})
gateway.graphqlGateway.addHook('onGatewayReplaceSchema', async () => {
throw new Error('kaboom')
})
await gateway.ready()
for (let i = 0; i < 200; i++) {
await t.context.clock.tickAsync(50)
}
})

I'll come up with a fix
@mcollina I dont have rights on this repo

@mcollina
Copy link
Contributor Author

@marco-ippolito
Copy link
Member

I'll try another approach on this test probably it's better to rewrite it completely.

@tomi-bigpi
Copy link
Contributor

Possibly related/FYI:

Tests in our application warn with A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.

This happens when we have reconnect enabled:

            wsConnectionParams: {
              reconnect: true,

We're disabling reconnects during tests as a workaround for the time being.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants