用于并行测试 Rails 应用程序的 JRuby 友好方法
我正在寻找一个系统,可以在使用 JRuby 运行的 Ruby on Rails 应用程序(使用 rspec、cucumber)中并行化大量测试。 Cucumber 实际上还不错,但完整的 rSpec 套件目前需要近 20 分钟才能运行。
我能找到的系统(Hydra、并行测试)看起来像是使用分叉,这不是 JRuby 环境的理想解决方案。
I am looking for a system to parallelise a large suite of tests in a Ruby on Rails app (using rspec, cucumber) that works using JRuby. Cucumber is actually not too bad, but the full rSpec suite currently takes nearly 20 minutes to run.
The systems I can find (hydra, parallel-test) look like they use forking, which isn't the ideal solution for the JRuby environment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于此类应用,我们目前还没有一个好的答案。就在最近,我开发了 spork 的一个分支,它允许您保持进程运行并重新运行规范或其功能,前提是您使用的是支持代码重新加载的应用程序框架(例如 Rails)。查看 jrubyhub 应用程序,了解我如何使用 Spork 的示例。
您可能能够为您的应用程序生成一个 spork 实例,然后向它发送多个线程请求以运行不同的规范。但是你依赖 RSpec 内部结构来保证线程安全,不幸的是我很确定它们不是。
也许您可以以我的代码为起点,构建一个 spork 实例集群,然后拥有一个可以在它们之间分发测试套件的客户端。它不会节省内存,并且仍然需要很长时间才能启动,但是如果您将它们全部启动一次并重复使用它们进行重复运行,您可能会提高效率。
请随时访问 freenode 上的 [email protected] 或 #jruby 了解更多信息想法。
We don't have a good answer for this kind of application right now. Just recently I worked on a fork of spork that allows you to keep a process running and re-run specs or features in it, provided you're using an app framework that supports code reloading (like Rails). Take a look at the jrubyhub application for an example of how I use Spork.
You might be able to spawn a spork instance for your application and then send multiple, threaded requests to it to run different specs. But then you're relying on RSpec internals to be thread-safe, and unfortunately I'm pretty sure they're not.
Maybe you could take my code as a starting point and build a cluster of spork instances, and then have a client that can distribute your test suite across them. It's not going to save memory and will still take a long time to start up, but if you start them all once and just re-use them for repeated runs, you might make some gains in efficiency.
Feel free to stop by [email protected] or #jruby on freenode for more ideas.