Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filebeat: Add failing tests for @timestamps in JSON with timezone specified #1831

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions filebeat/tests/files/logs/json_timestamp.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{"@timestamp":"2016-04-05T18:47:18.444Z","level":"INFO","logger":"iapi.logger","thread":"JobCourier4","appInfo":{"appname":"SessionManager","appid":"Pooler","host":"demohost.mydomain.com","ip":"192.168.128.113","pid":13982},"userFields":{"ApplicationId":"PROFAPP_001","RequestTrackingId":"RetrieveTBProfileToken-6066477"},"source":"DataAccess\/FetchActiveSessionToken.process","msg":"FetchActiveSessionToken process ended"}
{"@timestamp":"invalid","level":"INFO","logger":"iapi.logger","thread":"JobCourier4","appInfo":{"appname":"SessionManager","appid":"Pooler","host":"demohost.mydomain.com","ip":"192.168.128.113","pid":13982},"userFields":{"ApplicationId":"PROFAPP_001","RequestTrackingId":"RetrieveTBProfileToken-6066477"},"source":"DataAccess\/FetchActiveSessionToken.process","msg":"FetchActiveSessionToken process ended"}
{"@timestamp":{"hello": "test"},"level":"INFO","logger":"iapi.logger","thread":"JobCourier4","appInfo":{"appname":"SessionManager","appid":"Pooler","host":"demohost.mydomain.com","ip":"192.168.128.113","pid":13982},"userFields":{"ApplicationId":"PROFAPP_001","RequestTrackingId":"RetrieveTBProfileToken-6066477"},"source":"DataAccess\/FetchActiveSessionToken.process","msg":"FetchActiveSessionToken process ended"}
{"@timestamp":"2016-04-05T18:47:18.444Z"}
{"@timestamp":"invalid"}
{"@timestamp":{"hello": "test"}}
{"@timestamp":"2016-04-05T18:47:18.444+00:00"}
{"@timestamp":"2016-04-05T18:47:18+00:00"}
9 changes: 7 additions & 2 deletions filebeat/tests/system/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ def test_timestamp_in_message(self):

proc = self.start_beat()
self.wait_until(
lambda: self.output_has(lines=3),
lambda: self.output_has(lines=5),
max_timeout=10)
proc.check_kill_and_wait()

output = self.read_output()
assert len(output) == 3
assert len(output) == 5
assert all(isinstance(o["@timestamp"], basestring) for o in output)
assert all(isinstance(o["type"], basestring) for o in output)
assert output[0]["@timestamp"] == "2016-04-05T18:47:18.444Z"
Expand All @@ -205,6 +205,11 @@ def test_timestamp_in_message(self):
assert output[2]["json_error"] == \
"@timestamp not overwritten (not string)"

assert output[3]["json_error"] is None, output[3]["json_error"]
assert output[3]["@timestamp"] == "2016-04-05T18:47:18.444+00:00", output[3]["@timestamp"]

assert output[4]["json_error"] is None, output[4]["json_error"]
assert output[4]["@timestamp"] == "2016-04-05T18:47:18+00:00", output[4]["@timestamp"]
def test_type_in_message(self):
"""
If overwrite_keys is true and type is in the message, we have to
Expand Down