testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Modify the GitLab recipe to use Headless Chromium

Open AM1988 opened this issue 4 years ago • 20 comments

What is your Scenario?

We run our tests on gitlabci using the official docker image testcafe/testcafe:1.16.0 and all is fine. Tests are executed behind the proxy. We tried to switch to a more fresh version 1.18.3 (changed only docker tag) but this resulted in the pipeline failure, tests are not executed and we see the next error:

ERROR Cannot establish one or more browser connections.
1 of 1 browser connections have not been established:
- chromium --start-maximized --incognito
Hints:
- Increase the value of the "browserInitTimeout" option if it is too low (currently: 2 minutes for local browsers and 6 minutes for remote browsers). This option determines how long TestCafe waits for browsers to be ready.
- The error can also be caused by network issues or remote device failure. Make sure that your network connection is stable and you can reach the remote device.```


- >
  /opt/testcafe/docker/testcafe-docker.sh "chromium --start-maximized --incognito"
  -c 1
  e2e/tests/*.test.ts
  --skip-js-errors --color
  --reporter spec,xunit:e2e/tests/reports/index.xml,html:e2e/tests/reports/index.html
  --video e2e/tests/reports/video
  --video-options singleFile=false,failedOnly=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.mp4
  -s takeOnFails=true,path=e2e/tests/reports/screenshots,fullPage=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.png
  --page-load-timeout 90000
  --assertion-timeout 60000
  --proxy $CODE_PROXY_HOST:$CODE_PROXY_PORT
  --page-request-timeout 60000
  -q attemptLimit=2,successThreshold=1

### What is the Current behavior?

Tests did not run

### What is the Expected behavior?

Tests are executed

### What is your public website URL? (or attach your complete example)

----

### What is your TestCafe test code?

any

### Your complete configuration file

no file

### Your complete test report

_No response_

### Screenshots

_No response_

### Steps to Reproduce

1. Run any test in docker v1.18.3

### TestCafe version

1.18.3

### Node.js version

-

### Command-line arguments

    - >       /opt/testcafe/docker/testcafe-docker.sh "chromium --start-maximized --incognito"       -c 1       e2e/tests/*.test.ts       --skip-js-errors --color       --reporter spec,xunit:e2e/tests/reports/index.xml,html:e2e/tests/reports/index.html       --video e2e/tests/reports/video       --video-options singleFile=false,failedOnly=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.mp4       -s takeOnFails=true,path=e2e/tests/reports/screenshots,fullPage=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.png       --page-load-timeout 90000       --assertion-timeout 60000       --proxy $CODE_PROXY_HOST:$CODE_PROXY_PORT       --page-request-timeout 60000       -q attemptLimit=2,successThreshold=1

### Browser name(s) and version(s)

chromium

### Platform(s) and version(s)

-

### Other

-

AM1988 avatar Feb 10 '22 13:02 AM1988

Unfortunately, I couldn't reproduce the issue on my side. Could you please share your project or, at least, your gitlab config file so that we can examine it and determine the cause of the issue?

dositec avatar Feb 11 '22 12:02 dositec

Hi @dositec

I can not share my project but it is quite standard I would say.

gitlab.ci is similar to the documentation https://testcafe.io/documentation/402816/guides/continuous-integration/gitlab

e2e_tests:
  image:
    name: testcafe/testcafe:1.18.3
    entrypoint: ["/bin/sh", "-c"]
  script:
    - >
        /opt/testcafe/docker/testcafe-docker.sh "chromium --start-maximized --incognito"
        -c 1
        e2e/tests/*.test.ts
        --skip-js-errors --color
        --reporter spec,xunit:e2e/tests/reports/index.xml,html:e2e/tests/reports/index.html
        --video e2e/tests/reports/video
        --video-options singleFile=false,failedOnly=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.mp4
        -s takeOnFails=true,path=e2e/tests/reports/screenshots,fullPage=true,pathPattern='${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}'.png
        --page-load-timeout 90000
        --assertion-timeout 60000
        --proxy $CODE_PROXY_HOST:$CODE_PROXY_PORT
        --page-request-timeout 60000
        -q attemptLimit=2,successThreshold=1

and these tests run thru proxy.

AM1988 avatar Feb 11 '22 16:02 AM1988

I could not reproduce the problem with the settings on my side. You can try to find its cause on your own. Add the disablehttp2 argument to the Jobs section of your .yml GitLab CI configuration file. Then, try to reproduce the problem and share your results with us.

dositec avatar Feb 14 '22 09:02 dositec

nothing has changed with that flag image

AM1988 avatar Feb 14 '22 10:02 AM1988

Seems it is chromium related issue. I've tried to run tests in firefox with the same settings and it works fine. image

In chromium:headless it also works fine.

AM1988 avatar Feb 14 '22 10:02 AM1988

I'm happy to hear that you've solved the problem. Could you please create a simple public project on GitLab where the problem is reproduced and share a project link so that we can research the problem and fix it?

dositec avatar Feb 15 '22 07:02 dositec

Here it is: https://gitlab.com/AM1988/testacfe-ci-setup/-/tree/docker_testcafe_1.18.3 (branch -> docker_testcafe_1.18.3)

Example of failed pipeline: https://gitlab.com/AM1988/testacfe-ci-setup/-/jobs/2093946120

$ /opt/testcafe/docker/testcafe-docker.sh "chromium --start-maximized --incognito" -c 1 e2e/tests/*.test.ts --skip-js-errors --color --page-load-timeout 90000 --assertion-timeout 60000 --page-request-timeout 60000 -q attemptLimit=2,successThreshold=1
ERROR Cannot establish one or more browser connections.
1 of 1 browser connections have not been established:
- chromium --start-maximized --incognito
Hints:
- Increase the value of the "browserInitTimeout" option if it is too low (currently: 2 minutes for local browsers and 6 minutes for remote browsers). This option determines how long TestCafe waits for browsers to be ready.
- The error can also be caused by network issues or remote device failure. Make sure that your network connection is stable and you can reach the remote device.

AM1988 avatar Feb 15 '22 08:02 AM1988

We have also observed this issue quite often on latest testcafe docker image for chromium:headless For us the issue is seen intermittently i.e. not reproducible for every run, but a bunch of jobs fail over a period of time.

monicainde avatar Feb 15 '22 10:02 monicainde

I ran into the same problem today. Yesterday we switched our Kubernetes NodePools from Container-Optimized OS with Docker (cos) to Container-Optimized OS with containerd (cos_containerd) and the error has been occurring since then.

egobude avatar Feb 15 '22 15:02 egobude

This solved the issue for us: https://testcafe.io/documentation/402838/guides/advanced-guides/use-testcafe-docker-image#troubleshooting

egobude avatar Feb 16 '22 05:02 egobude

I've tried with "chromium --no-sandbox --disable-dev-shm-usage" but that does not help, still getting the same error.

AM1988 avatar Feb 16 '22 08:02 AM1988

I have this problem too, but unfortunately I can't share it, --no-sandbox --disable-dev-shm-usage do not help, forfox is ok,but not stabilization

rr13k avatar Feb 16 '22 08:02 rr13k

Not sure if it helps in resolving this problem, I had reported very similar issue couple of months back here.

monicainde avatar Feb 16 '22 13:02 monicainde

Hello @AM1988, thank for the provided links:

Here it is: https://gitlab.com/AM1988/testacfe-ci-setup/-/tree/docker_testcafe_1.18.3 (branch -> docker_testcafe_1.18.3) Example of failed pipeline: https://gitlab.com/AM1988/testacfe-ci-setup/-/jobs/2093946120

Unfortunately, I can't open the links. I think this is related to the permission level of the project. I am currently getting a "404 Page Not Found" page. Could you please give public permissions to the project?

dositec avatar Feb 17 '22 08:02 dositec

@dositec my fault, fixed. Could you please check once again?

AM1988 avatar Feb 17 '22 08:02 AM1988

@AM1988 Thank you for the answer. Currently, I have access to your project, but I don't have access to your CI/CD; we need it to reproduce the problem (I have access to the pipelines but I don't have access to the "Run" button). Could you please give us access to your CI/CD? You can send the credentials to our email - [email protected]. We will keep this information private and will remove the credential when we resolve this problem.

dositec avatar Feb 18 '22 08:02 dositec

@dositec I've given you a 'Developer' role in that project. So you should be able to run the pipeline now. I believe you can also simply fork the project and try it within your own account.

I will not share my creds )

AM1988 avatar Feb 18 '22 08:02 AM1988

@AM1988 Thank you for the clarification and help. We reproduced the behavior, but we don't think that it's a bug. Could you please to try using "chromium:headless" instead of "chromium" in your .yaml file to avoid the error message? We will correct our documentation to point out that the correct way is to use "chromium:headless" in the pipeline file.

dositec avatar Feb 22 '22 10:02 dositec

yup, chromium:headless does the job as I said in the https://github.com/DevExpress/testcafe/issues/6865#issuecomment-1038933460

AM1988 avatar Feb 22 '22 11:02 AM1988

The documentation has been updated. It may take a while for the website to reflect these changes.

titerman avatar Oct 19 '22 11:10 titerman