Sha256: 75888fa64157cb476ab3e5131aa5fc4397d733c890b861d35d743d5124973653

Contents?: true

Size: 1.24 KB

Versions: 8

Compression:

Stored size: 1.24 KB

Contents

# encoding: utf-8
require "lumberjack/beats/client"
require "lumberjack/beats/server"
require "flores/random"
require "flores/pki"
require "spec_helper"
require_relative "../../support/flores_extensions"

Thread.abort_on_exception = true

describe "Server" do
  let(:certificate) { Flores::PKI.generate }
  let(:certificate_file_crt) { "certificate.crt" }
  let(:certificate_file_key) { "certificate.key" }
  let(:port) { Flores::Random.port }
  let(:tcp_port) { Flores::Random.port }
  let(:host) { "127.0.0.1" }
  let(:queue) { [] }

  before do
    expect(File).to receive(:read).at_least(1).with(certificate_file_crt) { certificate.first.to_s }
    expect(File).to receive(:read).at_least(1).with(certificate_file_key) { certificate.last.to_s }
  end

  it "should not block when closing the server" do
    server = Lumberjack::Beats::Server.new(:port => port,
                                  :address => host,
                                  :ssl_certificate => certificate_file_crt,
                                  :ssl_key => certificate_file_key)
    thread = Thread.new do
      server.run do |event|
        queue << event
      end
    end

    sleep(0.1) while thread.status != "run"
    server.close

    wait_for { thread.status }.to be_falsey
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
logstash-input-beats-3.0.4 spec/lumberjack/beats/server_spec.rb
logstash-input-beats-2.2.9 spec/lumberjack/beats/server_spec.rb
logstash-input-beats-3.0.3 spec/lumberjack/beats/server_spec.rb
logstash-input-beats-3.0.2 spec/lumberjack/beats/server_spec.rb
logstash-input-beats-3.0.1 spec/lumberjack/beats/server_spec.rb
logstash-input-beats-3.0.0 spec/lumberjack/beats/server_spec.rb
logstash-input-beats-2.2.8 spec/lumberjack/beats/server_spec.rb
logstash-input-beats-2.2.7 spec/lumberjack/beats/server_spec.rb