-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make usage of the new shutdown api + small rspec refactor #10
Make usage of the new shutdown api + small rspec refactor #10
Conversation
@@ -1,43 +1,63 @@ | |||
# encoding: utf-8 | |||
require "logstash/devutils/rspec/spec_helper" | |||
require_relative "../spec_helper" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this change feels right. It saves us one line of code here, but moves it to another file and requires a new file to be maintained. Can you tell me about the gain here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me having the old "automatic" behaviour of pointing everything to a single spec_helper per project, so there we can have specific helpers, mocks, etc. But I understand this does not provide much here 👍
The The new test doesn't pass for me:
|
(I have elastic/logstash#3812 and elastic/logstash-devutils#32 installed locally) |
Thanks for your test @jordansissel I will investigate this. |
If I understand your issue @jordansissel properly, this could happen because the plugin actually finished even before the first check for being alive. This makes me to have a question here, how do you guess this would have happen? might this be an error during the loop? Can you check if you see any kind of exception or logging message? I will try to reproduce, but I think the situation you see if because I took away https://github.com/logstash-plugins/logstash-input-pipe/blob/master/lib/logstash/inputs/pipe.rb#L66 in this PR, I will bring it back and introduce a way to wakeup the thread if necessary. Hope this provide a solution to your issue. |
@jordansissel, this test uses a unicode character, might be there is a problem regarding this? |
My expectation is the new test added https://github.com/purbon/logstash-input-pipe/commit/88abb4836da765f6650560581611722d041908c9 should not be failing in your env, can you check that for me? Thanks a lot. |
rescue Exception => e | ||
@logger.error("Exception while running command", :e => e, :backtrace => e.backtrace) | ||
end | ||
|
||
# Keep running the command forever. | ||
sleep(10) | ||
@sleep = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of this? Should we be using a synchronization mechanism instead? I'm not sure I like sleep+wakeup, but wait+notify is more common (a ConditionVariable) and I feel more confident in its thread safety.
@shutdown_requested = true | ||
def stop | ||
super | ||
Stud.stop! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless Stud.interval
is used, Stud.stop!
is not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, I got it, I thought it was necessary to stop stoppable_sleep too.
@talevy @jordansissel @colinsurprenant is this plugin ready to be merged? |
@purbon can you rebase? |
pre-rebase: LGTM |
refactor a bit the specs in order to include the new shared example to track the shutdown plus make them more rspec friendly.
Merged sucessfully into master! |
Implements
stop
to return fromrun
according to elastic/logstash#3210Depends on elastic/logstash-devutils#32 and elastic/logstash#3812
Fixes #11