Skip to content

Commit ea8e6d6

Browse files
authored
Update golden files for icinga/startup test to exclude timestamp (#9506)
The icing/startup log file does not contain a timestamp. Because of this the timestamp from filebeat is taken. During the generation of golden files still a timestamp was added but every skipped on comparison. Instead now the timestamp is not added to the generated file anymore to now show a diff each time GENERATE is run.
1 parent 1793955 commit ea8e6d6

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

filebeat/module/icinga/startup/test/test.log-expected.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[
22
{
3-
"@timestamp": "2018-11-06T18:29:13.579Z",
43
"event.dataset": "startup",
54
"event.module": "icinga",
65
"icinga.startup.facility": "cli",
@@ -10,7 +9,6 @@
109
"log.offset": 0
1110
},
1211
{
13-
"@timestamp": "2018-11-06T18:29:13.579Z",
1412
"event.dataset": "startup",
1513
"event.module": "icinga",
1614
"icinga.startup.facility": "cli",

filebeat/tests/system/test_modules.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def _test_expected_events(self, test_file, objects):
159159
for k, obj in enumerate(objects):
160160
objects[k] = self.flatten_object(obj, {}, "")
161161
clean_keys(objects[k])
162+
162163
json.dump(objects, f, indent=4, sort_keys=True)
163164

164165
with open(test_file + "-expected.json", "r") as f:
@@ -175,11 +176,6 @@ def _test_expected_events(self, test_file, objects):
175176
obj = self.flatten_object(obj, {}, "")
176177
clean_keys(obj)
177178

178-
# Remove timestamp for comparison where timestamp is not part of the log line
179-
if obj["event.module"] == "icinga" and obj["event.dataset"] == "startup":
180-
delete_key(obj, "@timestamp")
181-
delete_key(ev, "@timestamp")
182-
183179
if ev == obj:
184180
found = True
185181
break
@@ -199,6 +195,10 @@ def clean_keys(obj):
199195
for key in host_keys + time_keys + other_keys:
200196
delete_key(obj, key)
201197

198+
# Remove timestamp for comparison where timestamp is not part of the log line
199+
if obj["event.module"] == "icinga" and obj["event.dataset"] == "startup":
200+
delete_key(obj, "@timestamp")
201+
202202

203203
def delete_key(obj, key):
204204
if key in obj:

0 commit comments

Comments
 (0)