Просмотр исходного кода

Maintenance: Fix ipv6 detection if 'ip' command is not available.

Martin Gruner 2 лет назад
Родитель
Сommit
2d45e5133e
3 измененных файлов с 0 добавлено и 62 удалено
  1. 0 1
      .rubocop/todo.rspec.yml
  2. 0 48
      spec/scripts/websocket_server_spec.rb
  3. 0 13
      spec/support/script_helper.rb

+ 0 - 1
.rubocop/todo.rspec.yml

@@ -335,7 +335,6 @@ RSpec/ExampleLength:
     - 'spec/requests/user/organization_spec.rb'
     - 'spec/requests/user/permission_spec.rb'
     - 'spec/requests/user_spec.rb'
-    - 'spec/scripts/websocket_server_spec.rb'
     - 'spec/system/**/*'
 
 RSpec/ExpectActual:

+ 0 - 48
spec/scripts/websocket_server_spec.rb

@@ -1,48 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-# rubocop:disable RSpec/DescribeClass
-
-require 'spec_helper'
-require 'support/script_helper'
-require 'timeout'
-
-describe 'websocket-server', type: :script do
-  # Why not Rails.root.join here?
-  # Because it's not avaialable in this spec (no 'rails_helper' = faster start-up)
-  let(:app_root)   { File.expand_path('../..', __dir__) }
-  let(:ws_server)  { File.expand_path('script/websocket-server.rb', app_root) }
-  let(:pidfile)    { File.expand_path('tmp/pids/websocket.pid', app_root) }
-  let(:output_log) { File.expand_path('log/websocket-server_out.log', app_root) }
-  let(:error_log)  { File.expand_path('log/websocket-server_err.log', app_root) }
-
-  context 'with IPv6 bind address (via -b option)', if: has_ipv6? do
-    # This error is raised for invalid bind addresses
-    let(:error_msg) { "`start_tcp_server': no acceptor" }
-    let(:ipv6_addr) { '::1/128' }
-    # Prevent port assignment conflicts during parallel test execution
-    let(:port)      { rand(60_000..65_000) } # rubocop:disable Zammad/ForbidRand
-
-    # Flush logs
-    before do
-      File.write(output_log, '')
-      File.write(error_log, '')
-    end
-
-    it 'starts up successfully' do
-
-      system("RAILS_ENV=test #{ws_server} start -db #{ipv6_addr} -p #{port} >/dev/null 2>&1")
-
-      # Wait for daemon to start
-      Timeout.timeout(20, Timeout::Error, 'WebSocket Server startup timed out') do
-        loop { break if File.size(output_log) + File.size(error_log) > 0 }
-      end
-
-      expect(File.read(error_log)).not_to include(error_msg)
-    ensure
-      system("#{ws_server} stop >/dev/null 2>&1") if File.exist?(pidfile)
-
-    end
-  end
-end
-
-# rubocop:enable RSpec/DescribeClass

+ 0 - 13
spec/support/script_helper.rb

@@ -1,13 +0,0 @@
-# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
-
-module ScriptHelper
-  def has_ipv6?
-    File.exist?('/proc/net/if_inet6') && system('ip -6 addr | grep ::1')
-  end
-end
-
-RSpec.configure do |config|
-  # #extend adds setup methods for example groups (#describe / #context);
-  # #include adds methods within actual examples (#it blocks)
-  config.extend ScriptHelper, type: :script
-end