From d0809c6868399392c9abebe24efeb652ec8ba585 Mon Sep 17 00:00:00 2001 From: Fujimoto Seiji Date: Tue, 19 Jun 2018 11:44:45 +0900 Subject: [PATCH] in_http: Add a test case for the `keep_time_key` flag. This patch adds a test case (test_multi_json_with_keep_time_key) to test_in_http.rb. I've confirmed it passes without problems in my testing machine: test_multi_json_with_keep_time_key: .: (0.606005) Signed-off-by: Fujimoto Seiji --- test/plugin/test_in_http.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/plugin/test_in_http.rb b/test/plugin/test_in_http.rb index 8dfb78ed3e..9e8c6bbde8 100644 --- a/test/plugin/test_in_http.rb +++ b/test/plugin/test_in_http.rb @@ -347,6 +347,34 @@ def test_json_with_add_http_headers assert include_http_header?(d.events[1][2]) end + def test_multi_json_with_keep_time_key + d = create_driver(CONFIG + %[ + + @type json + keep_time_key true + + ]) + time1 = event_time("2011-01-02 13:14:15 UTC") + time2 = event_time("2012-01-02 13:14:15 UTC") + records = [{"time"=>time1.to_i},{"time"=>time2.to_i}] + tag = "tag1" + res_codes = [] + + d.run(expect_records: 2, timeout: 5) do + res = post("/#{tag}", records.to_json, {"Content-Type"=>"application/octet-stream"}) + res_codes << res.code + end + assert_equal ["200"], res_codes + + assert_equal "tag1", d.events[0][0] + assert_equal_event_time time1, d.events[0][1] + assert_equal d.events[0][2], records[0] + + assert_equal "tag1", d.events[1][0] + assert_equal_event_time time2, d.events[1][1] + assert_equal d.events[1][2], records[1] + end + def test_application_json d = create_driver time = event_time("2011-01-02 13:14:15 UTC")