|
15 | 15 | #Cabin::Channel.get(LogStash).level = :debug |
16 | 16 | describe LogStash::Inputs::Tcp do |
17 | 17 |
|
| 18 | + def get_port |
| 19 | + begin |
| 20 | + # Start high to better avoid common services |
| 21 | + port = rand(10000..65535) |
| 22 | + s = TCPServer.new("127.0.0.1", port) |
| 23 | + s.close |
| 24 | + return port |
| 25 | + rescue Errno::EADDRINUSE |
| 26 | + retry |
| 27 | + end |
| 28 | + end |
| 29 | + |
| 30 | + let(:port) { get_port } |
| 31 | + |
18 | 32 | context "codec (PR #1372)" do |
19 | 33 | it "switches from plain to line" do |
20 | 34 | require "logstash/codecs/plain" |
|
36 | 50 |
|
37 | 51 | it "should read plain with unicode" do |
38 | 52 | event_count = 10 |
39 | | - port = rand(1024..65535) |
40 | 53 | conf = <<-CONFIG |
41 | 54 | input { |
42 | 55 | tcp { |
|
69 | 82 |
|
70 | 83 | it "should handle PROXY protocol v1 connections" do |
71 | 84 | event_count = 10 |
72 | | - port = rand(1024..65535) |
73 | 85 | conf = <<-CONFIG |
74 | 86 | input { |
75 | 87 | tcp { |
76 | | - port => #{port} |
77 | 88 | proxy_protocol => true |
| 89 | + port => '#{port}' |
78 | 90 | } |
79 | 91 | } |
80 | 92 | CONFIG |
|
104 | 116 | end |
105 | 117 |
|
106 | 118 | it "should read events with plain codec and ISO-8859-1 charset" do |
107 | | - port = rand(1024..65535) |
108 | 119 | charset = "ISO-8859-1" |
109 | 120 | conf = <<-CONFIG |
110 | 121 | input { |
|
132 | 143 | end |
133 | 144 |
|
134 | 145 | it "should read events with json codec" do |
135 | | - port = rand(1024..65535) |
136 | 146 | conf = <<-CONFIG |
137 | 147 | input { |
138 | 148 | tcp { |
|
167 | 177 | end |
168 | 178 |
|
169 | 179 | it "should read events with json codec (testing 'host' handling)" do |
170 | | - port = rand(1024..65535) |
171 | 180 | conf = <<-CONFIG |
172 | 181 | input { |
173 | 182 | tcp { |
|
194 | 203 | end |
195 | 204 |
|
196 | 205 | it "should read events with json_lines codec" do |
197 | | - port = rand(1024..65535) |
198 | 206 | conf = <<-CONFIG |
199 | 207 | input { |
200 | 208 | tcp { |
|
233 | 241 |
|
234 | 242 | it "should one message per connection" do |
235 | 243 | event_count = 10 |
236 | | - port = rand(10000..65535) |
237 | 244 | conf = <<-CONFIG |
238 | 245 | input { |
239 | 246 | tcp { |
|
271 | 278 | srand(RSpec.configuration.seed) |
272 | 279 | end |
273 | 280 |
|
274 | | - let(:port) { rand(1024..65535) } |
275 | 281 | subject { LogStash::Plugin.lookup("input", "tcp").new({ "port" => port }) } |
276 | 282 | let!(:helper) { TcpHelpers.new } |
277 | 283 |
|
|
0 commit comments