Angular 5:Karma 单元测试无法在 CI 环境中启动 HeadlessChrome

Angular 5: Karma Unit testing fails to start HeadlessChrome on CI environment

我们在 CI 环境(Jenkins 在 Openshift 上的 Docker build pod 中)面临问题。

错误:无法调整 pid 为 261 的渲染器的 OOM 分数:权限被拒绝 (13)

这里有一些额外的信息:

版本:

[31m22 01 2018 13:05:37.019:ERROR [launcher]: [39mChrome stdout: [31m22 01 2018 13:05:37.019:ERROR [launcher]: [39mChrome stderr: DevTools listening on ws://127.0.0.1:9222/devtools/browser/c45b2629-938e-490e-a8af-706302677ea4 [0122/130522.747519:ERROR:zygote_host_impl_linux.cc(268)] Failed to adjust OOM score of renderer with pid 261: Permission denied (13) [0122/130533.563149:INFO:CONSOLE(8743)] "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.", source: http://localhost:9876/_karma_webpack_/polyfills.bundle.js (8743) [0122/130533.563271:ERROR:service_manager.cc(157)] Connection InterfaceProviderSpec prevented service: content_renderer from binding interface: blink::mojom::ReportingServiceProxy exposed by: content_browser

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

在我们将 build pod 的内存从 1GB 增加到 2GB 之后,现在一切都运行顺利....