ruby-on-rails – Gterlab CI中的Poltergeist/PhantomJS崩溃

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Gterlab CI中的Poltergeist/PhantomJS崩溃前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
背景:

我的测试套件直到最近才处理任何JS功能.我刚开始
只在我的机器上使用selenium-webdriver javascript驱动程序和firefox 47.0.1
没有问题.然后我转移到支持PhantomJS的恶作剧家
我的javascript驱动程序.我不得不对一些破损的测试做一些修改,但是
非常喜欢转换,并在PhantomJS / poltergeist上’卖’.

预期行为:

我预计测试会像在我的机器上一样传递给我的Gitlab-ci
(嘿,我们可以梦想),可能需要一些配置调整.

版本:

Ruby – 2.3.1

Rails – 5.0.0.1

恶作剧者 – 1.12.0

rspec – 3.5.0

rspec-rails – 3.5.1

水豚 – 2.11.0

cliver – 0.3.2

factory_girl_rails – 4.7.0

phantomjs – 2.1.1(在我的机器和CI服务器上)

Capybara配置:

require 'capybara/rspec'
require 'capybara/poltergeist'

Capybara.default_driver = :rack_test
Capybara.register_driver :poltergeist do |app|
   options = {
     :js_errors => false,:timeout => 360,:phantomjs_options => ['--load-images=no','--ignore-ssl-errors=yes','--disk-cache=false']
   }
   Capybara::Poltergeist::Driver.new(app,options)
 end
 Capybara.javascript_driver = :poltergeist

DatabaseCleaner配置

config.before(:suite) do
    DatabaseCleaner.clean_with(:truncation)
  end

  config.before(:each) do
    DatabaseCleaner.strategy = Capybara.current_driver == :rack_test ? :transaction : :truncation
    DatabaseCleaner.clean
    DatabaseCleaner.start
  end


  config.after(:each) do |example|
    puts 'RAM USAGE: ' + `pmap #{Process.pid} | tail -1`[10,40].strip

    if defined?(page)
      Capybara.reset_sessions!
      page.driver.restart
    end
    DatabaseCleaner.clean
  end

实际行为/回溯:

1.失败的测试,PhantomJS崩溃

在我吃完所有记忆之前,在我的失败测试中获得完整的堆栈跟踪
在我的第一个错误中使用了rspec –fail-fast选项为我提供结果.
这是我回来的:

ArgumentError:
                The detector #<struct Cliver::Detector command_arg=nil,version_pattern=nil> Failed to detect theversion of the executable at '/usr/bin/phantomjs'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/cliver-0.3.2/lib/cliver/dependency.rb:191:in `detect_version'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/cliver-0.3.2/lib/cliver/dependency.rb:87:in `block in installed_versions'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/cliver-0.3.2/lib/cliver/dependency.rb:214:in `block in find_executables'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/cliver-0.3.2/lib/cliver/dependency.rb:208:in `map'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/cliver-0.3.2/lib/cliver/dependency.rb:208:in `find_executables'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/cliver-0.3.2/lib/cliver/dependency.rb:86:in `each'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/cliver-0.3.2/lib/cliver/dependency.rb:86:in `installed_versions'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/cliver-0.3.2/lib/cliver/dependency.rb:108:in `each'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/cliver-0.3.2/lib/cliver/dependency.rb:108:in `detect!'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/cliver-0.3.2/lib/cliver/dependency.rb:97:in `detect'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/cliver-0.3.2/lib/cliver.rb:35:in `detect'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/poltergeist-1.12.0/lib/capybara/poltergeist/client.rb:47:in `initialize'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/poltergeist-1.12.0/lib/capybara/poltergeist/client.rb:14:in `new'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/poltergeist-1.12.0/lib/capybara/poltergeist/client.rb:14:in `start'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/poltergeist-1.12.0/lib/capybara/poltergeist/driver.rb:44:in `client'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/poltergeist-1.12.0/lib/capybara/poltergeist/driver.rb:25:in `browser'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/poltergeist-1.12.0/lib/capybara/poltergeist/driver.rb:183:in `reset!'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/capybara-2.11.0/lib/capybara/session.rb:110:in `reset!'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/capybara-2.11.0/lib/capybara.rb:335:in `block in reset_sessions!'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/capybara-2.11.0/lib/capybara.rb:335:in `reverse_each'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/capybara-2.11.0/lib/capybara.rb:335:in `reset_sessions!'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/capybara-2.11.0/lib/capybara/rspec.rb:21:in `block (2 levels) in <top (required)>'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:357:in `run'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:507:in `block in run_owned_hooks_for'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:506:in `each'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:506:in `run_owned_hooks_for'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:593:in `block in run_example_hooks_for'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:592:in `each'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:592:in `run_example_hooks_for'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:463:in `run'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:503:in `run_after_example'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:269:in `block in run'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:496:in `block in with_around_and_singleton_context_hooks'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:453:in `block in with_around_example_hooks'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:464:in `block in run'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:604:in `block in run_around_example_hooks_for'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-rails-3.5.1/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:375:in `execute_with'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.4.5/lib/rspec/retry.rb:98:in `block in run'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.4.5/lib/rspec/retry.rb:88:in `loop'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.4.5/lib/rspec/retry.rb:88:in `run'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.4.5/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-retry-0.4.5/lib/rspec/retry.rb:22:in `block (2 levels) in setup'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:375:in `execute_with'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:607:in `run_around_example_hooks_for'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:464:in `run'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:453:in `with_around_example_hooks'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:496:in `with_around_and_singleton_context_hooks'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:251:in `run'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:627:in `block in run_examples'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:623:in `map'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:623:in `run_examples'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:589:in `run'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `block (3 levels) in run_specs'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `map'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `block (2 levels) in run_specs'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1835:in `with_suite_hooks'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:112:in `block in run_specs'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:77:in `report'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:111:in `run_specs'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:87:in `run'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/bin/rspec:23:in `load'
              # /home/gitlab-runner/builds/wow_such_build/0/schwad_project/redacted/vendor/bundle/ruby/2.3.0/bin/rspec:23:in `<main>'
              #
              #   Showing full backtrace because every line was filtered out.
              #   See docs for RSpec::Configuration#backtrace_exclusion_patterns and
              #   RSpec::Configuration#backtrace_inclusion_patterns for more information.

