Repository: puma/puma
File: test/test_integration_cluster.rb (Ruby)

Code before:

    # below is so all of @server_log isn't simply output on failure
    refute @server_log[/.*Terminating timed out worker.*/]
  end

  def test_refork_phased_restart_with_fork_worker_and_high_worker_count
    worker_count = 10

    cli_server "test/rackup/hello.ru", config: <<~CONFIG
      fork_worker 1000 # not going to be reached
      worker_check_interval 1
      # lower worker timeout from default (60) to avoid test timeout
      worker_timeout 2
      # to simulate worker 0 timeout, total boot time for all workers
      # needs to exceed single worker timeout
      workers #{worker_count}
    CONFIG

    get_worker_pids 0, worker_count

    Process.kill :SIGURG, @pid

    get_worker_pids 1, worker_count - 1

    # below is so all of @server_log isn't simply output on failure
    refute @server_log[/.*Terminating timed out worker.*/]
  end

  def test_prune_bundler_with_multiple_workers
    cli_server "-C test/config/prune_bundler_with_multiple_workers.rb"
    reply = read_body(connect)

    assert reply, "embedded app"
  end

  def test_load_path_includes_extra_deps
    cli_server "-w #{workers} -C test/config/prune_bundler_with_deps.rb test/rackup/hello.ru"

    assert wait_for_server_to_match(/^LOAD_PATH: .+?\/gems\/minitest-[\d.]+\/lib$/)
  end

  def test_load_path_does_not_include_nio4r
    cli_server "-w #{workers} -C test/config/prune_bundler_with_deps.rb test/rackup/hello.ru"

    get_worker_pids # reads thru 'LOAD_PATH:' data

    # make sure we're seeing LOAD_PATH: logging
    assert_match(/^LOAD_PATH: .+\/gems\/minitest-[\d.]+\/lib$/, @server_log)
    refute_match(%r{gems/nio4r-[\d.]+/lib$}, @server_log)
  end


Review comment (suggestion):
All in all, I think this tests is good... we send `SIGURG` and we ensure no worker timed out by looking at the logs.

Just some details I don't understand. :) 

Code after:

    # below is so all of @server_log isn't simply output on failure
    refute @server_log[/.*Terminating timed out worker.*/]
  end

  def test_refork_phased_restart_with_fork_worker_and_high_worker_count
    worker_count = 10

    cli_server "test/rackup/hello.ru", config: <<~CONFIG
      fork_worker
      worker_check_interval 1
      # lower worker timeout from default (60) to avoid test timeout
      worker_timeout 2
      # to simulate worker 0 timeout, total boot time for all workers
      # needs to exceed single worker timeout
      workers #{worker_count}
    CONFIG

    get_worker_pids 0, worker_count

    Process.kill :SIGURG, @pid

    get_worker_pids 1, worker_count - 1

    # below is so all of @server_log isn't simply output on failure
    refute @server_log[/.*Terminating timed out worker.*/]
  end

  def test_prune_bundler_with_multiple_workers
    cli_server "-C test/config/prune_bundler_with_multiple_workers.rb"
    reply = read_body(connect)

    assert reply, "embedded app"
  end

  def test_load_path_includes_extra_deps
    cli_server "-w #{workers} -C test/config/prune_bundler_with_deps.rb test/rackup/hello.ru"

    assert wait_for_server_to_match(/^LOAD_PATH: .+?\/gems\/minitest-[\d.]+\/lib$/)
  end

  def test_load_path_does_not_include_nio4r
    cli_server "-w #{workers} -C test/config/prune_bundler_with_deps.rb test/rackup/hello.ru"

    get_worker_pids # reads thru 'LOAD_PATH:' data

    # make sure we're seeing LOAD_PATH: logging
    assert_match(/^LOAD_PATH: .+\/gems\/minitest-[\d.]+\/lib$/, @server_log)
    refute_match(%r{gems/nio4r-[\d.]+/lib$}, @server_log)
  end