-
Notifications
You must be signed in to change notification settings - Fork 5
Update all existing hook repos with the latest changes in this template #16
Comments
Hi @honzajavorek, While updating the Ruby hooks I figured out that I was missing an entire feature file. (I had removed it when stabilizing the dependencies versions quite some time ago as part of apiaryio/dredd-hooks-ruby#16 - my bad.) That's why it didn't fail when I updated Aruba. : / This timeout seems to be a known Aruba issue, or in fact a sort of lack of feature (the step I can make it work partially (read unreliably) using Aruba v0.6.2, however. (Which is probably why it didn't pose problems when the feature was originally written.) Possible workaround Find a reasonable amount of time to wait: # features/tcp_server.feature
#...
Background:
Given I run `dredd-hooks-ruby` interactively
And I run `sleep 2` # replaces the step that waited for output
Scenario: TCP server
When I connect to the server
# ... Remaining concerns
Here is a proof of concept, and the corresponding build. |
Interesting! So Aruba "officially" doesn't have a way how to wait for some output of a running process. That may explain why the tests were sometimes flaky (not remembering whether specifically this one though). In that case, I think we're left with sleeping, indeed. I agree we could go that way. As for killing the handler, I'd prefer to replace the bash lines with something more robust. It may not be necessary to kill the handler for running the test suite in CI, but I'm not sure I could locally successfully run the suite repeatedly if there are processes left. Isn't there a Ruby gem to provide a way how to easily kill processes? That could even bring us closer to portability of the test suite (support for Windows is coming soon). |
Hi @honzajavorek, I can't find a way to cleanly kill processes by name. There are a few Ruby wrappers to manage processes, but they seem to be intended to be managed by PID (at the *nix level) - we can use such a wrapper, but I'm not sure it really qualifies as more robust. Any thoughts @ddelnano? |
I'm just experimenting with ps-node in the Dredd test suite to solve the same thing. There are situations where processes are killed by name, and I'm trying to use ps's lookup first to get PID and then kill. I'm not sure it really works on all platforms yet though and I'm really not sure I'd like to mix Ruby and Node like that. I think the lib parses ps output (or win equivalent to ps command output). Similar Ruby solution would be the best. I can look into it later, but first I need to verify that it actually works at least in Node, in the tests. Or, maybe, we're solving a wrong problem here and the test can be done in a different way completely, but I'm really short of ideas how to ensure a good tear down. Stale processes can lead to "port taken" problems when locally running the same tests again, and similar issues. |
@gonzalo-bulnes @honzajavorek about the issue about when the hooks server is still listening on the port. Not sure if this is useful but someone asked me to merge functionality on the php hooks side that could be useful although its not going to solve the final tear down. The php hooks accept a The implementation can be found here |
I have updated the perl one as part of ungrim97/Dredd-Hooks#7 |
@ddelnano I'm not sure it would be a good idea to do that always. Killing a process in someone's system seems quite invasive to me. If a user chooses to do so by using a special option ( |
Just to reiterate, the current changes in the template's Before introducing the current changes to other hooks, we need to get the template fixed, i.e. get the template working first with either Ruby ( apiaryio/dredd-hooks-ruby#31 ) or Python ( apiaryio/dredd-hooks-python#28 ) hooks. The only missing part seems to be to find a nice way how to kill processes in Ruby, preferably by a dedicated library (and if dreaming is allowed, also cross-platform library). I've tried to find something and inspired by some forum posts, I got as far as this: $ gem install sys-proctable require 'sys/proctable'
Sys::ProcTable.ps.each { |ps|
puts ps.cmdline
# Ideally, there would be something like... (ruby-like pseudocode)
#
# if ps.cmdline contains 'hook-handler...'
# Process.kill('KILL', ps.pid)
# end
} @gonzalo-bulnes Do you think this would solve the issue? |
I'll also make a quick list of what we know so far to :P About killing the
On the other hand...
I cannot find a Dredd Hooks process left behind after the Dredd Hooks Ruby test suite ran on my machine. I've augmented a little bit the script from apiaryio/dredd-hooks-ruby#31 with debug output: # features/support/env.rb
require 'aruba/cucumber'
require "sinatra/base"
Before do
puts "Killing server..."
system "echo 'Searching for hooks:'"
system "ps aux | grep 'dredd-hooks'"
system "echo 'Searching for server.rb:'"
system "ps aux | grep 'server.rb'"
system "for i in `ps axu | grep 'server.rb' | grep ruby | awk '{print $2}'`; do kill -9 $i; done > /dev/null 2>&1"
sleep 3
@aruba_timeout_seconds = 10
end And I see no process to be killed at any point... neither when Sample output:
Hypothesis So I'm left wondering: is it possible that Aruba takes care of stopping the processes it runs interactively? I found this clue: https://www.relishapp.com/cucumber/aruba/v/0-9-0/docs/commands/interactive-process-control#all-processes-are-stopped-before-checking-for-filesystem-changes Sadly, I was unable to find the issue that's referred there for context. We're not performing filesystem checks, but I still see no left-over processes. Could it be that interactive processes are executed in a sub-shell (hence not visible to I'm sorry, these are more questions than answers. But I'm now more keen on removing the Any thoughts? |
The thing is, I think we need to confirm the tests clean up even if they're testing something which doesn't work as expected. That means, if Dredd won't correctly stop its child processes, the test suite should take care of any leftovers. In case Dredd works as expected and cleans up itself, it's possible these tear-downs do not catch and kill anything and that would be all right. If we can rely on Aruba automatically cleaning up any possible leftover child processes or subprocesses (if we experiment and we're still not sure, we can ask in their issues), then I'm completely okay with removing the custom killing logic altogether 👍 |
This template was updated with some minor changes recently. We should update the local copies in each hooks repo to contain those changes.
Related to: #9, #10, #12, #13, #14
The text was updated successfully, but these errors were encountered: