Fargate 上的错误 运行 Chimp / Webdriver.io / Selenium(Chrome 无法启动)

Error running Chimp / Webdriver.io / Selenium on Fargate (Chrome failed to start)

我正在尝试使用 Chimp 运行 我在 Fargate 上的测试用例,它在内部使用 Webdriver.io / Selenium。当我 运行 在我的 EC2 实例上安装它们时,它们 运行 在我的 docker 容器中很好,但是一旦我将我的容器上传到 ECS 并尝试使用执行相同的测试Fargate,我收到以下错误:

Chimp version:  0.50.2
ChromeDriver version:  ChromeDriver 2.34.522913 (36222509aa6e819815938cbf2709b4849735537c)
Java version:  openjdk version "1.8.0_151", OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-1~deb9u1-b12), OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
Selenium version:  3.8.1
Selenium drivers version:  chrome: 2.34, ie: 2.50.0, firefox: 0.19.1
OS version:  Linux 4.9.62-21.56.amzn1.x86_64
Node version:  v6.11.5
Browser version:  chrome undefined
[33m
[chimp] Running...[39m
[chimp][helper] setupBrowserAndDDP had error
{ Error: unknown error: Chrome failed to start: exited abnormally
    at initBrowser (node_modules/chimp/dist/lib/chimp-helper.js:189:43)
    at Object.setupBrowserAndDDP (node_modules/chimp/dist/lib/chimp-helper.js:264:7)
    at node_modules/chimp/dist/lib/cucumberjs/hooks.js:22:24
    at node_modules/meteor-promise/fiber_pool.js:43:40
    (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.9.62-21.56.amzn1.x86_64 x86_64)
    at new RuntimeError (node_modules/webdriverio/build/lib/utils/ErrorHandler.js:144:12)
    at Request._callback (node_modules/webdriverio/build/lib/utils/RequestHandler.js:313:39)
    at Request.self.callback (node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (node_modules/request/request.js:1163:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (node_modules/request/request.js:1085:12)
    at IncomingMessage.g (events.js:292:16)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickDomainCallback [as _tickCallback] (internal/process/next_tick.js:128:9)
  details: undefined,
  message: 'unknown error: Chrome failed to start: exited abnormally\n  (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.9.62-21.56.amzn1.x86_64 x86_64)',
  type: 'RuntimeError',
  seleniumStack: 
   { type: 'UnknownError',
     message: 'An unknown server-side error occurred while processing the command.',
     orgStatusMessage: 'unknown error: Chrome failed to start: exited abnormally\n  (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.9.62-21.56.amzn1.x86_64 x86_64)' } }
Error: unknown error: Chrome failed to start: exited abnormally
    at initBrowser (node_modules/chimp/dist/lib/chimp-helper.js:189:43)
    at Object.setupBrowserAndDDP (node_modules/chimp/dist/lib/chimp-helper.js:264:7)
    at node_modules/chimp/dist/lib/cucumberjs/hooks.js:22:24
    at node_modules/meteor-promise/fiber_pool.js:43:40
    (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.9.62-21.56.amzn1.x86_64 x86_64)
    at new RuntimeError (node_modules/webdriverio/build/lib/utils/ErrorHandler.js:144:12)
    at Request._callback (node_modules/webdriverio/build/lib/utils/RequestHandler.js:313:39)
    at Request.self.callback (node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (node_modules/request/request.js:1163:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (node_modules/request/request.js:1085:12)
    at IncomingMessage.g (events.js:292:16)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickDomainCallback [as _tickCallback] (internal/process/next_tick.js:128:9)
Cucumber steps failed

我尝试将以下行添加到我的测试脚本的开头,以确保 Chrome 存在并响应:

echo Running chrome version:
google-chrome --version

结果是:

Running chrome version:
Google Chrome 62.0.3202.75 

所以 Chrome 在那里并且正在响应。为什么它在 Fargate 中不起作用?

开头的 Chimp 调试信息中的以下调试行看起来是最大的罪魁祸首:

Browser version:  chrome undefined

我不知道为什么找不到它。当我在本地 运行ning 时,它会报告正确的版本。

很久以后我才知道我的 docker 容器在保存图像之前没有成功完成所有操作。当我解决这个问题时,这个问题就消失了。 X11 在 Docker 容器/AWS Fargate 中运行良好。

如果 --headless 模式不适用于您的应用程序(这似乎是一个有点频繁的事件),您也可以在没有 Headless 的情况下为帧缓冲区尝试 Xvfb Chrome。