Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: handle flaky tests #853

Merged
merged 1 commit into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -32,7 +32,7 @@
"@graphql-tools/merge": "^8.0.0",
"@graphql-tools/schema": "^8.0.0",
"@graphql-tools/utils": "^8.0.0",
"@sinonjs/fake-timers": "^9.0.0",
"@sinonjs/fake-timers": "^9.1.2",
"@types/node": "^18.0.0",
"@types/ws": "^8.2.0",
"@types/isomorphic-form-data": "^2.0.0",
Expand All @@ -48,7 +48,7 @@
"snazzy": "^9.0.0",
"split2": "^4.0.0",
"standard": "^17.0.0",
"tap": "^16.0.0",
"tap": "^16.3.0",
"tsd": "^0.22.0",
"typescript": "^4.3.5",
"wait-on": "^6.0.0"
Expand Down
36 changes: 18 additions & 18 deletions test/gateway/retry-failed-services.js
Expand Up @@ -119,11 +119,11 @@ test('gateway - retry mandatory failed services on startup', async (t) => {
advanceTimeDelta: 100
})

const service1 = await createTestService(5001, userService.schema, userService.resolvers)
const service1 = await createTestService(0, userService.schema, userService.resolvers)

let service2 = null
setTimeout(async () => {
service2 = await createTestService(5002, postService.schema, postService.resolvers)
service2 = await createTestService(5113, postService.schema, postService.resolvers)
}, 5000)

const app = Fastify()
Expand All @@ -140,12 +140,12 @@ test('gateway - retry mandatory failed services on startup', async (t) => {
services: [
{
name: 'user',
url: 'http://localhost:5001/graphql',
url: `http://localhost:${service1.server.address().port}/graphql`,
mandatory: false
},
{
name: 'post',
url: 'http://localhost:5002/graphql',
url: 'http://localhost:5113/graphql',
mandatory: true
}
]
Expand Down Expand Up @@ -221,11 +221,11 @@ test('gateway - should not call onGatewayReplaceSchemaHandler if the hook is not
advanceTimeDelta: 100
})

const service1 = await createTestService(5001, userService.schema, userService.resolvers)
const service1 = await createTestService(0, userService.schema, userService.resolvers)

let service2 = null
setTimeout(async () => {
service2 = await createTestService(5002, postService.schema, postService.resolvers)
service2 = await createTestService(5111, postService.schema, postService.resolvers)
}, 5000)

const app = Fastify()
Expand All @@ -242,12 +242,12 @@ test('gateway - should not call onGatewayReplaceSchemaHandler if the hook is not
services: [
{
name: 'user',
url: 'http://localhost:5001/graphql',
url: `http://localhost:${service1.server.address().port}/graphql`,
mandatory: false
},
{
name: 'post',
url: 'http://localhost:5002/graphql',
url: 'http://localhost:5111/graphql',
mandatory: true
}
],
Expand Down Expand Up @@ -319,7 +319,7 @@ test('gateway - dont retry non-mandatory failed services on startup', async (t)
advanceTimeDelta: 100
})

const service1 = await createTestService(5001, userService.schema, userService.resolvers)
const service1 = await createTestService(0, userService.schema, userService.resolvers)

const app = Fastify()
t.teardown(async () => {
Expand All @@ -334,12 +334,12 @@ test('gateway - dont retry non-mandatory failed services on startup', async (t)
services: [
{
name: 'user',
url: 'http://localhost:5001/graphql',
url: `http://localhost:${service1.server.address().port}/graphql`,
mandatory: false
},
{
name: 'post',
url: 'http://localhost:5002/graphql',
url: 'http://localhost:5112/graphql',
mandatory: false
}
],
Expand Down Expand Up @@ -406,11 +406,11 @@ test('gateway - should log error if retry throws', async (t) => {
advanceTimeDelta: 100
})

const service1 = await createTestService(5001, userService.schema, userService.resolvers)
const service1 = await createTestService(0, userService.schema, userService.resolvers)

let service2 = null
setTimeout(async () => {
service2 = await createTestService(5002, postService.schema, postService.resolvers)
service2 = await createTestService(5113, postService.schema, postService.resolvers)
}, 2000)

const app = Fastify()
Expand All @@ -436,12 +436,12 @@ test('gateway - should log error if retry throws', async (t) => {
services: [
{
name: 'user',
url: 'http://localhost:5001/graphql',
url: `http://localhost:${service1.server.address().port}/graphql`,
mandatory: false
},
{
name: 'post',
url: 'http://localhost:5002/graphql',
url: 'http://localhost:5113/graphql',
mandatory: true
}
],
Expand All @@ -456,8 +456,8 @@ test('gateway - should log error if retry throws', async (t) => {

await app.ready()

for (let i = 0; i < 10; i++) {
await clock.tickAsync(1000)
for (let i = 0; i < 100; i++) {
await clock.tickAsync(100)
}
})

Expand Down Expand Up @@ -497,7 +497,7 @@ test('gateway - stop retrying after no. of retries exceeded', async (t) => {
},
{
name: 'post',
url: 'http://localhost:5002/graphql',
url: 'http://localhost:5114/graphql',
mandatory: true
}
],
Expand Down