Skip to content

Commit 53dd25a

Browse files
committed
run tests 100x to check flakiness
1 parent c6135dd commit 53dd25a

File tree

4 files changed

+191
-181
lines changed

4 files changed

+191
-181
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ jobs:
481481
needs: [job_get_metadata, job_build]
482482
if: needs.job_get_metadata.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request'
483483
runs-on: ubuntu-20.04
484-
timeout-minutes: 15
484+
timeout-minutes: 25
485485
strategy:
486486
fail-fast: false
487487
matrix:

packages/integration-tests/suites/replay/sessionExpiry/test.ts

Lines changed: 64 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -15,80 +15,84 @@ import {
1515
// Session should expire after 2s - keep in sync with init.js
1616
const SESSION_TIMEOUT = 2000;
1717

18-
sentryTest('handles an expired session', async ({ getLocalTestPath, page }) => {
19-
if (shouldSkipReplayTest()) {
20-
sentryTest.skip();
21-
}
22-
23-
const reqPromise0 = waitForReplayRequest(page, 0);
24-
const reqPromise1 = waitForReplayRequest(page, 1);
25-
26-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
27-
return route.fulfill({
28-
status: 200,
29-
contentType: 'application/json',
30-
body: JSON.stringify({ id: 'test-id' }),
18+
for (let i = 0; i < 100; i++) {
19+
sentryTest(`handles an expired session RUN ${i}`, async ({ getLocalTestPath, page }) => {
20+
if (shouldSkipReplayTest()) {
21+
sentryTest.skip();
22+
}
23+
24+
const reqPromise0 = waitForReplayRequest(page, 0);
25+
const reqPromise1 = waitForReplayRequest(page, 1);
26+
27+
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
28+
return route.fulfill({
29+
status: 200,
30+
contentType: 'application/json',
31+
body: JSON.stringify({ id: 'test-id' }),
32+
});
3133
});
32-
});
3334

34-
const url = await getLocalTestPath({ testDir: __dirname });
35+
const url = await getLocalTestPath({ testDir: __dirname });
3536

36-
await page.goto(url);
37+
await page.goto(url);
3738

38-
const replayEvent0 = getReplayEvent(await reqPromise0);
39-
expect(replayEvent0).toEqual(getExpectedReplayEvent({}));
39+
const replayEvent0 = getReplayEvent(await reqPromise0);
40+
expect(replayEvent0).toEqual(getExpectedReplayEvent({}));
4041

41-
const fullSnapshots0 = getFullRecordingSnapshots(await reqPromise0);
42-
expect(fullSnapshots0.length).toEqual(1);
43-
const stringifiedSnapshot = normalize(fullSnapshots0[0]);
44-
expect(stringifiedSnapshot).toMatchSnapshot('snapshot-0.json');
42+
const fullSnapshots0 = getFullRecordingSnapshots(await reqPromise0);
43+
expect(fullSnapshots0.length).toEqual(1);
44+
const stringifiedSnapshot = normalize(fullSnapshots0[0]);
45+
expect(stringifiedSnapshot).toMatchSnapshot('snapshot-0.json');
4546

46-
// We wait for another segment 0
47-
const reqPromise2 = waitForReplayRequest(page, 0);
47+
// We wait for another segment 0
48+
const reqPromise2 = waitForReplayRequest(page, 0);
4849

49-
await page.click('#button1');
50-
const replayEvent1 = getReplayEvent(await reqPromise1);
51-
expect(replayEvent1).toEqual(getExpectedReplayEvent({ replay_start_timestamp: undefined, segment_id: 1, urls: [] }));
50+
await page.click('#button1');
51+
const replayEvent1 = getReplayEvent(await reqPromise1);
52+
expect(replayEvent1).toEqual(
53+
getExpectedReplayEvent({ replay_start_timestamp: undefined, segment_id: 1, urls: [] }),
54+
);
5255

53-
const fullSnapshots1 = getFullRecordingSnapshots(await reqPromise1);
54-
expect(fullSnapshots1.length).toEqual(0);
56+
const fullSnapshots1 = getFullRecordingSnapshots(await reqPromise1);
57+
expect(fullSnapshots1.length).toEqual(0);
5558

56-
const incrementalSnapshots1 = getIncrementalRecordingSnapshots(await reqPromise1);
57-
// The number of incremental snapshots depends on the browser
58-
expect(incrementalSnapshots1.length).toBeGreaterThanOrEqual(4);
59+
const incrementalSnapshots1 = getIncrementalRecordingSnapshots(await reqPromise1);
60+
// The number of incremental snapshots depends on the browser
61+
expect(incrementalSnapshots1.length).toBeGreaterThanOrEqual(4);
5962

60-
expect(incrementalSnapshots1).toEqual(
61-
expect.arrayContaining([
62-
{
63-
source: 1,
64-
positions: [
65-
{
66-
id: 9,
67-
timeOffset: expect.any(Number),
68-
x: expect.any(Number),
69-
y: expect.any(Number),
70-
},
71-
],
72-
},
73-
]),
74-
);
63+
expect(incrementalSnapshots1).toEqual(
64+
expect.arrayContaining([
65+
{
66+
source: 1,
67+
positions: [
68+
{
69+
id: 9,
70+
timeOffset: expect.any(Number),
71+
x: expect.any(Number),
72+
y: expect.any(Number),
73+
},
74+
],
75+
},
76+
]),
77+
);
7578

76-
const replay = await getReplaySnapshot(page);
77-
const oldSessionId = replay.session?.id;
79+
const replay = await getReplaySnapshot(page);
80+
const oldSessionId = replay.session?.id;
7881

79-
await new Promise(resolve => setTimeout(resolve, SESSION_TIMEOUT));
82+
await new Promise(resolve => setTimeout(resolve, SESSION_TIMEOUT));
8083

81-
await page.click('#button2');
84+
await page.click('#button2');
8285

83-
const replay2 = await getReplaySnapshot(page);
86+
const replay2 = await getReplaySnapshot(page);
8487

85-
expect(replay2.session?.id).not.toEqual(oldSessionId);
88+
expect(replay2.session?.id).not.toEqual(oldSessionId);
8689

87-
const replayEvent2 = getReplayEvent(await reqPromise2);
88-
expect(replayEvent2).toEqual(getExpectedReplayEvent({}));
90+
const replayEvent2 = getReplayEvent(await reqPromise2);
91+
expect(replayEvent2).toEqual(getExpectedReplayEvent({}));
8992

90-
const fullSnapshots2 = getFullRecordingSnapshots(await reqPromise2);
91-
expect(fullSnapshots2.length).toEqual(1);
92-
const stringifiedSnapshot2 = normalize(fullSnapshots2[0]);
93-
expect(stringifiedSnapshot2).toMatchSnapshot('snapshot-2.json');
94-
});
93+
const fullSnapshots2 = getFullRecordingSnapshots(await reqPromise2);
94+
expect(fullSnapshots2.length).toEqual(1);
95+
const stringifiedSnapshot2 = normalize(fullSnapshots2[0]);
96+
expect(stringifiedSnapshot2).toMatchSnapshot('snapshot-2.json');
97+
});
98+
}

