|
40 | 40 |
|
41 | 41 | end
|
42 | 42 |
|
43 |
| - describe "timeout", :performance => true do |
44 |
| - |
45 |
| - ACCEPTED_TIMEOUT_DEGRADATION = 100 # in % (compared to timeout-less run) |
46 |
| - # TODO: with more real-world (pipeline) setup this usually gets bellow 10% on average |
47 |
| - |
48 |
| - MATCH_PATTERNS = { |
49 |
| - "message" => [ |
50 |
| - "foo0: %{NUMBER:bar}", "foo1: %{NUMBER:bar}", "foo2: %{NUMBER:bar}", "foo3: %{NUMBER:bar}", "foo4: %{NUMBER:bar}", |
51 |
| - "foo5: %{NUMBER:bar}", "foo6: %{NUMBER:bar}", "foo7: %{NUMBER:bar}", "foo8: %{NUMBER:bar}", "foo9: %{NUMBER:bar}", |
52 |
| - "%{SYSLOGLINE}" |
53 |
| - ] |
54 |
| - } |
55 |
| - |
56 |
| - SAMPLE_MESSAGE = "Mar 16 00:01:25 evita postfix/smtpd[1713]: connect from aaaaaaaa.aaaaaa.net[111.111.11.1]".freeze |
57 |
| - |
58 |
| - TIMEOUT_MILLIS = 5_000 |
59 |
| - |
60 |
| - let(:config_wout_timeout) do |
61 |
| - { |
62 |
| - 'match' => MATCH_PATTERNS, |
63 |
| - 'timeout_scope' => "event", |
64 |
| - 'timeout_millis' => 0 # 0 - disabled timeout |
65 |
| - } |
66 |
| - end |
67 |
| - |
68 |
| - let(:config_with_timeout) do |
69 |
| - { |
70 |
| - 'match' => MATCH_PATTERNS, |
71 |
| - 'timeout_scope' => "event", |
72 |
| - 'timeout_millis' => TIMEOUT_MILLIS |
73 |
| - } |
74 |
| - end |
75 |
| - |
76 |
| - SAMPLE_COUNT = 2 |
77 |
| - |
78 |
| - it "has less than #{ACCEPTED_TIMEOUT_DEGRADATION}% overhead" do |
79 |
| - filter_wout_timeout = LogStash::Filters::Grok.new(config_wout_timeout).tap(&:register) |
80 |
| - wout_timeout_duration = do_sample_filter(filter_wout_timeout) # warmup |
81 |
| - puts "filters/grok(timeout => 0) warmed up in #{wout_timeout_duration}" |
82 |
| - before_sample! |
83 |
| - no_timeout_durations = Array.new(SAMPLE_COUNT).map do |
84 |
| - do_sample_filter(filter_wout_timeout) |
85 |
| - end |
86 |
| - puts "filters/grok(timeout => 0) took #{no_timeout_durations}" |
87 |
| - |
88 |
| - expected_duration = avg(no_timeout_durations) |
89 |
| - expected_duration += (expected_duration / 100) * ACCEPTED_TIMEOUT_DEGRADATION |
90 |
| - puts "expected_duration #{expected_duration}" |
91 |
| - |
92 |
| - filter_with_timeout = LogStash::Filters::Grok.new(config_with_timeout).tap(&:register) |
93 |
| - with_timeout_duration = do_sample_filter(filter_with_timeout) # warmup |
94 |
| - puts "filters/grok(timeout_scope => event) warmed up in #{with_timeout_duration}" |
95 |
| - |
96 |
| - try(3) do |
97 |
| - before_sample! |
98 |
| - durations = [] |
99 |
| - begin |
100 |
| - expect do |
101 |
| - do_sample_filter(filter_with_timeout).tap { |duration| durations << duration } |
102 |
| - end.to perform_under(expected_duration).sample(SAMPLE_COUNT).times |
103 |
| - ensure |
104 |
| - puts "filters/grok(timeout_scope => event) took #{durations}" |
105 |
| - end |
106 |
| - end |
107 |
| - end |
108 |
| - |
109 |
| - @private |
110 |
| - |
111 |
| - def do_sample_filter(filter) |
112 |
| - sample_event = { "message" => SAMPLE_MESSAGE } |
113 |
| - measure do |
114 |
| - for _ in (1..EVENT_COUNT) do # EVENT_COUNT.times without the block cost |
115 |
| - filter.filter(LogStash::Event.new(sample_event)) |
116 |
| - end |
117 |
| - end |
118 |
| - end |
119 |
| - |
120 |
| - end |
| 43 | + # describe "timeout", :performance => true do |
| 44 | + # |
| 45 | + # ACCEPTED_TIMEOUT_DEGRADATION = 100 # in % (compared to timeout-less run) |
| 46 | + # # TODO: with more real-world (pipeline) setup this usually gets bellow 10% on average |
| 47 | + # |
| 48 | + # MATCH_PATTERNS = { |
| 49 | + # "message" => [ |
| 50 | + # "foo0: %{NUMBER:bar}", "foo1: %{NUMBER:bar}", "foo2: %{NUMBER:bar}", "foo3: %{NUMBER:bar}", "foo4: %{NUMBER:bar}", |
| 51 | + # "foo5: %{NUMBER:bar}", "foo6: %{NUMBER:bar}", "foo7: %{NUMBER:bar}", "foo8: %{NUMBER:bar}", "foo9: %{NUMBER:bar}", |
| 52 | + # "%{SYSLOGLINE}" |
| 53 | + # ] |
| 54 | + # } |
| 55 | + # |
| 56 | + # SAMPLE_MESSAGE = "Mar 16 00:01:25 evita postfix/smtpd[1713]: connect from aaaaaaaa.aaaaaa.net[111.111.11.1]".freeze |
| 57 | + # |
| 58 | + # TIMEOUT_MILLIS = 5_000 |
| 59 | + # |
| 60 | + # let(:config_wout_timeout) do |
| 61 | + # { |
| 62 | + # 'match' => MATCH_PATTERNS, |
| 63 | + # 'timeout_scope' => "event", |
| 64 | + # 'timeout_millis' => 0 # 0 - disabled timeout |
| 65 | + # } |
| 66 | + # end |
| 67 | + # |
| 68 | + # let(:config_with_timeout) do |
| 69 | + # { |
| 70 | + # 'match' => MATCH_PATTERNS, |
| 71 | + # 'timeout_scope' => "event", |
| 72 | + # 'timeout_millis' => TIMEOUT_MILLIS |
| 73 | + # } |
| 74 | + # end |
| 75 | + # |
| 76 | + # SAMPLE_COUNT = 2 |
| 77 | + # |
| 78 | + # it "has less than #{ACCEPTED_TIMEOUT_DEGRADATION}% overhead" do |
| 79 | + # filter_wout_timeout = LogStash::Filters::Grok.new(config_wout_timeout).tap(&:register) |
| 80 | + # wout_timeout_duration = do_sample_filter(filter_wout_timeout) # warmup |
| 81 | + # puts "filters/grok(timeout => 0) warmed up in #{wout_timeout_duration}" |
| 82 | + # before_sample! |
| 83 | + # no_timeout_durations = Array.new(SAMPLE_COUNT).map do |
| 84 | + # do_sample_filter(filter_wout_timeout) |
| 85 | + # end |
| 86 | + # puts "filters/grok(timeout => 0) took #{no_timeout_durations}" |
| 87 | + # |
| 88 | + # expected_duration = avg(no_timeout_durations) |
| 89 | + # expected_duration += (expected_duration / 100) * ACCEPTED_TIMEOUT_DEGRADATION |
| 90 | + # puts "expected_duration #{expected_duration}" |
| 91 | + # |
| 92 | + # filter_with_timeout = LogStash::Filters::Grok.new(config_with_timeout).tap(&:register) |
| 93 | + # with_timeout_duration = do_sample_filter(filter_with_timeout) # warmup |
| 94 | + # puts "filters/grok(timeout_scope => event) warmed up in #{with_timeout_duration}" |
| 95 | + # |
| 96 | + # try(3) do |
| 97 | + # before_sample! |
| 98 | + # durations = [] |
| 99 | + # begin |
| 100 | + # expect do |
| 101 | + # do_sample_filter(filter_with_timeout).tap { |duration| durations << duration } |
| 102 | + # end.to perform_under(expected_duration).sample(SAMPLE_COUNT).times |
| 103 | + # ensure |
| 104 | + # puts "filters/grok(timeout_scope => event) took #{durations}" |
| 105 | + # end |
| 106 | + # end |
| 107 | + # end |
| 108 | + # |
| 109 | + # @private |
| 110 | + # |
| 111 | + # def do_sample_filter(filter) |
| 112 | + # sample_event = { "message" => SAMPLE_MESSAGE } |
| 113 | + # measure do |
| 114 | + # for _ in (1..EVENT_COUNT) do # EVENT_COUNT.times without the block cost |
| 115 | + # filter.filter(LogStash::Event.new(sample_event)) |
| 116 | + # end |
| 117 | + # end |
| 118 | + # end |
| 119 | + # |
| 120 | + # end |
121 | 121 |
|
122 | 122 | @private
|
123 | 123 |
|
|
0 commit comments