comq 0.5.2 → 0.5.3-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,8 @@ jest.mock('@toa.io/command', () => mock.command)
10
10
 
11
11
  jest.setTimeout(10000)
12
12
 
13
+ global.COMQ_TESTING_HEALTHCHECK_INTERVAL = 0
14
+
13
15
  require('../broker')
14
16
 
15
17
  const context = /** @type {comq.features.Context} */ {}
@@ -172,11 +172,13 @@ describe('Given I\'m publishing {quantity}B events to the {token} exchange at {q
172
172
 
173
173
  step.call(context, bytesQ, exchange, frequencyQ)
174
174
 
175
- await timeout(100 + 11)
175
+ await timeout(100 + 12)
176
176
 
177
- expect(context.io.emit).toHaveBeenCalledTimes(10)
177
+ const callsAmountExpected = [10, 11]
178
+
179
+ expect(callsAmountExpected).toContain(context.io.emit.mock.calls.length)
178
180
  expect(context.publishing).toBeDefined()
179
- expect(context.eventsPublishedCount).toStrictEqual(10)
181
+ expect(callsAmountExpected).toContain(context.eventsPublishedCount)
180
182
 
181
183
  clearInterval(context.publishing)
182
184
  })
@@ -219,11 +219,13 @@ describe('Given I\'m sending {quantity}B requests to the {token} queue at {quant
219
219
 
220
220
  step.call(context, bytesQ, queue, frequencyQ)
221
221
 
222
- await timeout(100 + 11)
222
+ await timeout(100 + 12)
223
223
 
224
- expect(context.io.request).toHaveBeenCalledTimes(10)
224
+ const callsAmountExpected = [10, 11]
225
+
226
+ expect(callsAmountExpected).toContain(context.io.request.mock.calls.length)
225
227
  expect(context.sending).toBeDefined()
226
- expect(context.requestsSent.length).toStrictEqual(10)
228
+ expect(callsAmountExpected).toContain(context.requestsSent.length)
227
229
 
228
230
  clearInterval(context.sending)
229
231
  })
@@ -46,10 +46,11 @@ async function healthy () {
46
46
  let process
47
47
 
48
48
  do {
49
- await timeout(1000)
49
+ await timeout(HEALTHCHECK_INTERVAL)
50
50
 
51
51
  process = await execute('docker inspect -f {{.State.Health.Status}} comq-rmq-0')
52
52
  } while (process.output !== 'healthy')
53
53
  }
54
54
 
55
55
  const BROKERS_AMOUNT = 2
56
+ const HEALTHCHECK_INTERVAL = global.COMQ_TESTING_HEALTHCHECK_INTERVAL ?? 1000
package/lerna.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "useWorkspaces": true,
3
- "version": "0.5.2",
3
+ "version": "0.5.3-dev.0",
4
4
  "conventionalCommits": true
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comq",
3
- "version": "0.5.2",
3
+ "version": "0.5.3-dev.0",
4
4
  "description": "ComQ",
5
5
  "author": {
6
6
  "name": "Artem Gurtovoi",
@@ -27,7 +27,7 @@
27
27
  "main": "source/index.js",
28
28
  "types": "types/index.d.ts",
29
29
  "devDependencies": {
30
- "@cucumber/cucumber": "9.0.1",
30
+ "@cucumber/cucumber": "9.1.0",
31
31
  "@toa.io/command": "0.3.0",
32
32
  "@toa.io/mock": "0.3.0",
33
33
  "@toa.io/tomato": "0.4.0-dev.2",
@@ -4,7 +4,7 @@
4
4
 
5
5
  const { randomBytes } = require('node:crypto')
6
6
  const { generate } = require('randomstring')
7
- const { flip, random } = require('@toa.io/generic')
7
+ const { flip, random, timeout } = require('@toa.io/generic')
8
8
 
9
9
  const backpressure = require('./backpressure')
10
10
  const { amqplib } = require('./amqplib.mock')
@@ -730,7 +730,7 @@ describe('recovery', () => {
730
730
 
731
731
  const chan = await getCreatedChannel()
732
732
 
733
- chan.publish.mockImplementation(() => true)
733
+ chan.publish.mockImplementation(() => true) // back pressure
734
734
 
735
735
  /** @type {jest.MockedObject<comq.amqp.Connection>} */
736
736
  let replacement
@@ -747,6 +747,8 @@ describe('recovery', () => {
747
747
 
748
748
  const repl = await getCreatedChannel(replacement)
749
749
 
750
+ await timeout(1)
751
+
750
752
  expect(repl.publish).toHaveBeenCalledWith(
751
753
  exchange, '', buffer, expect.objectContaining(options), expect.any(Function)
752
754
  )