Reduce CI flake on MacOS runner
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
parent
988a39a25b
commit
2606276428
1 changed files with 19 additions and 9 deletions
|
@ -14,7 +14,7 @@ import {
|
||||||
} from '../../jobs/AttachmentDownloadManager';
|
} from '../../jobs/AttachmentDownloadManager';
|
||||||
import type { AttachmentDownloadJobType } from '../../types/AttachmentDownload';
|
import type { AttachmentDownloadJobType } from '../../types/AttachmentDownload';
|
||||||
import dataInterface from '../../sql/Client';
|
import dataInterface from '../../sql/Client';
|
||||||
import { HOUR, MINUTE, SECOND } from '../../util/durations';
|
import { MINUTE } from '../../util/durations';
|
||||||
import { type AciString } from '../../types/ServiceId';
|
import { type AciString } from '../../types/ServiceId';
|
||||||
|
|
||||||
describe('AttachmentDownloadManager/JobManager', () => {
|
describe('AttachmentDownloadManager/JobManager', () => {
|
||||||
|
@ -73,13 +73,20 @@ describe('AttachmentDownloadManager/JobManager', () => {
|
||||||
...AttachmentDownloadManager.defaultParams,
|
...AttachmentDownloadManager.defaultParams,
|
||||||
shouldHoldOffOnStartingQueuedJobs: isInCall,
|
shouldHoldOffOnStartingQueuedJobs: isInCall,
|
||||||
runJob,
|
runJob,
|
||||||
|
getRetryConfig: () => ({
|
||||||
|
maxAttempts: 5,
|
||||||
|
backoffConfig: {
|
||||||
|
multiplier: 5,
|
||||||
|
firstBackoffs: [MINUTE],
|
||||||
|
maxBackoffTime: 30 * MINUTE,
|
||||||
|
},
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
sandbox.restore();
|
|
||||||
clock.restore();
|
|
||||||
await downloadManager?.stop();
|
await downloadManager?.stop();
|
||||||
|
sandbox.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function addJob(
|
async function addJob(
|
||||||
|
@ -152,6 +159,7 @@ describe('AttachmentDownloadManager/JobManager', () => {
|
||||||
// ticked forward and make tests unreliable
|
// ticked forward and make tests unreliable
|
||||||
await dataInterface.getAllItems();
|
await dataInterface.getAllItems();
|
||||||
await clock.tickAsync(ms);
|
await clock.tickAsync(ms);
|
||||||
|
await dataInterface.getAllItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPromisesForAttempts(
|
function getPromisesForAttempts(
|
||||||
|
@ -287,20 +295,22 @@ describe('AttachmentDownloadManager/JobManager', () => {
|
||||||
assert.strictEqual(retriedJob?.attempts, 1);
|
assert.strictEqual(retriedJob?.attempts, 1);
|
||||||
assert.isNumber(retriedJob?.retryAfter);
|
assert.isNumber(retriedJob?.retryAfter);
|
||||||
|
|
||||||
await advanceTime(60 * SECOND); // one tick
|
await advanceTime(MINUTE);
|
||||||
|
|
||||||
await job1Attempts[1].completed;
|
await job1Attempts[1].completed;
|
||||||
assert.strictEqual(runJob.callCount, 3);
|
assert.strictEqual(runJob.callCount, 3);
|
||||||
|
|
||||||
await advanceTime(5 * MINUTE);
|
await advanceTime(5 * MINUTE);
|
||||||
|
|
||||||
await job1Attempts[2].completed;
|
await job1Attempts[2].completed;
|
||||||
assert.strictEqual(runJob.callCount, 4);
|
assert.strictEqual(runJob.callCount, 4);
|
||||||
|
|
||||||
await advanceTime(50 * MINUTE);
|
await advanceTime(25 * MINUTE);
|
||||||
await job1Attempts[3].completed;
|
await job1Attempts[3].completed;
|
||||||
assert.strictEqual(runJob.callCount, 5);
|
assert.strictEqual(runJob.callCount, 5);
|
||||||
|
|
||||||
await advanceTime(6 * HOUR);
|
await advanceTime(30 * MINUTE);
|
||||||
await job1Attempts[4].completed;
|
await job1Attempts[4].completed;
|
||||||
|
|
||||||
assert.strictEqual(runJob.callCount, 6);
|
assert.strictEqual(runJob.callCount, 6);
|
||||||
assertRunJobCalledWith([
|
assertRunJobCalledWith([
|
||||||
jobs[1],
|
jobs[1],
|
||||||
|
@ -353,11 +363,11 @@ describe('AttachmentDownloadManager/JobManager', () => {
|
||||||
await attempts[2].completed;
|
await attempts[2].completed;
|
||||||
assert.strictEqual(runJob.callCount, 6);
|
assert.strictEqual(runJob.callCount, 6);
|
||||||
|
|
||||||
await advanceTime(50 * MINUTE);
|
await advanceTime(25 * MINUTE);
|
||||||
await attempts[3].completed;
|
await attempts[3].completed;
|
||||||
assert.strictEqual(runJob.callCount, 7);
|
assert.strictEqual(runJob.callCount, 7);
|
||||||
|
|
||||||
await advanceTime(6 * HOUR);
|
await advanceTime(30 * MINUTE);
|
||||||
await attempts[4].completed;
|
await attempts[4].completed;
|
||||||
assert.strictEqual(runJob.callCount, 8);
|
assert.strictEqual(runJob.callCount, 8);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue