|
| 1 | +-- This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +-- License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | +-- file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 | + |
| 5 | +require "string" |
| 6 | +local test = require "test_verify_message" |
| 7 | + |
| 8 | +local messages = { |
| 9 | + {Logger = "input.test_decoder", Type = "error", Hostname = "integration_test", |
| 10 | + Payload = "inject_message() failed: field name must be a string", |
| 11 | + Fields = { |
| 12 | + data = '{"Logger":"input1", "Fields":[{}]}' |
| 13 | + } |
| 14 | + }, |
| 15 | + {Logger = "input.test_decoder|input1", Type = "default", Hostname = "integration_test"}, |
| 16 | + {Logger = "input.test_decoder|input2", Type = "default|type2", Hostname = "integration_test"}, |
| 17 | + {Logger = "input.test_decoder|input2", Type = "default|type2", Hostname = "integration_test", |
| 18 | + Fields = { |
| 19 | + user_agent_browser = "Firefox", |
| 20 | + agent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0", |
| 21 | + user_agent_os = "Linux", |
| 22 | + user_agent_version = 27 |
| 23 | + } |
| 24 | + }, |
| 25 | + {Logger = "input.test_decoder|input2", Type = "default|type2", Hostname = "integration_test", |
| 26 | + Fields = { |
| 27 | + foo = "bar", |
| 28 | + } |
| 29 | + }, |
| 30 | + {Logger = "input.test_decoder", Type = "default", Hostname = "integration_test", |
| 31 | + Fields = { |
| 32 | + ["deep.level1.level2.level3"] = '{"level4":"value"}', |
| 33 | + Timestamp = 123456789, |
| 34 | + foo = "bar", |
| 35 | + ["nested.level1"] = "l1" |
| 36 | + } |
| 37 | + }, |
| 38 | +} |
| 39 | + |
| 40 | +local cnt = 0 |
| 41 | +function process_message() |
| 42 | + cnt = cnt + 1 |
| 43 | + local received = decode_message(read_message("raw")) |
| 44 | + test.fields_array_to_hash(received) |
| 45 | + test.verify_msg(messages[cnt], received, cnt) |
| 46 | + return 0 |
| 47 | +end |
| 48 | + |
| 49 | +function timer_event(ns) |
| 50 | + assert(cnt == #messages, string.format("%d of %d tests ran", cnt, #messages)) |
| 51 | +end |
0 commit comments