简体   繁体   中英

EOFError with Capybara, Puma, Rails System Tests under SSL

Running Rails system tests under SSL exhibits strange behavior and I'm not sure if it's a bug or by design.

This very basic Example Application has one system test that looks for an element on the index page.

git clone https://github.com/frankjmattia/rails-ssl-system-tests.git blorgh
cd blorgh
./bin/setup

At this point you must create a self-signed certificate and direct your operating system to trust it.

./bin/generate-blorgh-cert blorgh.test

This will generate the certificate and print directions for trusting it on Mac OS X or Ubuntu. This will be valid for https://blorgh.test , https://127.0.0.1 , and https://localhost

rake to run the system test

or

rails s to start the server and then navigate to https://localhost:3000

When running the tests they pass, however I get an error thrown from Puma before I even make a request.

% rake
Run options: --seed 43000

# Running:
    Capybara starting Puma...
* Version 3.12.1 , codename: Llamas in Pajamas
* Min threads: 1, max threads: 1
* Listening on ssl://127.0.0.1:56260?key=/Users/frankjmattia/src/blorgh/ssl/blorgh.test.key.pem&cert=/Users/frankjmattia/src/blorgh/ssl/blorgh.test.cert.pem
2019-04-28 16:59:48 -0400: SSL error, peer: 127.0.0.1, peer cert: , #<Puma::MiniSSL::SSLError: OpenSSL error: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request - 336027804>
2019-04-28 16:59:49 -0400: SSL error, peer: 127.0.0.1, peer cert: , #<Puma::MiniSSL::SSLError: OpenSSL error: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request - 336027804>
.

Finished in 3.177669s, 0.3147 runs/s, 0.3147 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
2019-04-28 16:59:49 -0400: Read error: #<EOFError: EOFError>
/Users/frankjmattia/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/client.rb:306:in `try_to_finish'
/Users/frankjmattia/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/client.rb:119:in `reset'
/Users/frankjmattia/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:486:in `process_client'
/Users/frankjmattia/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:334:in `block in run'
/Users/frankjmattia/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/thread_pool.rb:135:in `block in spawn_thread'

I think this is from the Capybara server checking responsive? but I'm not sure how to prove it or work around it.

Also, even though all the test pass locally, they hang when run on a CI platform like SemaphoreCI.

If this is a bug, who's bug is it? I 'm leaning towards Capybara but don't want to waste anyones time filing a bug report if I don't have all the facts, or can't adequately describe it.

That SSL "error" is output by OpenSSL when Capybara attempts an http request to the server while waiting for the server to start and determine whether it is http or https. After receiving the error Capybara then retries as a https request. It isn't an error that actually affects anything other than a message being output and there's no reason that "error" should cause SemaphoreCI to hang.

If Semaphore is using the docker platform and you're running Chrome >= 73 you may find you need to pass the command line options --no-sandbox and --disable-features='VizDisplayCompositor' to Chrome in order for it to run correctly.

No clue what the EOFError is about though it could have to do with you switching app_host while the page is being requested (page load is not guaranteed to be done when visit returns)

Not doing this is what solved the issue for me. Passing the extra options to chromedriver was unnecessary in my case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM