Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aybabtme authored and Antoine Grondin committed Sep 15, 2022
1 parent ac3ea5d commit 85936d7
Show file tree
Hide file tree
Showing 25 changed files with 343 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/cases/0001/input → test/cases/00001-json/input
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,21 @@
{"data":{"short":"http access","message":"incoming HTTP request was served"},"datacontenttype":"application/json","id":"01FCV6SEKCC9RG364AJ60J75KW","invapptracingcallingservice":"unset","invapptracingrequestid":"01FCV6SEKCNSQJJ2NDEPQ2TGMP","invapptracingtequestsource":"unset","invloglevel":"Info","invwebbytes":0,"invwebbytesin":0,"invwebbytesout":0,"invwebcached":false,"invwebdesthost":"","invwebdestip":"::ffff:0.0.0.0","invwebduration":0,"invwebhttpcontenttype":"","invwebhttpmethod":"","invwebhttpuseragent":"","invwebhttpuseragentlength":0,"invwebsrcip":"::ffff:0.0.0.0","invwebstatus":0,"invweburipath":"","invweburiquery":"","invweburl":"","invweburllength":0,"source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:15:00.46025-05:00","type":"incoming_http_request"}
{"data":{"short":"http access","message":"incoming HTTP request was served"},"datacontenttype":"application/json","id":"01FCV6SF3DXGB8G1DVX19KQZYT","invapptracingcallingservice":"unset","invapptracingrequestid":"01FCV6SF3DJZSXTT1RNR6F1QAV","invapptracingtequestsource":"unset","invloglevel":"Info","invwebbytes":0,"invwebbytesin":0,"invwebbytesout":0,"invwebcached":false,"invwebdesthost":"","invwebdestip":"::ffff:0.0.0.0","invwebduration":0,"invwebhttpcontenttype":"","invwebhttpmethod":"","invwebhttpuseragent":"","invwebhttpuseragentlength":0,"invwebsrcip":"::ffff:0.0.0.0","invwebstatus":0,"invweburipath":"","invweburiquery":"","invweburl":"","invweburllength":0,"source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:15:00.973455-05:00","type":"incoming_http_request"}
{"data":{"short":"http access","message":"incoming HTTP request was served"},"datacontenttype":"application/json","id":"01FCV6SKY9MM7D795258XPQGC9","invapptracingcallingservice":"unset","invapptracingrequestid":"01FCV6SKY9M1D725HTV0ZXKF1V","invapptracingtequestsource":"unset","invloglevel":"Info","invwebbytes":0,"invwebbytesin":0,"invwebbytesout":0,"invwebcached":false,"invwebdesthost":"","invwebdestip":"::ffff:0.0.0.0","invwebduration":0,"invwebhttpcontenttype":"","invwebhttpmethod":"","invwebhttpuseragent":"","invwebhttpuseragentlength":0,"invwebsrcip":"::ffff:0.0.0.0","invwebstatus":0,"invweburipath":"","invweburiquery":"","invweburl":"","invweburllength":0,"source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:15:05.929423-05:00","type":"incoming_http_request"}
{"data":{"event":"Shutdown"},"datacontenttype":"application/json","id":"01FCV6SR6JZH7JZ6RFDFN9Q99Y","invloglevel":"Info","source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:15:10.290034-05:00","type":"service-shutdown"}
{"data":{"event":"Shutdown"},"datacontenttype":"application/json","id":"01FCV6SR6JZH7JZ6RFDFN9Q99Y","invloglevel":"Info","source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:15:10.290034-05:00","type":"service-shutdown"}
{"time":"2021-08-11T13:15:10.290034-05:00","message":"hello"}
{"time":"2021-08-11T13:15:10.290034-05:00","msg":"hello"}
{"ts":"2021-08-11T13:15:10.290034-05:00","msg":"hello"}
{"timestamp":"2021-08-11T13:15:10.290034-05:00","msg":"hello"}
{"@timestamp":"2021-08-11T13:15:10.290034-05:00","msg":"hello"}
{"level":"fatal"}
{"lvl":"fatal"}
{"loglevel":"fatal"}
{"severity":"fatal"}
{"level":"fatal"}
{"level":"debug"}
{"level":"info"}
{"level":"warn"}
{"level":"warning"}
{"level":"error"}
{"level":"panic"}
{"level":"some unknown level"}
File renamed without changes.
25 changes: 25 additions & 0 deletions test/cases/00001-json/want
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Aug 11 13:14:50 || <no msg> specversion="1.0" type="simple-log" invloglevel="Info" id="01FCV6S4M6S8H3VKAQD9SWFWFP" datacontenttype="application/json" source="irn:libraries:github.com/InVisionApp/invlogger" data=map[message:The login-api service is running on port 8085. short:service-startup]
Aug 11 13:14:55 || <no msg> invweburl="" invwebbytes=0 invwebstatus=0 invwebbytesin=0 invwebbytesout=0 invwebduration=0 invweburipath="" invwebdesthost="" invweburiquery="" invweburllength=0 invwebcached=false invwebhttpmethod="" invwebhttpuseragent="" invwebhttpcontenttype="" invwebhttpuseragentlength=0 invwebsrcip="::ffff:0.0.0.0" type="incoming_http_request" invwebdestip="::ffff:0.0.0.0" id="01FCV6S9YK70GJ5Q6YT0PYKQDA" invapptracingtequestsource="unset" invapptracingcallingservice="unset" invapptracingrequestid="01FCV6S9YJXD2SYG3HTGWXHX0G" data=map[message:incoming HTTP request was served short:http access]
Aug 11 13:14:59 || <no msg> id="01FCV6SDKRW3XZDA1FAGZ3QVSH" invapptracingrequestid="01FCV6SDKRHB1RR1Q87Q1SKT5P"
Aug 11 13:15:00 || <no msg> id="01FCV6SE597EY6RJ762V59PZQA" invapptracingrequestid="01FCV6SE596ZMASA1D79M16KVV"
Aug 11 13:15:00 || <no msg> id="01FCV6SEKCC9RG364AJ60J75KW" invapptracingrequestid="01FCV6SEKCNSQJJ2NDEPQ2TGMP"
Aug 11 13:15:00 || <no msg> id="01FCV6SF3DXGB8G1DVX19KQZYT" invapptracingrequestid="01FCV6SF3DJZSXTT1RNR6F1QAV"
Aug 11 13:15:05 || <no msg> id="01FCV6SKY9MM7D795258XPQGC9" invapptracingrequestid="01FCV6SKY9M1D725HTV0ZXKF1V"
Aug 11 13:15:10 || <no msg> type="service-shutdown" data=map[event:Shutdown] id="01FCV6SR6JZH7JZ6RFDFN9Q99Y"
Aug 11 13:15:10 || hello
Aug 11 13:15:10 || hello
Aug 11 13:15:10 || hello
Aug 11 13:15:10 || hello
Aug 11 13:15:10 || hello
Jan 1 00:00:00 |FATA| <no msg>
Jan 1 00:00:00 |FATA| <no msg>
Jan 1 00:00:00 |FATA| <no msg>
Jan 1 00:00:00 |FATA| <no msg>
Jan 1 00:00:00 |FATA| <no msg>
Jan 1 00:00:00 |DEBU| <no msg>
Jan 1 00:00:00 |INFO| <no msg>
Jan 1 00:00:00 |WARN| <no msg>
Jan 1 00:00:00 |WARN| <no msg>
Jan 1 00:00:00 |ERRO| <no msg>
Jan 1 00:00:00 |PANI| <no msg>
Jan 1 00:00:00 |SOME| <no msg>
22 changes: 22 additions & 0 deletions test/cases/00002-logfmt/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
msg="i like turtle" key=value1
key=value1 msg="i like turtle" key2=42
key=value2 msg="i like turtle" key2=43
time="2022/09/11 16:31:21" do_all_electric_sheeps="dream"
time="2022/09/11 16:31:21.198136" do_all_electric_sheeps="dream"
time="2021-08-11T13:15:10.290034-05:00" message="hello"
time="2021-08-11T13:15:10.290034-05:00" msg="hello"
ts="2021-08-11T13:15:10.290034-05:00" msg="hello"
timestamp="2021-08-11T13:15:10.290034-05:00" msg="hello"
@timestamp="2021-08-11T13:15:10.290034-05:00" msg="hello"
level="fatal"
lvl="fatal"
loglevel="fatal"
severity="fatal"
level="fatal"
level="debug"
level="info"
level="warn"
level="warning"
level="error"
level="panic"
level="some unknown level"
File renamed without changes.
22 changes: 22 additions & 0 deletions test/cases/00002-logfmt/want
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Jan 1 00:00:00 || i like turtle key=value1
Jan 1 00:00:00 || i like turtle key2=42
Jan 1 00:00:00 || i like turtle key2=43 key=value2
Sep 11 16:31:21 || <no msg> do_all_electric_sheeps=dream
Sep 11 16:31:21 || <no msg>
Aug 11 13:15:10 || hello
Aug 11 13:15:10 || hello
Aug 11 13:15:10 || hello
Aug 11 13:15:10 || hello
Aug 11 13:15:10 || hello
Jan 1 00:00:00 |FATA| <no msg>
Jan 1 00:00:00 |FATA| <no msg>
Jan 1 00:00:00 |FATA| <no msg>
Jan 1 00:00:00 |FATA| <no msg>
Jan 1 00:00:00 |FATA| <no msg>
Jan 1 00:00:00 |DEBU| <no msg>
Jan 1 00:00:00 |INFO| <no msg>
Jan 1 00:00:00 |WARN| <no msg>
Jan 1 00:00:00 |WARN| <no msg>
Jan 1 00:00:00 |ERRO| <no msg>
Jan 1 00:00:00 |PANI| <no msg>
Jan 1 00:00:00 |SOME| <no msg>
File renamed without changes.
29 changes: 29 additions & 0 deletions test/cases/00003-zap/opts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"skip": null,
"keep": null,
"time_fields": [
"time",
"ts",
"@timestamp",
"timestamp"
],
"message_fields": [
"message",
"msg"
],
"level_fields": [
"level",
"lvl",
"loglevel",
"severity"
],
"sort_longest": true,
"skip_unchanged": true,
"truncates": false,
"light_bg": false,
"color_mode": 2,
"truncate_length": 15,
"time_format": "Jan _2 15:04:05",
"palette": null
}

File renamed without changes.
10 changes: 10 additions & 0 deletions test/cases/10000-behavior-base/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
2021-02-05T12:41:48.053-0700 DEBUG zapper/zapper.go:18 some message 1 {"rand_index": 1}
2021-02-05T12:41:49.059-0700 ERROR zapper/zapper.go:18 some message 2 {"rand_index": 3}
2021-02-05T15:45:04.425-0700 FATAL zapper/zapper.go:18 some message 5 {"rand_index": 11}
2021-02-05T12:41:50.064-0700 INFO zapper/zapper.go:18 some message 3 {"rand_index": 5}
2021-02-05T12:41:51.069-0700 WARN zapper/zapper.go:18 some message 4 {"rand_index": 7}
2021-02-06T22:55:22.004Z DEBUG zapper/zapper.go:17 some message 1 {"rand_index": 1}
2021-02-06T22:55:22.008Z ERROR zapper/zapper.go:17 some message 2 {"rand_index": 2}
2021-02-06T22:55:22.009Z FATAL zapper/zapper.go:17 some message 5 {"rand_index": 1}
2021-02-06T22:55:22.009Z INFO zapper/zapper.go:17 some message 3 {"rand_index": 2}
2021-02-06T22:55:22.009Z WARN zapper/zapper.go:17 some message 4 {"rand_index": 4}
29 changes: 29 additions & 0 deletions test/cases/10000-behavior-base/opts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"skip": null,
"keep": null,
"time_fields": [
"time",
"ts",
"@timestamp",
"timestamp"
],
"message_fields": [
"message",
"msg"
],
"level_fields": [
"level",
"lvl",
"loglevel",
"severity"
],
"sort_longest": true,
"skip_unchanged": true,
"truncates": false,
"light_bg": false,
"color_mode": 2,
"truncate_length": 15,
"time_format": "Jan _2 15:04:05",
"palette": null
}

10 changes: 10 additions & 0 deletions test/cases/10000-behavior-base/want
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feb 5 12:41:48 |DEBU| some message 1 rand_index=1 caller=zapper/zapper.go:18
Feb 5 12:41:49 |ERRO| some message 2 rand_index=3 caller=zapper/zapper.go:18
Feb 5 15:45:04 |FATA| some message 5 rand_index=11 caller=zapper/zapper.go:18
Feb 5 12:41:50 |INFO| some message 3 rand_index=5 caller=zapper/zapper.go:18
Feb 5 12:41:51 |WARN| some message 4 rand_index=7 caller=zapper/zapper.go:18
2021-02-06T22:55:22.004Z DEBUG zapper/zapper.go:17 some message 1 {"rand_index": 1}
2021-02-06T22:55:22.008Z ERROR zapper/zapper.go:17 some message 2 {"rand_index": 2}
2021-02-06T22:55:22.009Z FATAL zapper/zapper.go:17 some message 5 {"rand_index": 1}
2021-02-06T22:55:22.009Z INFO zapper/zapper.go:17 some message 3 {"rand_index": 2}
2021-02-06T22:55:22.009Z WARN zapper/zapper.go:17 some message 4 {"rand_index": 4}
4 changes: 4 additions & 0 deletions test/cases/10001-behavior-truncates/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"k2":"lonnnnnnnng","k1":"short"}
{"repeated":"first time"}
{"repeated":"first time"}
{"repeated":"second time"}
29 changes: 29 additions & 0 deletions test/cases/10001-behavior-truncates/opts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"skip": null,
"keep": null,
"time_fields": [
"time",
"ts",
"@timestamp",
"timestamp"
],
"message_fields": [
"message",
"msg"
],
"level_fields": [
"level",
"lvl",
"loglevel",
"severity"
],
"sort_longest": true,
"skip_unchanged": true,
"truncates": true,
"light_bg": false,
"color_mode": 2,
"truncate_length": 15,
"time_format": "Jan _2 15:04:05",
"palette": null
}

