Skip to content

test: Fix flaky droppedError test #7337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/integration-tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const config: PlaywrightTestConfig = {
retries: 0,
// Run tests inside of a single file in parallel
fullyParallel: true,
// Use 5 workers on CI, else use defaults (based on available CPU cores)
// Note that 5 is a random number selected to work well with our CI setup
workers: process.env.CI ? 5 : undefined,
// Use 3 workers on CI, else use defaults (based on available CPU cores)
// Note that 3 is a random number selected to work well with our CI setup
workers: process.env.CI ? 3 : undefined,
};
export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,58 @@ import { getReplayEvent, shouldSkipReplayTest, waitForReplayRequest } from '../.
* TODO: Once we have lifecycle hooks, we should revisit this test and make sure it behaves as expected.
* This means that the recording should not be started or stopped if the error that triggered it is not sent.
*/
sentryTest(
'[error-mode] should start recording if an error occurred although the error was dropped',
async ({ getLocalTestPath, page }) => {
if (shouldSkipReplayTest()) {
sentryTest.skip();
}
for (let i = 0; i < 100; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jup, just waiting for the final test run 👍

sentryTest(
`[error-mode] should start recording if an error occurred although the error was dropped RUN ${i}`,
async ({ getLocalTestPath, page }) => {
if (shouldSkipReplayTest()) {
sentryTest.skip();
}

let callsToSentry = 0;
const reqPromise0 = waitForReplayRequest(page, 0);
const reqPromise0 = waitForReplayRequest(page, 0);
const reqPromise1 = waitForReplayRequest(page, 1);
const reqPromise2 = waitForReplayRequest(page, 2);

await page.route('https://dsn.ingest.sentry.io/**/*', route => {
callsToSentry++;
return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 'test-id' }),
let callsToSentry = 0;

await page.route('https://dsn.ingest.sentry.io/**/*', route => {
callsToSentry++;

return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 'test-id' }),
});
});
});

const url = await getLocalTestPath({ testDir: __dirname });
const url = await getLocalTestPath({ testDir: __dirname });

await page.goto(url);
await page.click('#go-background');
expect(callsToSentry).toEqual(0);

await page.goto(url);
await page.click('#go-background');
expect(callsToSentry).toEqual(0);
await page.click('#error');
const req0 = await reqPromise0;

await page.click('#error');
const req0 = await reqPromise0;
await page.click('#go-background');
await reqPromise1;

await page.click('#go-background');
expect(callsToSentry).toEqual(2); // 2 replay events
await page.click('#log');
await page.click('#go-background');
await reqPromise2;

await page.click('#log');
await page.click('#go-background');
// Note: The fact that reqPromise1/reqPromise2 are fulfilled prooves that the recording continues

const event0 = getReplayEvent(req0);
const event0 = getReplayEvent(req0);

expect(event0).toEqual(
getExpectedReplayEvent({
contexts: { replay: { error_sample_rate: 1, session_sample_rate: 0 } },
// This is by design. A dropped error shouldn't be in this list.
error_ids: [],
replay_type: 'error',
}),
);
},
);
expect(event0).toEqual(
getExpectedReplayEvent({
contexts: { replay: { error_sample_rate: 1, session_sample_rate: 0 } },
// This is by design. A dropped error shouldn't be in this list.
error_ids: [],
replay_type: 'error',
}),
);
},
);
}
6 changes: 3 additions & 3 deletions packages/nextjs/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const config: PlaywrightTestConfig = {
},
// Run tests inside of a single file in parallel
fullyParallel: true,
// Use 5 workers on CI, else use defaults (based on available CPU cores)
// Note that 5 is a random number selected to work well with our CI setup
workers: process.env.CI ? 5 : undefined,
// Use 3 workers on CI, else use defaults (based on available CPU cores)
// Note that 3 is a random number selected to work well with our CI setup
workers: process.env.CI ? 3 : undefined,
webServer: {
cwd: path.join(__dirname, 'test', 'integration'),
command: 'yarn start',
Expand Down
6 changes: 3 additions & 3 deletions packages/remix/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const config: PlaywrightTestConfig = {
},
// Run tests inside of a single file in parallel
fullyParallel: true,
// Use 5 workers on CI, else use defaults (based on available CPU cores)
// Note that 5 is a random number selected to work well with our CI setup
workers: process.env.CI ? 5 : undefined,
// Use 3 workers on CI, else use defaults (based on available CPU cores)
// Note that 3 is a random number selected to work well with our CI setup
workers: process.env.CI ? 3 : undefined,
webServer: {
command: '(cd test/integration/ && yarn build && yarn start)',
port: 3000,
Expand Down