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 isRemoteBrowser check #889

Merged
merged 9 commits into from May 23, 2023
Merged

Refactor isRemoteBrowser check #889

merged 9 commits into from May 23, 2023

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented May 17, 2023

Description of changes

This refactors the IsRemoteBrowser detection of the code so that it is done once when creating the RootModule. We now rely on a remoteRegistry which can be accessed by the mapping when a new vu is initialised. Eventually when there are multiple remote chrome instances, this will select one of many ws urls and return it for use in the current vu/iteration.

@ankur22 ankur22 requested review from inancgumus and ka3de May 17, 2023 16:38
@ankur22 ankur22 self-assigned this May 17, 2023
@ankur22 ankur22 added this to the v0.10.0 milestone May 17, 2023
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

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

Nice, but I remember @ka3de has been refactoring the similar parts in #876?

@ankur22
Copy link
Collaborator Author

ankur22 commented May 18, 2023

Nice, but I remember @ka3de has been refactoring the similar parts in #876?

I'll take a look at that PR first. Thanks for the heads up.

@ankur22 ankur22 changed the title Refactor/remote global check Refactor is remote check May 18, 2023
@ankur22 ankur22 changed the title Refactor is remote check Refactor isRemoteBrowser check May 18, 2023
We're renaming them from webvital_xxx_xxx_xxx to browser_web_vital_xxx.
This change benefits us in three ways:
1. Browser metrics will be namespaced with browser_
2. webvital is two words, so web vital
3. We're assuming that users will have the context of web vital metrics
so that we can use the abbreviations which also helps with the display
of them at the end of the test run.

Closes: #884
@ankur22 ankur22 force-pushed the refactor/remote-global-check branch from 63196d0 to b64e8b1 Compare May 18, 2023 11:01
@ankur22 ankur22 changed the base branch from main to update/858-validate-browser-opts May 18, 2023 11:01
This type will use env to retrieve the remote ws url details and
whether one is supplied. It will store this data, which can then
be retrieved when needed.
Create a new instance of remoteRegistry which can be stored in the
RootModule. This single instance of remoteRegistry can be set in all
new ModuleInstances. Later on anything requiring the remoteRegistry
should be able to access it to retrieve the remote ws url.
@ankur22 ankur22 force-pushed the refactor/remote-global-check branch from b64e8b1 to 2980e0d Compare May 18, 2023 11:06
Now that the remoteRegistry is part of the ModuleInstance, we can
retrieve the parsed data from the env var and use it when setting up
the mapping for the current vu.
@ankur22 ankur22 force-pushed the refactor/remote-global-check branch from 2980e0d to b3b101f Compare May 18, 2023 11:08
browser/remoteregistry.go Outdated Show resolved Hide resolved
Base automatically changed from update/858-validate-browser-opts to main May 18, 2023 14:01
browser/remoteregistry.go Outdated Show resolved Hide resolved
When K6_BROWSER_WS_URL is a comma separated list of ws urls, we need
to pick from the list every time remoteRegistry.IsRemoteBrowser is
called, not just once when remoteRegistry is created. This change moves
the round robin (with the use of rand) to remoteRegistry.Is...
...RemoteBrowser from env.IsRemoteBrowser. env.IsRemoteBrowser now
only collects and returns the list of ws urls.
@ankur22 ankur22 force-pushed the refactor/remote-global-check branch from dd7a025 to a81d246 Compare May 22, 2023 10:05
Env package now contains one type that is specific to the environment.
The registry package contains changes which are specific to retrieving
the remote ws urls. So this commit splits the two different concerns.
A future commit with also move the remote registry specific logic from
the browser package into the registry package.
To encapsulate the remote registry logic, we've moved the remote
registry logic from the browser package into the remote package.
We no longer need to expose the pkg scoped IsRemoteBrowser since the
only thing calling it is NewRemoteRegistry. The logic has been moved
into NewRemoteRegistry.
@ankur22 ankur22 requested review from ka3de and inancgumus May 22, 2023 10:45
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

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

Nice 👏

registry/doc.go Show resolved Hide resolved
browser/modulevu.go Outdated Show resolved Hide resolved
ankur22 added a commit that referenced this pull request May 22, 2023
@ankur22 ankur22 force-pushed the refactor/remote-global-check branch from 6fc9b9f to 6d87e37 Compare May 22, 2023 15:10
@ankur22 ankur22 mentioned this pull request May 22, 2023
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.

LGTM 👏

@ankur22 ankur22 merged commit fffc577 into main May 23, 2023
13 checks passed
@ankur22 ankur22 deleted the refactor/remote-global-check branch May 23, 2023 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants