Skip to content

Commit 4ffae4a

Browse files
ofrobotsJustinBeckwith
authored andcommitted
fix: de-flake system tests (#265)
1. The test timeout was not effectively applied. 2. All of the tests needed a longer timeout rather than just the error reporting ones. 3. The error-reporting tests would race with a concurrent execution of the tests in the CI because they were logging and polling against the same service. Uniquify the service name.
1 parent 3ade731 commit 4ffae4a

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

handwritten/logging-winston/system-test/logging-winston.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ function logName(name: string) {
3737
return `${UUID}_${name}`;
3838
}
3939

40-
describe('LoggingWinston', () => {
40+
describe('LoggingWinston', function() {
41+
this.timeout(WRITE_CONSISTENCY_DELAY_MS);
4142
const testTimestamp = new Date();
4243

4344
// type TestData
@@ -193,17 +194,13 @@ describe('LoggingWinston', () => {
193194
const ERROR_REPORTING_POLL_TIMEOUT = WRITE_CONSISTENCY_DELAY_MS;
194195
const errorsTransport = new ErrorsApiTransport();
195196

196-
beforeEach(async function() {
197-
this.timeout(WRITE_CONSISTENCY_DELAY_MS);
198-
});
199-
200197
after(async () => {
201198
await errorsTransport.deleteAllEvents();
202199
});
203200

204201
it('reports errors when logging errors with winston2', async () => {
205202
const start = Date.now();
206-
const service = 'logging-winston-system-test';
203+
const service = `logging-winston-system-test-winston2-${UUID}`;
207204
const LoggingWinston = inject('../src/index', {
208205
winston: winston2,
209206
'winston/package.json': {version: '2.2.0'}
@@ -224,14 +221,13 @@ describe('LoggingWinston', () => {
224221
assert.strictEqual(errors.length, 1);
225222
const errEvent = errors[0];
226223

227-
assert.strictEqual(
228-
errEvent.serviceContext.service, 'logging-winston-system-test');
224+
assert.strictEqual(errEvent.serviceContext.service, service);
229225
assert(errEvent.message.startsWith(`an error Error: ${message}`));
230226
});
231227

232228
it('reports errors when logging errors with winston3', async () => {
233229
const start = Date.now();
234-
const service = 'logging-winston-system-test-winston3';
230+
const service = `logging-winston-system-test-winston3-${UUID}`;
235231
const LoggingWinston = inject('../src/index', {
236232
winston: winston3,
237233
'winston/package.json': {version: '3.0.0'}
@@ -252,9 +248,7 @@ describe('LoggingWinston', () => {
252248
assert.strictEqual(errors.length, 1);
253249
const errEvent = errors[0];
254250

255-
assert.strictEqual(
256-
errEvent.serviceContext.service,
257-
'logging-winston-system-test-winston3');
251+
assert.strictEqual(errEvent.serviceContext.service, service);
258252

259253
assert(errEvent.message.startsWith(message));
260254
});

0 commit comments

Comments
 (0)