logstash-plugins / logstash-input-snmptrap

Apache License 2.0
12 stars 20 forks source link

failling spec under jruby 9k #23

Closed ph closed 7 years ago

ph commented 7 years ago

https://travis-ci.org/logstash-plugins/logstash-input-snmptrap/jobs/236451960

  1) LogStash::Inputs::Snmptrap behaves like an interruptible input plugin #stop returns from run
     Failure/Error: data, host_info = @socket.recvfrom(max_bytes)

     IOError:
       IO Error
     Shared Example Group: "an interruptible input plugin" called from ./spec/inputs/snmptrap_spec.rb:5
     # /home/travis/.rvm/gems/jruby-9.1.9.0/gems/snmp-1.2.0/lib/snmp/manager.rb:552:in `recvfrom'
     # /home/travis/.rvm/gems/jruby-9.1.9.0/gems/snmp-1.2.0/lib/snmp/manager.rb:705:in `block in process_traps'
     # /home/travis/.rvm/gems/jruby-9.1.9.0/gems/snmp-1.2.0/lib/snmp/manager.rb:704:in `process_traps'
     # /home/travis/.rvm/gems/jruby-9.1.9.0/gems/snmp-1.2.0/lib/snmp/manager.rb:631:in `block in initialize'
Finished in 0.59112 seconds (files took 3.2 seconds to load)
2 examples, 1 failure
Failed examples:
rspec ./spec/inputs/snmptrap_spec.rb:5 # LogStash::Inputs::Snmptrap behaves like an interruptible input plugin #stop returns from run
Randomized with seed 41533
ph commented 7 years ago

Seems to be a bad test?

jordansissel commented 7 years ago

I can reproduce this on jruby 9.1.8.0

jordansissel commented 7 years ago

SNMP::TrapListener#exit this closes the underlying socket (good!), and the in-flight socket.recvfrom throws an IOError. This could be ok except that the TrapListener runs the IO call in a separate thread which is not available to Logstash. I'm not sure how rspec is capturing this, to be honest, but I think the fix is to have this exception not thrown during plugin termination.