Skip to content

Commit 70f77b9

Browse files
authored
[Tests] Update unit tests to account for ECS (#94)
* [Tests] Update unit tests to account for ECS and fix .ci integration This fixes tests to account for the different data shape presented when ECS is on by default in Logstash 8.x This also fixes .ci integration - .ci is no longer introduced via submodules - the submodule is out of date and breaking the build.
1 parent fd1f296 commit 70f77b9

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

.ci

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## unreleased
2+
- Fixed unit tests to account for ECS by default [#94](https://github.com/logstash-plugins/logstash-output-file/pull/94)
3+
- Fixed .ci integration [#94](https://github.com/logstash-plugins/logstash-output-file/pull/94)
4+
15
## 4.3.0
26
- Made `stale_cleanup_interval` configurable [#84](https://github.com/logstash-plugins/logstash-output-file/pull/84)
37
- CI: upgrade testing [#83](https://github.com/logstash-plugins/logstash-output-file/pull/83)

spec/outputs/file_spec.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
require "fileutils"
1313
require "flores/random"
1414

15+
def get_sequence_number(event)
16+
event.get('sequence') || event.get('event')['sequence']
17+
end
18+
1519
describe LogStash::Outputs::File do
1620
describe "ship lots of events to a file" do
1721
tmp_file = Tempfile.new('logstash-spec-output-file')
@@ -37,10 +41,10 @@
3741

3842
# Now check all events for order and correctness.
3943
events = tmp_file.map {|line| LogStash::Event.new(LogStash::Json.load(line))}
40-
sorted = events.sort_by {|e| e.get('sequence')}
44+
sorted = events.sort_by {|e| get_sequence_number(e)}
4145
sorted.each do |event|
4246
insist {event.get("message")} == "hello world"
43-
insist {event.get("sequence")} == line_num
47+
insist {get_sequence_number(event)} == line_num
4448
line_num += 1
4549
end
4650

@@ -72,10 +76,10 @@
7276
line_num = 0
7377
# Now check all events for order and correctness.
7478
events = Zlib::GzipReader.open(tmp_file.path).map {|line| LogStash::Event.new(LogStash::Json.load(line)) }
75-
sorted = events.sort_by {|e| e.get("sequence")}
79+
sorted = events.sort_by {|e| get_sequence_number(e)}
7680
sorted.each do |event|
7781
insist {event.get("message")} == "hello world"
78-
insist {event.get("sequence")} == line_num
82+
insist {get_sequence_number(event)} == line_num
7983
line_num += 1
8084
end
8185
insist {line_num} == event_count

0 commit comments

Comments
 (0)