Sha256: 5426a227087b5e5b886ccbf7b5bc710ed59887d1634d8e5c9c3d364ad8f8d123
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
# encoding: utf-8 require "flores/random" shared_examples "send events" do it "successfully send the events" do wait(20).for { queue.size }.to eq(number_of_events), "Expected: #{number_of_events} got: #{queue.size}, execution output:\n #{@execution_output}" expect(queue.collect { |e| e["message"] }).to eq(events) end end shared_examples "doesn't send events" do it "doesn't send any events" do expect(queue.size).to eq(0), "Expected: #{number_of_events} got: #{queue.size}, execution output:\n #{@execution_output}" end end shared_context "beats configuration" do # common let(:port) { Flores::Random.port } let(:host) { "localhost" } let(:queue) { [] } let_tmp_file(:log_file) { events.join("\n") + "\n" } # make sure we end of line let(:number_of_events) { 5 } let(:event) { "Hello world" } let(:events) do events = [] number_of_events.times { |n| events << "#{event} #{n}" } events end let(:input_config) do { "host" => host, "port" => port } end let(:beats) do LogStash::Inputs::Beats.new(input_config) end before :each do beats.register @abort_on_exception = Thread.abort_on_exception Thread.abort_on_exception = true @server = Thread.new do begin # use to know what lumberjack is actually doing if ENV["DEBUG"] logger = Logger.new(STDOUT) beats.logger = Cabin::Channel.new beats.logger.subscribe(logger) beats.logger.level = :debug end beats.run(queue) rescue => e retry unless beats.stop? end end @server.abort_on_exception = true sleep(1) while @server.status != "run" end after(:each) do beats.stop Thread.abort_on_exception = @abort_on_exception end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
logstash-input-beats-2.2.9 | spec/support/integration_shared_context.rb |
logstash-input-beats-2.2.8 | spec/support/integration_shared_context.rb |