当使用Docker Centos 7.5映像运行GitLab CI管道时,ChromeHeadless给出超时 [英] ChromeHeadless giving timeout when running GitLab CI pipeline with Docker Centos 7.5 image

查看:188
本文介绍了当使用Docker Centos 7.5映像运行GitLab CI管道时,ChromeHeadless给出超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我尝试使用GitLab CI管道在带有Centos 7.5的Docker映像上针对Angular 6应用程序运行Karma测试.

So I am trying to run Karma tests for an Angular 6 application on a docker image with Centos 7.5 using a pipeline for GitLab CI.

问题是

30 08 2018 07:09:55.222:WARN [启动器]:ChromeHeadless还没有 在60000毫秒内捕获,杀死. 30 08 2018 07:09:55.244:INFO [启动器]:尝试再次启动ChromeHeadless(1/2). 30 08 2018 07:10:55.264:WARN [发射器]:ChromeHeadless在60000毫秒内未捕获,导致死亡. 30 08 2018 07:10:55.277:INFO [启动器]:尝试再次启动ChromeHeadless(2/2). 30 08 2018 07:11:55.339:WARN [发射器]:ChromeHeadless在60000毫秒内未捕获,导致死亡. 30 08 2018 07:11:55.355:ERROR [启动]:ChromeHeadless失败2次(超时).放弃. 错误:作业失败:退出代码1

30 08 2018 07:09:55.222:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing. 30 08 2018 07:09:55.244:INFO [launcher]: Trying to start ChromeHeadless again (1/2). 30 08 2018 07:10:55.264:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing. 30 08 2018 07:10:55.277:INFO [launcher]: Trying to start ChromeHeadless again (2/2). 30 08 2018 07:11:55.339:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing. 30 08 2018 07:11:55.355:ERROR [launcher]: ChromeHeadless failed 2 times (timeout). Giving up. ERROR: Job failed: exit code 1

我用ng test --browsers ChromeHeadlessNoSandbox --watch=false --code-coverage

业力conf:

browsers: ['Chrome', 'ChromeHeadlessNoSandbox'],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: [
          '--no-sandbox',
          '--disable-setuid-sandbox',
          '--disable-gpu',
          '--remote-debugging-port=9222',
        ],
      },
    },

还在Image docker文件上,我安装了最新的Chrome稳定程序:

Also on the Image the docker file I install the latest chrome stable:

RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
RUN yum -y localinstall google-chrome-stable_current_x86_64.rpm && yum clean all

您是否知道为什么给超时?在本地环境中,它运行完美.

Do you have any idea about why its giving timeout? In the local environment, it runs perfectly.

推荐答案

我已经解决了相同的问题.我的测试服可以在本地计算机上完美运行,但是在docker容器中运行这些测试时,由于连接超时而导致失败. (我也在使用Gitlab Runner,而我的docker镜像基于circleci/node:8.9.2-browsers)

I have resolved the same issue. My test suits runs perfectly in my local machine but when running these tests in a docker container, it fails due to connection timeout. (i'm using Gitlab runner also, and My docker image is based on circleci/node:8.9.2-browsers)

在研究了这个问题之后,我发现docker bin文件中缺少chrome bin变量路径.所以我通过添加以下内容解决了该问题: export CHROME_BIN=/usr/bin/google-chromebefore_script

After investigating this issue, i found that the chrome bin variable path was missed in the docker file. so i fixed the issue by adding: export CHROME_BIN=/usr/bin/google-chrome to my .gitlab-ci.yml in before_script

# TESTING
unit_test_client:
  stage: test
  before_script:
    - export CHROME_BIN=/usr/bin/google-chrome
  script:
    - npm run test:client

您还可以通过设置CHROME_BIN来解决您的问题 业力配置文件顶部的process.env.CHROME_BIN='/usr/bin/google-chrome'. 在这种情况下,您需要处理在本地计算机上运行测试的情况,可能它应该匹配相同的镶边路径

You can also fix your issue by setting the CHROME_BIN by process.env.CHROME_BIN='/usr/bin/google-chrome' in the top of your karma config file. In this case, you need to handle the case that you are running the test in your local machine, probably it should match the same chrome path

这篇关于当使用Docker Centos 7.5映像运行GitLab CI管道时,ChromeHeadless给出超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