4 changes: 4 additions & 0 deletions test/cases/10001-behavior-truncates/want
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Jan 1 00:00:00 || <no msg> k1="short" k2="lonnnnnnnng"
Jan 1 00:00:00 || <no msg> repeated="first time"
Jan 1 00:00:00 || <no msg>
Jan 1 00:00:00 || <no msg> repeated="second time"
8 changes: 8 additions & 0 deletions test/cases/20001-strip-doker-compose/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
web_1 | {"data":{"short":"service-startup","message":"The login-api service is running on port 8085."},"datacontenttype":"application/json","id":"01FCV6S4M6S8H3VKAQD9SWFWFP","invloglevel":"Info","source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:14:50.246861-05:00","type":"simple-log"}
web_1 | {"data":{"short":"http access","message":"incoming HTTP request was served"},"datacontenttype":"application/json","id":"01FCV6S9YK70GJ5Q6YT0PYKQDA","invapptracingcallingservice":"unset","invapptracingrequestid":"01FCV6S9YJXD2SYG3HTGWXHX0G","invapptracingtequestsource":"unset","invloglevel":"Info","invwebbytes":0,"invwebbytesin":0,"invwebbytesout":0,"invwebcached":false,"invwebdesthost":"","invwebdestip":"::ffff:0.0.0.0","invwebduration":0,"invwebhttpcontenttype":"","invwebhttpmethod":"","invwebhttpuseragent":"","invwebhttpuseragentlength":0,"invwebsrcip":"::ffff:0.0.0.0","invwebstatus":0,"invweburipath":"","invweburiquery":"","invweburl":"","invweburllength":0,"source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:14:55.699075-05:00","type":"incoming_http_request"}
web_1 | {"data":{"short":"http access","message":"incoming HTTP request was served"},"datacontenttype":"application/json","id":"01FCV6SDKRW3XZDA1FAGZ3QVSH","invapptracingcallingservice":"unset","invapptracingrequestid":"01FCV6SDKRHB1RR1Q87Q1SKT5P","invapptracingtequestsource":"unset","invloglevel":"Info","invwebbytes":0,"invwebbytesin":0,"invwebbytesout":0,"invwebcached":false,"invwebdesthost":"","invwebdestip":"::ffff:0.0.0.0","invwebduration":0,"invwebhttpcontenttype":"","invwebhttpmethod":"","invwebhttpuseragent":"","invwebhttpuseragentlength":0,"invwebsrcip":"::ffff:0.0.0.0","invwebstatus":0,"invweburipath":"","invweburiquery":"","invweburl":"","invweburllength":0,"source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:14:59.448566-05:00","type":"incoming_http_request"}
web_1 | {"data":{"short":"http access","message":"incoming HTTP request was served"},"datacontenttype":"application/json","id":"01FCV6SE597EY6RJ762V59PZQA","invapptracingcallingservice":"unset","invapptracingrequestid":"01FCV6SE596ZMASA1D79M16KVV","invapptracingtequestsource":"unset","invloglevel":"Info","invwebbytes":0,"invwebbytesin":0,"invwebbytesout":0,"invwebcached":false,"invwebdesthost":"","invwebdestip":"::ffff:0.0.0.0","invwebduration":0,"invwebhttpcontenttype":"","invwebhttpmethod":"","invwebhttpuseragent":"","invwebhttpuseragentlength":0,"invwebsrcip":"::ffff:0.0.0.0","invwebstatus":0,"invweburipath":"","invweburiquery":"","invweburl":"","invweburllength":0,"source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:15:00.009615-05:00","type":"incoming_http_request"}
web_1 | {"data":{"short":"http access","message":"incoming HTTP request was served"},"datacontenttype":"application/json","id":"01FCV6SEKCC9RG364AJ60J75KW","invapptracingcallingservice":"unset","invapptracingrequestid":"01FCV6SEKCNSQJJ2NDEPQ2TGMP","invapptracingtequestsource":"unset","invloglevel":"Info","invwebbytes":0,"invwebbytesin":0,"invwebbytesout":0,"invwebcached":false,"invwebdesthost":"","invwebdestip":"::ffff:0.0.0.0","invwebduration":0,"invwebhttpcontenttype":"","invwebhttpmethod":"","invwebhttpuseragent":"","invwebhttpuseragentlength":0,"invwebsrcip":"::ffff:0.0.0.0","invwebstatus":0,"invweburipath":"","invweburiquery":"","invweburl":"","invweburllength":0,"source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:15:00.46025-05:00","type":"incoming_http_request"}
web_1 | {"data":{"short":"http access","message":"incoming HTTP request was served"},"datacontenttype":"application/json","id":"01FCV6SF3DXGB8G1DVX19KQZYT","invapptracingcallingservice":"unset","invapptracingrequestid":"01FCV6SF3DJZSXTT1RNR6F1QAV","invapptracingtequestsource":"unset","invloglevel":"Info","invwebbytes":0,"invwebbytesin":0,"invwebbytesout":0,"invwebcached":false,"invwebdesthost":"","invwebdestip":"::ffff:0.0.0.0","invwebduration":0,"invwebhttpcontenttype":"","invwebhttpmethod":"","invwebhttpuseragent":"","invwebhttpuseragentlength":0,"invwebsrcip":"::ffff:0.0.0.0","invwebstatus":0,"invweburipath":"","invweburiquery":"","invweburl":"","invweburllength":0,"source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:15:00.973455-05:00","type":"incoming_http_request"}
web_1 | {"data":{"short":"http access","message":"incoming HTTP request was served"},"datacontenttype":"application/json","id":"01FCV6SKY9MM7D795258XPQGC9","invapptracingcallingservice":"unset","invapptracingrequestid":"01FCV6SKY9M1D725HTV0ZXKF1V","invapptracingtequestsource":"unset","invloglevel":"Info","invwebbytes":0,"invwebbytesin":0,"invwebbytesout":0,"invwebcached":false,"invwebdesthost":"","invwebdestip":"::ffff:0.0.0.0","invwebduration":0,"invwebhttpcontenttype":"","invwebhttpmethod":"","invwebhttpuseragent":"","invwebhttpuseragentlength":0,"invwebsrcip":"::ffff:0.0.0.0","invwebstatus":0,"invweburipath":"","invweburiquery":"","invweburl":"","invweburllength":0,"source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:15:05.929423-05:00","type":"incoming_http_request"}
web_1 | {"data":{"event":"Shutdown"},"datacontenttype":"application/json","id":"01FCV6SR6JZH7JZ6RFDFN9Q99Y","invloglevel":"Info","source":"irn:libraries:github.com/InVisionApp/invlogger","specversion":"1.0","time":"2021-08-11T13:15:10.290034-05:00","type":"service-shutdown"}
29 changes: 29 additions & 0 deletions test/cases/20001-strip-doker-compose/opts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"skip": null,
"keep": null,
"time_fields": [
"time",
"ts",
"@timestamp",
"timestamp"
],
"message_fields": [
"message",
"msg"
],
"level_fields": [
"level",
"lvl",
"loglevel",
"severity"
],
"sort_longest": true,
"skip_unchanged": true,
"truncates": false,
"light_bg": false,
"color_mode": 2,
"truncate_length": 15,
"time_format": "Jan _2 15:04:05",
"palette": null
}

Loading

0 comments on commit 85936d7

Please sign in to comment.