Skip to content
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

chore: Remove retries for testcafe tests but increase timeout. Wait for lag in parallel #1380

Merged
merged 54 commits into from
Aug 26, 2024

Conversation

robbie-c
Copy link
Member

@robbie-c robbie-c commented Aug 22, 2024

Changes

Problem: previously, the test had a relatively short timeout that was sometimes less than ingestion lag. It also retried 3x, and had 3 tests where the ingestion lag ran in series. This meant that if the tests were bounded by ingestion lag, they would take ingestion lag x9 to finish.

This remove those whole-suite-level retry. It also pulls the query logic out of the test code and moves it to a later step, so instead of doing:

  • test 1
  • lag
  • query assert 1
  • test 2
  • lag
  • query assert 2
  • test 3
  • lag
  • query assert 3

it now does

  • test 1
  • test 2
  • test 3
  • lag
  • query assert 1
  • query assert 2
  • query assert 3

It's obviously still not going to work if there's 3 hours of ingestion lag, but should be more resilient to e.g. 5 minutes of lag.

Checklist

  • Tests for new code (see advice on the tests we use)
  • Accounted for the impact of any changes across different browsers
  • Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)

Copy link

vercel bot commented Aug 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Aug 26, 2024 5:17pm

Copy link

github-actions bot commented Aug 22, 2024

Size Change: +2.47 kB (+0.21%)

Total Size: 1.17 MB

Filename Size Change
dist/array.full.js 334 kB +626 B (+0.19%)
dist/array.js 155 kB +616 B (+0.4%)
dist/main.js 156 kB +616 B (+0.4%)
dist/module.js 155 kB +616 B (+0.4%)
ℹ️ View Unchanged
Filename Size
dist/exception-autocapture.js 10.4 kB
dist/recorder-v2.js 110 kB
dist/recorder.js 110 kB
dist/surveys-preview.js 59.8 kB
dist/surveys.js 66 kB
dist/tracing-headers.js 8.26 kB
dist/web-vitals.js 5.79 kB

compressed-size-action

@robbie-c robbie-c force-pushed the fix/increase-test-timeout branch from ca68132 to 1e3655b Compare August 22, 2024 15:35
@robbie-c robbie-c force-pushed the fix/increase-test-timeout branch from e76e314 to cb53922 Compare August 23, 2024 10:54
@robbie-c robbie-c force-pushed the fix/increase-test-timeout branch from 1472351 to e6aab80 Compare August 23, 2024 15:51
Copy link
Collaborator

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

Not going to block but some comments added. Seeing as this is a "side-gig" feels acceptable but would love to see some much cleaner code there.

@@ -203,7 +203,7 @@ function _tryReadXHRBody({
if (isObject(body)) {
try {
return JSON.stringify(body)
} catch (e) {
} catch (_) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feels like these should just be empty rather than have an underscore 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

This is to workaround IE11 not supporting the optional catch binding syntax, i.e.

try {
  // some stuff
} catch {
  // other stuff
}

is not valid for IE11. There's a comment in this PR that links to some more details, see https://github.com/PostHog/posthog-js/pull/1380/files#diff-e2954b558f2aa82baff0e30964490d12942e0e251c1aa56c3294de6ec67b7cf5R12

Copy link
Member Author

Choose a reason for hiding this comment

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

(I'm not sure if we can just rely on babel to handle this for us, if we can then we might just want to change all of these)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah looks like we can, so I'll change these

Copy link
Collaborator

Choose a reason for hiding this comment

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

This the only thing I don't love... Feels like a hacky js script that we will not enjoy modifying and therefore won't improve upon later 🤔
All the hacky import stuff feels really nasty and it seems only to avoid making those assertion and loader helpers more pure. I appreciate this PR eats a lot of time so not going to block but this file is for sure going to be a headache in the future and cause people to turn away from improving things...

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, sorry to hear that you don't like this. I thought it was much easier to read the test code with the assertions in the same file as tests, so I prioritised that over making the setup code readable, and these hacks were included to make this work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants