Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit ce737a3

Browse files
committed
test: Add logging when tests to something unnatural, to avoid confusion when parsing logs.
1 parent abc84ca commit ce737a3

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

test/integration/GapFill.test.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ describeRepeats('GapFill with resends', () => {
121121

122122
count += 1
123123
if (count === 2) {
124+
client.debug('(%o) << Test Dropped Message %s: %o', client.connection.getState(), count, msg)
124125
return null
125126
}
126127

@@ -130,7 +131,7 @@ describeRepeats('GapFill with resends', () => {
130131
expect(subscriber.count(stream.id)).toBe(1)
131132

132133
const published = await publishTestMessages(MAX_MESSAGES, {
133-
timestamp: 111111,
134+
waitForLast: true,
134135
})
135136

136137
const received = []
@@ -155,7 +156,8 @@ describeRepeats('GapFill with resends', () => {
155156
}
156157

157158
count += 1
158-
if (count > 1 && count < 5) {
159+
if (count > 1 && count < 4) {
160+
client.debug('(%o) << Test Dropped Message %s: %o', client.connection.getState(), count, msg)
159161
return null
160162
}
161163

@@ -164,7 +166,9 @@ describeRepeats('GapFill with resends', () => {
164166

165167
expect(subscriber.count(stream.id)).toBe(1)
166168

167-
const published = await publishTestMessages(MAX_MESSAGES)
169+
const published = await publishTestMessages(MAX_MESSAGES, {
170+
waitForLast: true,
171+
})
168172

169173
const received = []
170174
for await (const m of sub) {
@@ -175,7 +179,7 @@ describeRepeats('GapFill with resends', () => {
175179
}
176180
expect(received).toEqual(published)
177181
expect(client.connection.getState()).toBe('connected')
178-
}, 10000)
182+
}, 20000)
179183

180184
it('can fill multiple gaps', async () => {
181185
const sub = await client.subscribe(stream.id)
@@ -189,6 +193,7 @@ describeRepeats('GapFill with resends', () => {
189193

190194
count += 1
191195
if (count === 3 || count === 4 || count === 7) {
196+
client.debug('(%o) << Test Dropped Message %s: %o', client.connection.getState(), count, msg)
192197
return null
193198
}
194199

@@ -197,7 +202,9 @@ describeRepeats('GapFill with resends', () => {
197202

198203
expect(subscriber.count(stream.id)).toBe(1)
199204

200-
const published = await publishTestMessages(MAX_MESSAGES)
205+
const published = await publishTestMessages(MAX_MESSAGES, {
206+
waitForLast: true,
207+
})
201208

202209
const received = []
203210
for await (const m of sub) {
@@ -221,14 +228,14 @@ describeRepeats('GapFill with resends', () => {
221228

222229
count += 1
223230
if (count === 3 || count === 4 || count === 7) {
231+
client.debug('(%o) << Test Dropped Message %s: %o', client.connection.getState(), count, msg)
224232
return null
225233
}
226234

227235
return msg
228236
}
229237

230238
const published = await publishTestMessages(MAX_MESSAGES, {
231-
timestamp: 111111,
232239
waitForLast: true,
233240
})
234241

@@ -260,10 +267,12 @@ describeRepeats('GapFill with resends', () => {
260267
if (!droppedMsgRef) {
261268
droppedMsgRef = msg.streamMessage.getMessageRef()
262269
}
270+
client.debug('(%o) << Test Dropped Message %s: %o', client.connection.getState(), count, msg)
263271
return null
264272
}
265273

266274
if (droppedMsgRef && msg.streamMessage.getMessageRef().compareTo(droppedMsgRef) === 0) {
275+
client.debug('(%o) << Test Dropped Message %s: %o', client.connection.getState(), count, msg)
267276
return null
268277
}
269278

test/integration/StreamConnectionState.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ describeRepeats('Connection State', () => {
281281
received.push(msg.getParsedContent())
282282
if (received.length === 2) {
283283
expect(received).toEqual(published)
284+
client.debug('test closing socket')
284285
client.connection.socket.close()
285286
// this will cause a gap fill
286287
published.push(...(await publishTestMessages(2)))
@@ -304,6 +305,7 @@ describeRepeats('Connection State', () => {
304305
received.push(msg.getParsedContent())
305306
if (received.length === 1) {
306307
expect(received).toEqual(published.slice(0, 1))
308+
client.debug('test disconnecting')
307309
client.disconnect() // should trigger break
308310
// no await, should be immediate
309311
}
@@ -337,6 +339,7 @@ describeRepeats('Connection State', () => {
337339
for await (const msg of sub2) {
338340
received2.push(msg.getParsedContent())
339341
if (received2.length === 1) {
342+
client.debug('test disconnecting')
340343
await client.disconnect()
341344
}
342345
}
@@ -406,7 +409,9 @@ describeRepeats('Connection State', () => {
406409
if (localOtherClient !== otherClient) {
407410
throw new Error('not equal')
408411
}
412+
409413
await localOtherClient.nextConnection()
414+
410415
if (cancelled || msgs.length === MAX_MESSAGES) {
411416
reconnected.resolve(undefined)
412417
return
@@ -415,6 +420,7 @@ describeRepeats('Connection State', () => {
415420
if (localOtherClient !== otherClient) {
416421
throw new Error('not equal')
417422
}
423+
client.debug('test closing localOtherClient socket')
418424
localOtherClient.connection.socket.close()
419425
// wait for reconnection before possibly disconnecting again
420426
await localOtherClient.nextConnection()

0 commit comments

Comments
 (0)