From 9ce8d4fc4ee24a65fc96838d604235d521feaf06 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Tue, 1 Oct 2019 09:01:45 -0500 Subject: [PATCH] Add tests for pre-existing unix paths 1. test_binder.rb - test_pre_existing_unix 2. test_integration_cluster.rb - test_pre_existing_unix --- test/test_binder.rb | 17 +++++++++++++++++ test/test_integration_cluster.rb | 20 +++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/test/test_binder.rb b/test/test_binder.rb index dc45adfb..198370ec 100644 --- a/test/test_binder.rb +++ b/test/test_binder.rb @@ -78,6 +78,23 @@ class TestBinder < TestBinderBase assert_parsing_logs_uri [:tcp, :unix] end + def test_pre_existing_unix + skip UNIX_SKT_MSG unless UNIX_SKT_EXIST + unix_path = "test/#{name}_server.sock" + + File.open(unix_path, mode: 'wb') { |f| f.puts 'pre eixisting' } + @binder.parse ["unix://#{unix_path}"], @events + + assert_match %r!unix://#{unix_path}!, @events.stdout.string + + refute_includes @binder.instance_variable_get(:@unix_paths), unix_path + + ensure + if UNIX_SKT_EXIST + File.unlink unix_path if File.exist? unix_path + end + end + private def assert_parsing_logs_uri(order = [:unix, :tcp]) diff --git a/test/test_integration_cluster.rb b/test/test_integration_cluster.rb index f6634c3b..0973b511 100644 --- a/test/test_integration_cluster.rb +++ b/test/test_integration_cluster.rb @@ -12,7 +12,25 @@ class TestIntegrationCluster < TestIntegration end def teardown - super if HAS_FORK + return if skipped? + super + end + + def test_pre_existing_unix + skip UNIX_SKT_MSG unless UNIX_SKT_EXIST + + File.open(@bind_path, mode: 'wb') { |f| f.puts 'pre eixisting' } + + cli_server "-w #{WORKERS} -t 0:6 -q test/rackup/sleep_step.ru", unix: :unix + + stop_server + + assert File.exist?(@bind_path) + + ensure + if UNIX_SKT_EXIST + File.unlink @bind_path if File.exist? @bind_path + end end def test_siginfo_thread_print