Skip to content

Commit

Permalink
Updated kusto_spec.rb and ingestor_spec.rb
Browse files Browse the repository at this point in the history
Testing spec files
  • Loading branch information
MonishkaDas committed Sep 26, 2024
1 parent 521c21f commit 531046c
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions spec/outputs/kusto_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,61 +21,63 @@
} }

describe '#register' do
skip 'temporarily disabling all tests' do
it 'allows valid configuration' do
kusto = described_class.new(options)
expect { kusto.register }.not_to raise_error
kusto.close
end
it 'allows valid configuration' do
RSpec.configuration.reporter.message("Running test: allows valid configuration")
kusto = described_class.new(options)
expect { kusto.register }.not_to raise_error
kusto.close
RSpec.configuration.reporter.message("Completed test: allows valid configuration")
end
end

describe '#multi_receive_encoded' do
skip 'temporarily disabling all tests' do
it 'buffers events and flushes based on max_size' do
kusto = described_class.new(options.merge( {'max_size' => 2} ))
kusto.register
it 'buffers events and flushes based on max_size' do
RSpec.configuration.reporter.message("Running test: buffers events and flushes based on max_size")
kusto = described_class.new(options.merge({'max_size' => 2}))
kusto.register

event1 = LogStash::Event.new("message" => "event1")
event2 = LogStash::Event.new("message" => "event2")
event3 = LogStash::Event.new("message" => "event3")
event1 = LogStash::Event.new("message" => "event1")
event2 = LogStash::Event.new("message" => "event2")
event3 = LogStash::Event.new("message" => "event3")

expect(kusto.instance_variable_get(:@buffer)).to receive(:flush).twice.and_call_original
expect(kusto.instance_variable_get(:@buffer)).to receive(:flush).twice.and_call_original

kusto.multi_receive_encoded([[event1, event1.to_json], [event2, event2.to_json]])
kusto.multi_receive_encoded([[event3, event3.to_json]])
kusto.multi_receive_encoded([[event1, event1.to_json], [event2, event2.to_json]])
kusto.multi_receive_encoded([[event3, event3.to_json]])

kusto.close
end
kusto.close
RSpec.configuration.reporter.message("Completed test: buffers events and flushes based on max_size")
end

it 'flushes events based on max_interval' do
kusto = described_class.new(options.merge( {'max_interval' => 1} ))
kusto.register
it 'flushes events based on max_interval' do
RSpec.configuration.reporter.message("Running test: flushes events based on max_interval")
kusto = described_class.new(options.merge({'max_interval' => 1}))
kusto.register

event1 = LogStash::Event.new("message" => "event1")
event1 = LogStash::Event.new("message" => "event1")

expect(kusto.instance_variable_get(:@buffer)).to receive(:flush).at_least(:once).and_call_original
expect(kusto.instance_variable_get(:@buffer)).to receive(:flush).at_least(:once).and_call_original

kusto.multi_receive_encoded([[event1, event1.to_json]])
kusto.multi_receive_encoded([[event1, event1.to_json]])

sleep 2
sleep 2

kusto.close
end
kusto.close
RSpec.configuration.reporter.message("Completed test: flushes events based on max_interval")
end
end

describe '#close' do
skip 'temporarily disabling all tests' do
it 'shuts down the buffer and ingestor' do
kusto = described_class.new(options)
kusto.register
it 'shuts down the buffer and ingestor' do
RSpec.configuration.reporter.message("Running test: shuts down the buffer and ingestor")
kusto = described_class.new(options)
kusto.register

expect(kusto.instance_variable_get(:@buffer)).to receive(:shutdown)
expect(kusto.instance_variable_get(:@ingestor)).to receive(:stop)
expect(kusto.instance_variable_get(:@buffer)).to receive(:shutdown)
expect(kusto.instance_variable_get(:@ingestor)).to receive(:stop)

kusto.close
end
kusto.close
RSpec.configuration.reporter.message("Completed test: shuts down the buffer and ingestor")
end
end
end

0 comments on commit 531046c

Please sign in to comment.