spec/integration_spec.rb in logstash-input-beats-0.9.6 vs spec/integration_spec.rb in logstash-input-beats-2.0.0
- old
+ new
@@ -31,40 +31,41 @@
@tcp_server = Thread.new do
while true
tcp_server.accept do |socket|
con = Lumberjack::Beats::Connection.new(socket, tcp_server)
begin
- con.run { |data| queue << data }
+ con.run { |data, identity_stream| queue << [data, identity_stream] }
rescue
# Close connection on failure. For example SSL client will make
# parser for TCP based server trip.
# Connection is closed by Server connection object
end
end
end
end
@ssl_server = Thread.new do
- ssl_server.run { |data| queue << data }
+ ssl_server.run { |data, identity_stream| queue << [data, identity_stream] }
end
end
shared_examples "send payload" do
it "supports single element" do
(1..random_number_of_events).each do |n|
expect(client.write(payload)).to eq(sequence_start + n)
end
sleep(0.5) # give time to the server to read the events
expect(queue.size).to eq(random_number_of_events)
+ expect(queue.collect(&:last).uniq.size).to eq(1)
end
it "support sending multiple elements in one payload" do
expect(client.write(batch_payload)).to eq(sequence_start + batch_size)
sleep(0.5)
expect(queue.size).to eq(batch_size)
- expect(queue).to match_array(batch_payload)
+ expect(queue.collect(&:last).uniq.size).to eq(1)
end
end
shared_examples "transmit payloads" do
let(:random_number_of_events) { Flores::Random.integer(2..10) }
@@ -104,11 +105,11 @@
it "adjusts the ack" do
expect(client.write(batch_payload)).to eq(batch_size / 2)
sleep(0.5)
expect(queue.size).to eq(batch_size)
- expect(queue).to match_array(batch_payload)
+ expect(queue.collect(&:first)).to match_array(batch_payload)
end
end
end
context "using plain tcp connection" do
@@ -150,19 +151,19 @@
end
context "using ssl encrypted connection" do
context "with a valid certificate" do
it "successfully connect to the server" do
- expect {
+ expect {
Lumberjack::Beats::Client.new(:port => port,
:host => host,
:addresses => host,
:ssl_certificate => certificate_file_crt)
}.not_to raise_error
end
it "should fail connecting to plain tcp server" do
- expect {
+ expect {
Lumberjack::Beats::Client.new(:port => tcp_port,
:host => host,
:addresses => host,
:ssl_certificate => certificate_file_crt)
}.to raise_error(OpenSSL::SSL::SSLError)