另外,在我的gitlab-ci.yml文件中,如果我在before_script中调用phantomjs –version,我会收到:

QXcbConnection: Could not connect to display
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.

任何有关这方面的帮助将非常感激.

2.内存爆破已解决:请参阅更新2

即使我们增加了内存容量,测试也会耗尽内存
服务器,并在测试套件完成之前崩溃.跟踪内存使用情况
我运行的每个测试后在我的RSpec配置中:

put’输入代码hereRAM USAGE:’pmap#{Process.pid} | tail -1 [10,40] .strip

在模型测试下,内存受到的影响微乎其微,但增长迅速
在集成测试下.像这样:

Model Test-
RAM USAGE: 567800K
Model Test-
RAM USAGE: 567800K
Model Test-
RAM USAGE: 567800K
Model Test-
RAM USAGE: 568220K
Model Test-
RAM USAGE: 568220K
Model Test-
RAM USAGE: 568360K
Model Test-
RAM USAGE: 568500K
Model Test-
RAM USAGE: 568652K
Model Test-
RAM USAGE: 568788K

First Feature Test:
RAM USAGE: 1100628K

并从那里炸毁.

为了解决这个问题,我确保使用适当的DatabaseCleaner策略,
也通过尝试工具如Capybara.reset_sessions!来循环
Capybara.current_session.driver.quit,page.driver.quit,page.driver.restart
没有真正的快乐.

更新:

UTC时间下午5:06,2016年12月15日

1.崩溃

Gitlab的支持建议调查我们的软件包和依赖项是否会导致PhantomJS出现非无头情况.我们现在正在研究这个问题.

2.记忆

我在这里针对几个不同的迭代运行了一个内存跟踪器,它似乎只是简单地启用我们的js:javascript驱动程序的真正功能测试占用内存,从1G进行大约1,750次测试,超过我们的4G限制在1,800-1,850测试.我相信这似乎发生在selenium-webdriver或poltergeist作为js驱动程序.

更新2:

UTC时间11:45 PM,16/12/16

1.崩溃

还在等待在我们的服务器上正确安装软件包.如果这是问题,将更新并奖励答案.

2.记忆

在我们迁移到启用Javascript驱动程序的一批测试的分支上,部分加速测试的配置实现了DeferredGarbageCollector,它具有吞噬内存的设置. PhantomJS和Poltergeist没有泄漏.解决

解决方法

http://github.com/ariya/phantomjs/issues/14240是你的PhantomJS崩溃的原因 – Ubuntu发布的PhantomJS版本需要运行X.

下载官方发布版本并使用它来解决崩溃问题.

您可能希望将内存问题添加为单独的问题.

原文链接:https://www.f2er.com/ruby/267953.html

猜你在找的Ruby相关文章