使用Docker和Jenkins运行测试 - 测试结果 [英] Running tests with Docker and Jenkins - Test Result

查看:386
本文介绍了使用Docker和Jenkins运行测试 - 测试结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Rails写的应用程序。为了测试它,我已经建立了一个码头图像。一切正常。



但是,当我配置Jenkins来运行这些测试时,会出现问题。这是我做的,在建立步骤:

  docker-comps up rspec 

其中rspec是在docker-compose.yml中定义的服务,包含以下命令:

 命令:rspec spec /

当rspec返回错误的构建仍然成功。
这里输出一个例子:

  ... 
21:42:24 [36mrspec_1 | [0m应该保存第二个配置文件
21:42:24 [36mrspec_1 | [0m
21:42:24 [36mrspec_1 | [0m失败:
21:42:24 [36mrspec_1 | [0m
21:42:24 [36mrspec_1 | [0m 1]新的个人资料应该坚持new_profile_pricture
21:42:24 [36mrspec_1 | [0m失败/错误:jump_to_four_phase_with(new_profile_picture)
21:42 :24 [36mrspec_1 | [0m RuntimeError:
21:42:24 [36mrspec_1 | [0m超时为'#new_profile'(1)出现了!
...
21:42:25 [36mcompose_rspec_1退出与代码1
21:42:25 [0m [Profiler] $ / bin / sh -xe /tmp/hudson4606189750126491465.sh
21:42:25完成:成功

36mcompose_rspec_1 返回1并且构建仍然成功。



如果我使用docker检查容器的id = code> ps -a 我得到退出(1)2分钟前



你们知道发生了什么吗?


解决方案

Jenkins使用进程的退出状态判断成功或失败。



docker-compise up 旨在协调许多容器。当您处理多个容器时,对于什么构成成功和失败,存在一些灰色区域。退出时的所有 docker-compose 报告是 docker-compose 命令成功完成,而不是所有容器运行没关系



docker-compose run< command> 将运行一个命令并返回该命令退出状态。 p>

如果您依赖于多个服务/容器进行测试,则需要 docker-compise up 仅提供所需的服务。然后运行 docker-compose run rspec ,以进行测试。


I have an application written in Rails. In order to test it I've built a docker image. Everything works fine.

The problem, however, appears when I configure Jenkins to run those tests. Here's what I do, at the building step:

docker-compose up rspec

Where rspec is a service defined at docker-compose.yml and contains the following command:

command: "rspec spec/"

When rspec returns an error the build still succeeds. Here an example of the output:

    ...
21:42:24 [36mrspec_1  |[0m       should save second profile
21:42:24 [36mrspec_1  |[0m 
21:42:24 [36mrspec_1  |[0m Failures:
21:42:24 [36mrspec_1  |[0m 
21:42:24 [36mrspec_1  |[0m   1) New profile Should persist new_profile_pricture
21:42:24 [36mrspec_1  |[0m      Failure/Error: jump_to_four_phase_with(new_profile_picture)
21:42:24 [36mrspec_1  |[0m      RuntimeError:
21:42:24 [36mrspec_1  |[0m        Timeout for '#new_profile' (1) appearance reached!
...
21:42:25 [36mcomposes_rspec_1 exited with code 1
21:42:25 [0m[Profiler] $ /bin/sh -xe /tmp/hudson4606189750126491465.sh
21:42:25 Finished: SUCCESS

36mcomposes_rspec_1 returned 1 and the build still succeeded.

If I check the container by its id with docker ps -a I get "Exited (1) 2 minutes ago"

Do you guys know what is going on?

Is there an easy way to fail the build when the container fails?

解决方案

Jenkins uses the exit status of the process to judge success or failure.

docker-compose up is designed to orchestrate many containers. When you are dealing with multiple containers there is a bit of a grey area as to what constitutes success and failure. All that docker-compose reports on exit is that the docker-compose command completed successfully, not that all containers it ran are ok.

docker-compose run <command> will run a single command and return that commands exit status.

If you rely on multiple services/containers for the tests, then have docker-compose up only bring up the required services. Then run docker-compose run rspec afterwards for your tests.

这篇关于使用Docker和Jenkins运行测试 - 测试结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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