Skip to content

Commit e4d61d4

Browse files
committed
Workaround to make tests more stable.
1 parent a0b25ca commit e4d61d4

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

packages/service-core-tests/src/tests/register-data-storage-tests.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,11 @@ bucket_definitions:
15651565
await batch.keepalive('6/0');
15661566
});
15671567

1568-
const result2 = await iter.next();
1568+
let result2 = await iter.next();
1569+
if (result2.value?.base?.lsn == '5/0') {
1570+
// Events could arrive in a different order in some cases - this caters for it
1571+
result2 = await iter.next();
1572+
}
15691573
expect(result2).toMatchObject({
15701574
done: false,
15711575
value: {
@@ -1671,7 +1675,11 @@ bucket_definitions:
16711675
await batch.keepalive('6/0');
16721676
});
16731677

1674-
const result2 = await iter.next();
1678+
let result2 = await iter.next();
1679+
if (result2.value?.base?.lsn == '5/0') {
1680+
// Events could arrive in a different order in some cases - this caters for it
1681+
result2 = await iter.next();
1682+
}
16751683
expect(result2).toMatchObject({
16761684
done: false,
16771685
value: {
@@ -1689,14 +1697,15 @@ bucket_definitions:
16891697
user_id: 'user1'
16901698
}
16911699
]);
1692-
// We have to trigger a new keepalive after the checkpoint, at least to cover postgres storage.
1693-
// This is what is effetively triggered with RouteAPI.createReplicationHead().
1694-
// MongoDB storage doesn't explicitly need this anymore.
16951700
await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
16961701
await batch.keepalive('7/0');
16971702
});
16981703

1699-
const result3 = await iter.next();
1704+
let result3 = await iter.next();
1705+
if (result3.value?.base?.lsn == '6/0') {
1706+
// Events could arrive in a different order in some cases - this caters for it
1707+
result3 = await iter.next();
1708+
}
17001709
expect(result3).toMatchObject({
17011710
done: false,
17021711
value: {

0 commit comments

Comments
 (0)