spec/inputs/tcp_spec.rb in logstash-input-tcp-3.0.6 vs spec/inputs/tcp_spec.rb in logstash-input-tcp-4.0.0
- old
+ new
@@ -57,11 +57,11 @@
event_count.times.collect {queue.pop}
end
insist { events.length } == event_count
event_count.times do |i|
- insist { events[i]["message"] } == "#{i} ☹"
+ insist { events[i].get("message") } == "#{i} ☹"
end
end
it "should read events with plain codec and ISO-8859-1 charset" do
port = rand(1024..65535)
@@ -84,13 +84,13 @@
queue.pop
end
# Make sure the 0xA3 latin-1 code converts correctly to UTF-8.
- insist { event["message"].size } == 1
- insist { event["message"].bytesize } == 2
- insist { event["message"] } == "£"
+ insist { event.get("message").size } == 1
+ insist { event.get("message").bytesize } == 2
+ insist { event.get("message") } == "£"
end
it "should read events with json codec" do
port = rand(1024..65535)
conf = <<-CONFIG
@@ -115,17 +115,17 @@
socket.close
queue.pop
end
- insist { event["hello"] } == data["hello"]
- insist { event["foo"].to_a } == data["foo"] # to_a to cast Java ArrayList produced by JrJackson
- insist { event["baz"] } == data["baz"]
+ insist { event.get("hello") } == data["hello"]
+ insist { event.get("foo").to_a } == data["foo"] # to_a to cast Java ArrayList produced by JrJackson
+ insist { event.get("baz") } == data["baz"]
# Make sure the tcp input, w/ json codec, uses the event's 'host' value,
# if present, instead of providing its own
- insist { event["host"] } == data["host"]
+ insist { event.get("host") } == data["host"]
end
it "should read events with json codec (testing 'host' handling)" do
port = rand(1024..65535)
conf = <<-CONFIG
@@ -147,11 +147,11 @@
socket.close
queue.pop
end
- insist { event["hello"] } == data["hello"]
+ insist { event.get("hello") } == data["hello"]
insist { event }.include?("host")
end
it "should read events with json_lines codec" do
port = rand(1024..65535)
@@ -182,14 +182,14 @@
(1..event_count).map{queue.pop}
end
events.each_with_index do |event, idx|
- insist { event["hello"] } == data["hello"]
- insist { event["foo"].to_a } == data["foo"] # to_a to cast Java ArrayList produced by JrJackson
- insist { event["baz"] } == data["baz"]
- insist { event["idx"] } == idx + 1
+ insist { event.get("hello") } == data["hello"]
+ insist { event.get("foo").to_a } == data["foo"] # to_a to cast Java ArrayList produced by JrJackson
+ insist { event.get("baz") } == data["baz"]
+ insist { event.get("idx") } == idx + 1
end # do
end # describe
it "should one message per connection" do
event_count = 10
@@ -209,15 +209,15 @@
socket.flush
socket.close
end
# since each message is sent on its own tcp connection & thread, exact receiving order cannot be garanteed
- event_count.times.collect{queue.pop}.sort_by{|event| event["message"]}
+ event_count.times.collect{queue.pop}.sort_by{|event| event.get("message")}
end
event_count.times do |i|
- insist { events[i]["message"] } == "#{i}"
+ insist { events[i].get("message") } == "#{i}"
end
end
# below are new specs added in the context of the shutdown semantic refactor.
# TODO:
@@ -250,11 +250,11 @@
# TODO(sissel): Implement normal event-receipt tests as as a shared example
end
context "when ssl_enable is true" do
let(:pki) { Flores::PKI.generate }
- let(:certificate) { pki[0] }
- let(:key) { pki[1] }
+ let(:certificate) { pki[0] }
+ let(:key) { pki[1] }
let(:certificate_file) { Stud::Temporary.file }
let(:key_file) { Stud::Temporary.file }
let(:queue) { Queue.new }
let(:config) do