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

k6 hosts option doesn't work on an already running browser instance #811

Open
ankur22 opened this issue Mar 6, 2023 · 2 comments
Open
Labels
bug Something isn't working remote remote browser related
Milestone

Comments

@ankur22
Copy link
Collaborator

ankur22 commented Mar 6, 2023

Brief summary

Try to run examples/hosts.js and it should not be able to navigate to test.k6.io since the hosts option has been used so that test.k6.io resolves to 127.0.0.254. This is the expected behaviour when working with this example file.

If we change the script so that it connects to an already browser instance, then the browser will resolve to the actual test.k6.io ip address, and not to 127.0.0.254, which is the incorrect behaviour for this example file.

The reason the behaviour is incorrect when testing on an already running browser instance, is because the k6 hosts option in k6-browser uses Chromium's --host-resolver-rules in the background to resolve hosts to a given IP. If the browser is already running then how can we inject this rule?

xk6-browser version

48ee41a

OS

NA

Chrome version

Version 110.0.5481.177 (Official Build) (arm64)

Docker version and image (if applicable)

NA

Steps to reproduce the problem

  1. Start a browser instance.
  2. Change the examples/hosts.js file to connect to the running browser instance from the previous step.
  3. Run k6 with the modified examples/hosts.js file.

Expected behaviour

The test should pass since test.k6.io resolves to 127.0.0.254.

Actual behaviour

The test fails since it resolves to the actual IP address of test.k6.io.

@ankur22 ankur22 added the bug Something isn't working label Mar 6, 2023
@inancgumus inancgumus added the remote remote browser related label Mar 6, 2023
@ankur22 ankur22 added this to the v0.9.0 milestone Mar 7, 2023
@ka3de
Copy link
Collaborator

ka3de commented Mar 13, 2023

Researching about how to block a blacklist through CDP, I found the Fetch domain, which probably would allows us to implement the "hosts" functionality with an already launched browser, although the development "cost" is higher than just specifying a flag on startup.

@ankur22
Copy link
Collaborator Author

ankur22 commented Mar 13, 2023

Researching about how to block a blacklist through CDP

That's a good find, could be useful in the future!

I found the Fetch domain, which probably would allows us to implement the "hosts" functionality with an already launched browser

We use fetch already so we should be able to fit that in quite easily.

@inancgumus inancgumus modified the milestones: v0.9.0, v0.10.0 Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working remote remote browser related
Projects
None yet
Development

No branches or pull requests

3 participants