packages/integration-tests/suites/replay/sessionInactive/test.ts

Lines changed: 61 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -14,73 +14,75 @@ import {
1414
// Session should expire after 2s - keep in sync with init.js
1515
const SESSION_TIMEOUT = 2000;
1616

17-
sentryTest('handles an inactive session', async ({ getLocalTestPath, page }) => {
18-
if (shouldSkipReplayTest()) {
19-
sentryTest.skip();
20-
}
21-
22-
const reqPromise0 = waitForReplayRequest(page, 0);
23-
24-
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
25-
return route.fulfill({
26-
status: 200,
27-
contentType: 'application/json',
28-
body: JSON.stringify({ id: 'test-id' }),
17+
for (let i = 0; i < 100; i++) {
18+
sentryTest(`handles an inactive session RUN ${i}`, async ({ getLocalTestPath, page }) => {
19+
if (shouldSkipReplayTest()) {
20+
sentryTest.skip();
21+
}
22+
23+
const reqPromise0 = waitForReplayRequest(page, 0);
24+
25+
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
26+
return route.fulfill({
27+
status: 200,
28+
contentType: 'application/json',
29+
body: JSON.stringify({ id: 'test-id' }),
30+
});
2931
});
30-
});
3132

32-
const url = await getLocalTestPath({ testDir: __dirname });
33+
const url = await getLocalTestPath({ testDir: __dirname });
3334

34-
await page.goto(url);
35+
await page.goto(url);
3536

36-
const replayEvent0 = getReplayEvent(await reqPromise0);
37-
expect(replayEvent0).toEqual(getExpectedReplayEvent({}));
37+
const replayEvent0 = getReplayEvent(await reqPromise0);
38+
expect(replayEvent0).toEqual(getExpectedReplayEvent({}));
3839

39-
const fullSnapshots0 = getFullRecordingSnapshots(await reqPromise0);
40-
expect(fullSnapshots0.length).toEqual(1);
41-
const stringifiedSnapshot = normalize(fullSnapshots0[0]);
42-
expect(stringifiedSnapshot).toMatchSnapshot('snapshot-0.json');
40+
const fullSnapshots0 = getFullRecordingSnapshots(await reqPromise0);
41+
expect(fullSnapshots0.length).toEqual(1);
42+
const stringifiedSnapshot = normalize(fullSnapshots0[0]);
43+
expect(stringifiedSnapshot).toMatchSnapshot('snapshot-0.json');
4344

44-
await page.click('#button1');
45+
await page.click('#button1');
4546

46-
// We wait for another segment 0
47-
const reqPromise1 = waitForReplayRequest(page, 0);
47+
// We wait for another segment 0
48+
const reqPromise1 = waitForReplayRequest(page, 0);
4849

49-
// Now we wait for the session timeout, nothing should be sent in the meanwhile
50-
await new Promise(resolve => setTimeout(resolve, SESSION_TIMEOUT));
50+
// Now we wait for the session timeout, nothing should be sent in the meanwhile
51+
await new Promise(resolve => setTimeout(resolve, SESSION_TIMEOUT));
5152

52-
// nothing happened because no activity/inactivity was detected
53-
const replay = await getReplaySnapshot(page);
54-
// @ts-ignore private api
55-
expect(replay._isEnabled).toEqual(true);
56-
// @ts-ignore private api
57-
expect(replay._isPaused).toEqual(false);
53+
// nothing happened because no activity/inactivity was detected
54+
const replay = await getReplaySnapshot(page);
55+
// @ts-ignore private api
56+
expect(replay._isEnabled).toEqual(true);
57+
// @ts-ignore private api
58+
expect(replay._isPaused).toEqual(false);
5859

59-
// Now we trigger a blur event, which should move the session to paused mode
60-
await page.evaluate(() => {
61-
window.dispatchEvent(new Event('blur'));
62-
});
60+
// Now we trigger a blur event, which should move the session to paused mode
61+
await page.evaluate(() => {
62+
window.dispatchEvent(new Event('blur'));
63+
});
64+
65+
const replay2 = await getReplaySnapshot(page);
66+
// @ts-ignore private api
67+
expect(replay2._isEnabled).toEqual(true);
68+
// @ts-ignore private api
69+
expect(replay2._isPaused).toEqual(true);
6370

64-
const replay2 = await getReplaySnapshot(page);
65-
// @ts-ignore private api
66-
expect(replay2._isEnabled).toEqual(true);
67-
// @ts-ignore private api
68-
expect(replay2._isPaused).toEqual(true);
69-
70-
// Trigger an action, should re-start the recording
71-
await page.click('#button2');
72-
73-
const replay3 = await getReplaySnapshot(page);
74-
// @ts-ignore private api
75-
expect(replay3._isEnabled).toEqual(true);
76-
// @ts-ignore private api
77-
expect(replay3._isPaused).toEqual(false);
78-
79-
const replayEvent1 = getReplayEvent(await reqPromise1);
80-
expect(replayEvent1).toEqual(getExpectedReplayEvent({}));
81-
82-
const fullSnapshots1 = getFullRecordingSnapshots(await reqPromise0);
83-
expect(fullSnapshots1.length).toEqual(1);
84-
const stringifiedSnapshot1 = normalize(fullSnapshots1[0]);
85-
expect(stringifiedSnapshot1).toMatchSnapshot('snapshot-1.json');
86-
});
71+
// Trigger an action, should re-start the recording
72+
await page.click('#button2');
73+
74+
const replay3 = await getReplaySnapshot(page);
75+
// @ts-ignore private api
76+
expect(replay3._isEnabled).toEqual(true);
77+
// @ts-ignore private api
78+
expect(replay3._isPaused).toEqual(false);
79+
80+
const replayEvent1 = getReplayEvent(await reqPromise1);
81+
expect(replayEvent1).toEqual(getExpectedReplayEvent({}));
82+
83+
const fullSnapshots1 = getFullRecordingSnapshots(await reqPromise0);
84+
expect(fullSnapshots1.length).toEqual(1);
85+
const stringifiedSnapshot1 = normalize(fullSnapshots1[0]);
86+
expect(stringifiedSnapshot1).toMatchSnapshot('snapshot-1.json');
87+
});
88+
}

0 commit comments

Comments
 (0)