Closed gmoskovicz closed 6 years ago
Prior to this, we can see a message for the Listener starting:
←[32mStarting gelf listener
{
: address=>"127.0.0.1:12201",
: level=>: info,
: file=>"/jruby/lib/ruby/gems/shared/gems/logsta
sh-input-gelf-2.0.2/lib/logstash/inputs/gelf.rb",
: line=>"81",
: method=>"udp_listener"
}
←[0m
This is the main reason why the Plugins tests are hanging. There is a socket error binding 127.0.0.1:12201
.
CC @ph @suyograo
The very first message looks related:
←[33mgelf listener died
{
: exception=>#<RuntimeError: expectedUTF-8encodingforvalue=127.0.0.1,
encoding=#<Encoding: Windows-1252>>,
: backtrace=>[
"C:/jruby/lib/ruby/gems/shared/gems/logstash-core-2.0.0.beta3-java/lib/logstash/event.rb:264:
in `validate_value'",
"C:/jruby/lib/ruby/gems/shared/gems/logstash-devutils-0.0.18-java/lib/logstash/devutils/rspec/spec
_helper.rb:43:in `[]='",
"C:/jruby/lib/ruby/gems/shared/gems/logstash-input-gelf-2.0.2/lib/logstash/inputs/gelf.rb:101:i
n `udp_listener'",
"C:/jruby/lib/ruby/gems/shared/gems/logstash-input-gelf-2.0.2/lib/logstash/inputs/gelf.rb:63:in `run'
",
"C:/jruby/lib/ruby/gems/shared/gems/logstash-core-2.0.0.beta3-java/lib/logstash/pipeline.rb:180:in `inputworker'",
"C
:/jruby/lib/ruby/gems/shared/gems/logstash-core-2.0.0.beta3-java/lib/logstash/pipeline.rb:174:in `start_input'"
],
: level=>: warn,
: file=>"/jruby/lib/ruby/gems/shared/gems/logstash-input-gelf-2.0.2/lib/logstash/inputs/gelf.rb",
: line=>"66",
: method=>"run"
}
←[0m
Find what is causing this, we need to force encoding to UTF-8 here:
https://github.com/logstash-plugins/logstash-input-gelf/blob/master/lib/logstash/inputs/gelf.rb#L101
event["source_host"] = client[3].force_encoding("UTF-8")
Which succeeds!
PS C:\jruby\lib\ruby\gems\shared\gems\logstash-input-gelf-2.0.2\spec\inputs> rspec .\gelf_spec.rb
io/console not supported; tty will not be manipulated
Using Accessor#strict_set for specs
Run options: exclude {:redis=>true, :socket=>true, :performance=>true, :couchdb=>true, :elasticsearch=>true, :elasticsea
rch_secure=>true, :export_cypher=>true, :integration=>true, :unix=>true}
reads chunked gelf messages #<GELF::Notifier:0x1221c139 @enabled=true, @max_chunk_size=1420, @level_mapping={0=>7, 1=>6,
2=>5, 3=>4, 4=>3, 5=>1}, @rescue_network_errors=false, @default_options={"version"=>"1.0", "host"=>"OWNEROR-H4J1HH2", "
level"=>5, "facility"=>"gelf-rb"}, @sender=#<GELF::RubyUdpSender:0xcbb2984 @socket=#<UDPSocket:fd 114>, @addresses=[["12
7.0.0.1", 12201]], @i=0>, @collect_file_and_line=true, @level=0>
input {
gelf {
port => "12201"
host => "127.0.0.1"
}
}
pass
..
Finished in 5.89 seconds (files took 4.84 seconds to load)
2 examples, 0 failures
Randomized with seed 43262
closed by #23
Setting the environment variable to debug:
Shows that the UDP connection is not working as expected. Here is the information from the output: