Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI on FreeBSD #2589

Open
dentarg opened this issue Apr 1, 2021 · 15 comments
Open

CI on FreeBSD #2589

dentarg opened this issue Apr 1, 2021 · 15 comments

Comments

@dentarg
Copy link
Member

dentarg commented Apr 1, 2021

I think we can get CI going on FreeBSD using Cirrus CI, from https://cirrus-ci.org/features/:

To support the Open Source community, Cirrus CI provides Linux, Windows, macOS and FreeBSD services free of charge with some limits but without a cap on how many minutes a month OSS projects can consume.

Even after applying #2588, there are many failing tests (gist with test output), it seems to be all that use wait_for_server_to_boot:

# wait for server to say it booted
def wait_for_server_to_boot(log: false)
if log
puts "Waiting for server to boot..."
begin
line = @server.gets
puts line if line && line.strip != ''
end while line !~ /Ctrl-C/
puts "Server booted!"
else
true while @server.gets !~ /Ctrl-C/
end
end

Anyone has any idea?

@MSP-Greg
Copy link
Member

MSP-Greg commented Apr 1, 2021

@dentarg

Interesting. What happens if you change it to something like:

true until @server.gets.include? 'Ctrl-C'

@dentarg
Copy link
Member Author

dentarg commented Apr 1, 2021

@MSP-Greg Thanks!

Using this diff now there is progress: https://gist.github.com/dentarg/0f3137b724f83818fcacfd95c0bf5560 (2 failures, 2 errors)

diff --git a/lib/puma/server.rb b/lib/puma/server.rb
index 0b42460c..d0e09a34 100644
--- a/lib/puma/server.rb
+++ b/lib/puma/server.rb
@@ -137,8 +137,6 @@ module Puma
     # socket parameter may be an MiniSSL::Socket, so use to_io
     #
     if tcp_cork_supported?
-      UNPACK_TCP_STATE_FROM_TCP_INFO = "C".freeze
-
       # 6 == Socket::IPPROTO_TCP
       # 3 == TCP_CORK
       # 1/0 == turn on/off
@@ -168,6 +166,8 @@ module Puma
     end

     if closed_socket_supported?
+      UNPACK_TCP_STATE_FROM_TCP_INFO = "C".freeze
+
       def closed_socket?(socket)
         return false unless socket.kind_of? TCPSocket
         return false unless @precheck_closing
diff --git a/test/helpers/integration.rb b/test/helpers/integration.rb
index b13ef2a3..b6a2aff8 100644
--- a/test/helpers/integration.rb
+++ b/test/helpers/integration.rb
@@ -109,7 +109,7 @@ class TestIntegration < Minitest::Test
       end while line !~ /Ctrl-C/
       puts "Server booted!"
     else
-      true while @server.gets !~ /Ctrl-C/
+      true until @server.gets.to_s.include?("Ctrl-C")
     end
   end
(Added #to_s as I saw two nil errors happening)
Run options: --seed 32132

# Running:

.....................................................................................................................................................................................................................................................F........................................................................................S..........................................F............................Traceback (most recent call last):
	6: from <internal:gem_prelude>:1:in `<internal:gem_prelude>'
	5: from <internal:gem_prelude>:1:in `require'
	4: from /usr/local/lib/ruby/site_ruby/2.7/rubygems.rb:9:in `<top (required)>'
	3: from /usr/local/lib/ruby/site_ruby/2.7/rubygems.rb:9:in `require'
	2: from /usr/local/lib/ruby/2.7/amd64-freebsd12/rbconfig.rb:11:in `<top (required)>'
	1: from /usr/local/lib/ruby/2.7/amd64-freebsd12/rbconfig.rb:12:in `<module:RbConfig>'
/usr/local/lib/ruby/2.7/amd64-freebsd12/rbconfig.rb:12:in `start_with?': Interrupt
#<Thread:0x0000000805d8f9c0 /usr/home/vagrant/puma/test/helpers/integration.rb:267 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
	1: from /usr/home/vagrant/puma/test/helpers/integration.rb:275:in `block in hot_restart_does_not_drop_connections'
/usr/home/vagrant/puma/test/helpers/integration.rb:112:in `wait_for_server_to_boot': undefined method `include?' for nil:NilClass (NoMethodError)
Traceback (most recent call last):
	1: from /usr/home/vagrant/puma/test/helpers/integration.rb:275:in `block in hot_restart_does_not_drop_connections'
/usr/home/vagrant/puma/test/helpers/integration.rb:112:in `wait_for_server_to_boot': undefined method `include?' for nil:NilClass (NoMethodError)

@dentarg
Copy link
Member Author

dentarg commented Apr 1, 2021

  • TestIntegrationSSL#test_ssl_run
  • TestIntegrationCluster#test_hot_restart_does_not_drop_connections
  • TestPumaServerSSL#test_ssl_v3_rejection
  • TestIntegrationSingle#test_term_not_accepts_new_connections

@dentarg
Copy link
Member Author

dentarg commented Apr 1, 2021

TestIntegrationSingle#test_term_not_accepts_new_connections

Ah... macOS and Linux:

$ curl http://127.0.0.1:1337
curl: (7) Failed to connect to 127.0.0.1 port 1337: Connection refused

FreeBSD:

$ curl http://127.0.0.1:1337
curl: (7) Couldn't connect to server

@dentarg
Copy link
Member Author

dentarg commented Apr 1, 2021

TestIntegrationSingle#test_term_not_accepts_new_connections

Expecting curl to print Connection reset by peer makes the test pass:

  1) Failure:
TestIntegrationSingle#test_term_not_accepts_new_connections [/usr/home/vagrant/puma/test/test_integration_single.rb:88]:
Expected /Connection refused|Couldn't connect to server/ to match "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\ncurl: (56) Recv failure: Connection reset by peer\n".

@dentarg
Copy link
Member Author

dentarg commented Apr 2, 2021

TestIntegrationCluster#test_hot_restart_does_not_drop_connections

Does not complete in 45 seconds for me, seems to need about 77 seconds

@dentarg
Copy link
Member Author

dentarg commented Apr 2, 2021

TestIntegrationSingle#test_term_not_accepts_new_connections

Expecting curl to print Connection reset by peer makes the test pass

...the second time the test is run:

$ time m test/test_integration_single.rb:66
Run options: -n "/^(test_term_not_accepts_new_connections)$/" --seed 7262

# Running:

F

Fabulous run in 10.176957s, 0.0983 runs/s, 0.6878 assertions/s.
Errors & Failures:

  1) Failure:
TestIntegrationSingle#test_term_not_accepts_new_connections [/usr/home/vagrant/puma/test/test_integration_single.rb:88]:
Expected /Connection refused|Connection reset by peer/ to match "curl: (7) Couldn't connect to server\n".

1 runs, 7 assertions, 1 failures, 0 errors, 0 skips
       10.36 real         0.15 user         0.10 sys
$
$
$ time m test/test_integration_single.rb:66
Run options: -n "/^(test_term_not_accepts_new_connections)$/" --seed 16538

# Running:

.

Fabulous run in 10.127876s, 0.0987 runs/s, 0.6912 assertions/s.

1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
       10.30 real         0.33 user         0.31 sys

When I ran the full suite (did this before the two runs above), there were some deadlocks:

$ time bundle exec rake
...
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [amd64-freebsd12]
RUBYOPT: -r/usr/home/vagrant/.gem/ruby/2.7/gems/bundler-2.2.15/lib/bundler/setup
                         Puma::MiniSSL                   OpenSSL
OPENSSL_LIBRARY_VERSION: OpenSSL 1.1.1h-freebsd  22 Sep 2020OpenSSL 1.1.1h-freebsd  22 Sep 2020
        OPENSSL_VERSION: OpenSSL 1.1.1h-freebsd  22 Sep 2020OpenSSL 1.1.1h-freebsd  22 Sep 2020

Run options: --seed 19437

# Running:

..........................................................................................................................................................................................................................................................................................................................................F...............................Traceback (most recent call last):
	13: from /usr/home/vagrant/puma/bin/puma:10:in `<main>'
	12: from /usr/home/vagrant/puma/lib/puma/cli.rb:80:in `run'
	11: from /usr/home/vagrant/puma/lib/puma/launcher.rb:181:in `run'
	10: from /usr/home/vagrant/puma/lib/puma/cluster.rb:439:in `run'
	 9: from /usr/home/vagrant/puma/lib/puma/runner.rb:29:in `log'
	 8: from /usr/home/vagrant/puma/lib/puma/events.rb:65:in `log'
	 7: from /usr/home/vagrant/puma/lib/puma/events.rb:65:in `puts'
	 6: from /usr/home/vagrant/puma/lib/puma/events.rb:65:in `write'
	 5: from /usr/home/vagrant/puma/lib/puma/cluster.rb:316:in `block in setup_signals'
	 4: from /usr/home/vagrant/puma/lib/puma/launcher.rb:221:in `close_binder_listeners'
	 3: from /usr/home/vagrant/puma/lib/puma/launcher.rb:366:in `log'
	 2: from /usr/home/vagrant/puma/lib/puma/events.rb:65:in `log'
	 1: from /usr/home/vagrant/puma/lib/puma/events.rb:65:in `puts'
/usr/home/vagrant/puma/lib/puma/events.rb:65:in `write': deadlock; recursive locking (ThreadError)
..Traceback (most recent call last):
	13: from /usr/home/vagrant/puma/bin/puma:10:in `<main>'
	12: from /usr/home/vagrant/puma/lib/puma/cli.rb:80:in `run'
	11: from /usr/home/vagrant/puma/lib/puma/launcher.rb:181:in `run'
	10: from /usr/home/vagrant/puma/lib/puma/cluster.rb:439:in `run'
	 9: from /usr/home/vagrant/puma/lib/puma/runner.rb:29:in `log'
	 8: from /usr/home/vagrant/puma/lib/puma/events.rb:65:in `log'
	 7: from /usr/home/vagrant/puma/lib/puma/events.rb:65:in `puts'
	 6: from /usr/home/vagrant/puma/lib/puma/events.rb:65:in `write'
	 5: from /usr/home/vagrant/puma/lib/puma/cluster.rb:316:in `block in setup_signals'
	 4: from /usr/home/vagrant/puma/lib/puma/launcher.rb:221:in `close_binder_listeners'
	 3: from /usr/home/vagrant/puma/lib/puma/launcher.rb:366:in `log'
	 2: from /usr/home/vagrant/puma/lib/puma/events.rb:65:in `log'
	 1: from /usr/home/vagrant/puma/lib/puma/events.rb:65:in `puts'
/usr/home/vagrant/puma/lib/puma/events.rb:65:in `write': deadlock; recursive locking (ThreadError)
..................................S................................................

Fabulous run in 278.188612s, 1.6068 runs/s, 4.7953 assertions/s.
Errors & Failures:

  1) Failure:
TestIntegrationSingle#test_term_not_accepts_new_connections [/usr/home/vagrant/puma/test/test_integration_single.rb:88]:
Expected /Connection refused|Connection reset by peer/ to match "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\r100     7  100     7    0     0    218      0 --:--:-- --:--:-- --:--:--   218\n".

447 runs, 1334 assertions, 1 failures, 0 errors, 1 skips

You have skipped tests. Run with --verbose for details.

------------------------------------------------------------ Debugging Info
TestIntegrationSingle#test_hot_restart_does_not_drop_connections_threads
   restart_count 13, reset 0, success after restart 972
TestIntegrationSingle#test_hot_restart_does_not_drop_connections
   restart_count 30, reset 0, success after restart 494
TestIntegrationCluster#test_hot_restart_does_not_drop_connections_threads
   restart_count 19, reset 0, success after restart 2954
TestIntegrationCluster#test_term_closes_listeners_unix
    10 successes, 0 resets, 30 refused, failures 0
TestIntegrationCluster#test_term_closes_listeners_tcp
    11 successes, 2 resets, 27 refused, failures 0
TestIntegrationCluster#test_hot_restart_does_not_drop_connections
   restart_count 59, reset 0, success after restart 995
---------------------------------------------------------------------------

rake aborted!
Command failed with status (1)

Tasks: TOP => default => test:all => test
(See full trace by running task with --trace)
      279.97 real        51.58 user        33.10 sys

@dentarg
Copy link
Member Author

dentarg commented Apr 3, 2021

TestIntegrationSingle#test_term_not_accepts_new_connections

This test was originally added in c0691e6 (#1685) as test_not_accepts_new_connections_after_term_signal

@dentarg
Copy link
Member Author

dentarg commented Apr 3, 2021

When I ran the full suite (did this before the two runs above), there were some deadlocks:

The deadlocks does not fail the build. They exist when we run on macOS too: https://github.com/puma/puma/runs/2250467472?check_suite_focus=true#step:9:429

@dentarg
Copy link
Member Author

dentarg commented Apr 3, 2021

TestIntegrationSingle#test_term_not_accepts_new_connections

I think this test should use the same technique as the cluster mode tests does (term_closes_listeners, originally introduced with #1808). With single mode and 12 threads, it seems to pass reliably.

@MSP-Greg
Copy link
Member

MSP-Greg commented Apr 3, 2021

@dentarg

Thanks for working on this, both FreeBSD & macOS with the new arch would both be good to add to CI.

Do you have a Cirrus CI script? I'd like to run it with https://github.com/MSP-Greg/puma/tree/test-update...

@dentarg
Copy link
Member Author

dentarg commented Apr 3, 2021

@MSP-Greg haven't yet tried Cirrus CI in my fork, but the instructions are at https://cirrus-ci.org/guide/FreeBSD/

I'm using Ruby 2.7 from FreeBSD ports over at https://github.com/dentarg/puma-vagrant and I think a complete script to run the tests would look something like this (installing devel/ruby-gems will also install ruby as it is an required dependency)

pkg install -y git devel/ragel devel/ruby-gems
gem install bundler
git clone https://github.com/puma/puma.git
cd puma
bundle
bundle exec rake

@MSP-Greg
Copy link
Member

MSP-Greg commented Apr 3, 2021

@dentarg Getting FreeBSD to run locally (Windows) is probably difficult, so I've got to use Cirrus CI. WSL2 can run Ubuntu and/or Debian.

@dentarg
Copy link
Member Author

dentarg commented Apr 3, 2021

@MSP-Greg both VirtualBox and Vagrant are available for Windows: https://www.virtualbox.org/wiki/Downloads, https://www.vagrantup.com/downloads – so I think you can run it if you and your PC are up for it ;-)

@MSP-Greg
Copy link
Member

MSP-Greg commented Apr 3, 2021

@dentarg

Thanks for the info.

if you and your PC are up for it

My PC, yes, I went a little overboard a few months ago.

Me? I'm staying busy with WSL2/Ubuntu, trying to not get frustrated jumping between bash & PowerShell. I'm doing most of my Puma work in WSL2/Ubuntu...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants