Browser with Docker on ARM64 doesn't work

Brief summary

I try to set up browser tests with k6. However it always failed with browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module.

k6 version

0.46.0

OS

macOS 13.4.1

Docker version and image (if applicable)

grafana/k6:0.46.0-with-browser

Steps to reproduce the problem

  1. Start k6 in docker using below command
docker run --rm --cap-add=SYS_ADMIN \
    --entrypoint sh \
    -it grafana/k6:0.46.0-with-browser
  1. Add example script with browser set up (below is script content)
import { browser } from 'k6/experimental/browser';

export const options = {
  scenarios: {
    ui: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
  thresholds: {
    checks: ["rate==1.0"]
  }
}

export default async function () {
  const page = browser.newPage();

  try {
    await page.goto('https://test.k6.io/');
    page.screenshot({ path: 'screenshot.png' });
  } finally {
    page.close();
  }
}
  1. Start k6 using k6 run script.js

Expected behaviour

Start testings

Actual behaviour

Show errors as below:

ERRO[0003] process with PID 22 unexpectedly ended: signal: trace/breakpoint trap  category=browser elapsed="0 ms" source=browser
ERRO[0003] Uncaught (in promise) GoError: browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module
running at github.com/grafana/xk6-browser/browser.mapBrowser.func6 (native)
ui     [at file:///home/k6/script.js:20:15(4)  executor=shared-iterations scenario=ui
2 Likes

I’m having the same problem when running the test with the browser with the command in cmd:

“k6 run --vus 2 --duration 10s script2.js”

If I run it only with: “k6 run script2.js” it doesn’t return the error.

I have the same version on k6, but running on windows.

Hi @kamontat,

When you run the test script what command do you use?

Some command line arguments do not currently work when working with browser tests such as -u (--vus), -i (--iterations), and -d (--duration). You can set these up in the scenario itself (reference).

Hope that helps,
Ankur

2 Likes

@fsimoneto,

I can see that you are using --vus and --duration as command line args. They currently do not work with browser tests. You can instead add these to the scenario itself (reference).

Hope that helps,
Ankur

3 Likes

Command: k6 run script.js.
I didn’t use any of unsupported options (--vus, --iterations, or --duration)

Hi @kamontat,

I was able to run the test script you’ve provided with the latest release of k6 (v0.46.0) with k6 run test.js :+1:

I’ve replicated the issue that you are having on a mac running on a ARM processor when working with the specified (grafana/k6:0.46.0-with-browser) docker image. That docker image has been built for AMD64 processors and it unfortunately Chrome within the docker image is unable to start up. The error message you are seeing is incorrect and we need to fix that; i have opened a new issue to track this.

If you are reliant on working with a docker image you will need to either build your own image from scratch on your Mac, or use the image on a machine running a AMD64 processor. We have a issue to track the progress of the ARM images here.

Hope this helps,
Ankur

Hi @kamontat and @fsimoneto,

First of all, please make sure you’re running the latest Docker version.

Then, please make sure to update Rosetta and export an environment variable with the following:

$ export DOCKER_DEFAULT_PLATFORM=linux/amd64
$ softwareupdate --install-rosetta

Lastly, enable the Rosetta AMD64 emulation on the Docker side. Also, please make sure to enable containerd.

And this:

Lastly, restart Docker, and please try the following command:

# set the platform to linux/amd64
$ docker run --rm -i --cap-add=SYS_ADMIN --platform linux/amd64 grafana/k6:master-with-browser run -q - <examples/locator.js

This runs the locator test script (it should exist in the examples folder).

Hope this helps.

This works, Thank you.

1 Like