[英]Gitlab-ci runner hangs after cypress tests
I am using gitlab-ci to tests a react application with cypress .我正在使用gitlab-ci来测试带有cypress的反应应用程序。
The test seems to pass but it hangs after executing cypress run
command.测试似乎通过了,但它在执行
cypress run
命令后挂起。 Thus, the test fails because of the timeout.因此,测试因超时而失败。
My service is the following我的服务如下
cypress:
image: cypress/base:10
script:
- serve -s build -l 3000 & yarn wait-on http://localhost:3000
- yarn cypress:run
And in my package.json在我的 package.json
{
...
"scripts": {
"cypress:run": "cypress run --spec 'cypress/integration/**/*spec.js' --record false --config video=false"
},
...
}
This is the end of gitlab-ci runner's log:这是 gitlab-ci runner 日志的结尾:
✔ All specs passed! 01:01 11 11 - - -
Done in 73.82s.
ERROR: Job failed: execution took longer than 20m0s seconds
this issue occurs when a background task is running in the runner当后台任务在运行器中运行时会出现此问题
To fix this I put in an or condition on the cypress:run step and kill the process if the result is not a success为了解决这个问题,我在 cypress:run 步骤中设置了 or 条件,如果结果不成功,则终止进程
there is another kill statement added in the step below also in case -parallel is used and multiple steps are running在使用 -parallel 并且正在运行多个步骤的情况下,以下步骤中还添加了另一个 kill 语句
Something like this像这样的东西
script:
# start the server in the background
- npx serve -s build -p 3001 &
# run Cypress tests in parallel
- yarn cypress:run || (ps -ef | grep [s]erve| awk '{print $2}' | xargs kill -9 )
- (ps -ef | grep [s]erve| awk '{print $2}' | xargs kill -9 ) || exit 0
I don't know if this can help someone, but it is worth to try updating node.我不知道这是否可以帮助某人,但值得尝试更新节点。
I had the same problem when using cypress 11.1.0 and node:16.17.1-slim
docker image.使用 cypress 11.1.0 和
node:16.17.1-slim
docker 图像时,我遇到了同样的问题。 I do not experience hang ups with node:16.18.1-slim
anymore.我不再遇到
node:16.18.1-slim
的挂起问题。
PS Along with node update I've updated Chrome from 106 to 107, so can't be sure what actually made the trick, just wanted to share with possible solution. PS 随着节点更新,我已经将 Chrome 从 106 更新到 107,所以不能确定到底是什么导致了这个问题,只是想与可能的解决方案分享。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.