Skip to content

Commit bb469b9

Browse files
fix(keystone): INFRA-894 fix potential concurrency in tests (#5845)
* fix(keystone): INFRA-894 fix potential concurrency in tests * fix(keystone): INFRA-894 fix potential concurrency in tests * fix(keystone): INFRA-894 tests forceExist added * fix(keystone): INFRA-894 fix redis url
1 parent 20153ae commit bb469b9

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

bin/run_condo_domain_tests.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ else
8080
killall node || echo 'no node processes'
8181

8282
# TODO: INFRA-155 Remove it completely by rewriting a task tests or migrate to jest.setup or smth
83-
export REDIS_URL=redis://127.0.0.1:6379/4
84-
yarn jest ./packages/keystone --maxWorkers=2
83+
REDIS_URL=redis://127.0.0.1:6379/32 yarn jest ./packages/keystone --maxWorkers=1 --forceExit
8584
yarn workspace @app/condo lint-schema
8685
fi

packages/keystone/tasks.spec.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { getKVClient } = require('./kv')
12
const { createTask, createWorker, taskQueues } = require('./tasks')
23

34
function createTaskFactory () {
@@ -7,15 +8,17 @@ function createTaskFactory () {
78
}
89
}
910

10-
beforeAll(async () => {
11-
return await createWorker()
12-
})
11+
describe('tasks', () => {
12+
beforeAll(async () => {
13+
const kv = getKVClient()
14+
await kv.set('data_version', 2)
15+
return await createWorker()
16+
})
1317

14-
afterAll(async () => {
15-
await Promise.all(Array.from(taskQueues.entries()).map(([,queue]) => queue.close()))
16-
})
18+
afterAll(async () => {
19+
await Promise.all(Array.from(taskQueues.entries()).map(([,queue]) => queue.close()))
20+
})
1721

18-
describe('tasks', () => {
1922
test('createTask result', () => {
2023
const task = createTask('asyncAddTask1', createTaskFactory())
2124
expect(task).toHaveProperty('delay')

0 commit comments

Comments
 (0)