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

Refactor integration test browser #935

Merged
merged 46 commits into from
Jun 16, 2023
Merged

Refactor integration test browser #935

merged 46 commits into from
Jun 16, 2023

Conversation

inancgumus
Copy link
Member

@inancgumus inancgumus commented Jun 14, 2023

Updates: #898.

This PR improves the test browser into this one as follows. It's a nice first small step in removing the api package, and starting with the core of tests seemed to me an effective idea. While on it, I also made a refactoring that had been on my mind for quite a while.

  • Removes the api package dependency by using concrete types. See it here altogether.
  • Refactors the test browser options to Rob Pike's self-referential functions pattern. See it here altogether.
  • Refactors the options to adjust the test browser behavior directly. I can remove this change. That part was an experiment, and it turned out to be useful. Please let me know which one you prefer: testBrowserOptions or testBrowser.
  • Unexports the exported identifiers to keep it self-reliant.
  • Makes use of the test browser helpers in the tests.
  • Fixes the linter errors.
  • Removes remnants.

@inancgumus inancgumus self-assigned this Jun 14, 2023
This will be needed when options need to set testBrowser themselves.
Instead of doing all the work in newTestBrowser and complicating it.
This will let us the testBrowser's initialization stage. Since it first
makes a test VU and then uses it to initialize a browser type, some
options (i.e. withLogCache) can only be used after the initialization.
However, some others (i.e. withSamples) can only be used before the
initialization. This fields lets us use both kind of options and let
them init by detecting the init stage.
The option is now responsible for setting the log cache. This has the
benefit of reducing the pollution in the newTestBrowser function and
separates the responsibilities. We also don't need to keep track of
whether to set the log cache. The option does that.
We're starting to remove the testBrowserOptions.
Simplify and remove testBrowserOptions. Options are now a part of
testBrowser itself.
This makes it easier to see the initialization of the test browser as
they're related.
@inancgumus inancgumus marked this pull request as ready for review June 15, 2023 07:54
@inancgumus inancgumus requested review from ka3de and ankur22 June 15, 2023 07:54
tests/test_browser.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

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

LGTM. I left a couple of nit picks comments 🙂

Would be nice next time if large refactors could be broken down into smaller PRs 😅

tests/test_browser.go Outdated Show resolved Hide resolved
tests/test_browser.go Outdated Show resolved Hide resolved
tests/test_browser.go Outdated Show resolved Hide resolved
tests/test_browser.go Outdated Show resolved Hide resolved
@inancgumus
Copy link
Member Author

inancgumus commented Jun 16, 2023

@ankur22, thanks for your review 🙇

Would be nice next time if large refactors could be broken down into smaller PRs 😅

Sorry for the hassle 😢 I understand the challenge with the commit count! While I've added descriptive links to help, they may not be enough 😢 Despite this PR being smaller than usual, I acknowledge that breaking larger refactors into smaller atomic PRs could aid comprehension. We also need to ensure clarity is maintained due to too many PRs. How about discussing the best approach in a brief meeting? 🙂 I'm sure we can devise a suitable solution for all. Thanks for your input! 👍

Copy link
Collaborator

@ka3de ka3de left a comment

Choose a reason for hiding this comment

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

Nice refactor! 👏 Although quite lengthy 😅
I think readability of the testBrowser implementation is better now and helper methods are better organized. Thanks!
Just made a small comment.

k6ext/k6test/vu.go Outdated Show resolved Hide resolved
@inancgumus
Copy link
Member Author

Nice refactor! 👏 Although quite lengthy 😅

Thanks, @ka3de 🙇 You mean the number of commits since our usual PRs are larger? Then again, sorry for the hassle :( I couldn't keep it smaller to make it a meaningful unit of work. I'm happy to discuss this in a short meeting :)

I think readability of the testBrowser implementation is better now and helper methods are better organized. Thanks!
Just made a small comment.

Good to hear!

@inancgumus inancgumus merged commit 45b3e8b into main Jun 16, 2023
9 of 13 checks passed
@inancgumus inancgumus deleted the refactor/test-browser branch June 16, 2023 12:28
@inancgumus inancgumus added the productivity Issues and PRs that improve our productivity label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
productivity Issues and PRs that improve our productivity refactor tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants