-
Notifications
You must be signed in to change notification settings - Fork 280
Dumb implementation for support --port and --host for hooks server #712
Dumb implementation for support --port and --host for hooks server #712
Conversation
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.
Thanks very much! Especially for discovering the discrepancy in Dredd's universe. I like the change, but several things need to be resolved first:
- There should be the discussion about how the parameters should look and work, as you mention, but honestly,
--port
and--host
look quite production-ready to me 😄 The discussion should happen in Add test for configurable port dredd-hooks-template#17. - We need to find out how other hook libs will behave if they're given
--port
and--host
before releasing this or similar change. People can have older installations while upgrading Dredd itself. I'm not sure whether other hook handlers will at least ignore the unknown arguments 🤔 (see Tests do not validate hooks can listen on different ports dredd-hooks-template#11 (comment)) - I'd like Drop support for Node 0.10 and 0.12 #716 to be merged first so we get rid of the failing builds.
src/hooks-worker-client.coffee
Outdated
@@ -163,9 +163,10 @@ class HooksWorkerClient | |||
callback() | |||
|
|||
spawnHandler: (callback) -> | |||
pathGlobs = [].concat @runner.hooks?.configuration?.options?.hookfiles | |||
pathGlobs = [].concat ["--port", "#{@handlerPort}", "--host", "#{@handlerHost}"], @runner.hooks?.configuration?.options?.hookfiles | |||
console.info pathGlobs |
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.
Is this a debugging leftover? Maybe it was meant as logger.info
?
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.
Yep, removed it.
src/hooks-worker-client.coffee
Outdated
@@ -163,9 +163,10 @@ class HooksWorkerClient | |||
callback() | |||
|
|||
spawnHandler: (callback) -> | |||
pathGlobs = [].concat @runner.hooks?.configuration?.options?.hookfiles | |||
pathGlobs = [].concat ["--port", "#{@handlerPort}", "--host", "#{@handlerHost}"], @runner.hooks?.configuration?.options?.hookfiles |
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.
In this case, I'd probably call the variable args
instead of pathGlobs
(with subsequent changes in the code below).
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.
Also, lately I tend to prefer to have all Dredd options in the GNU-style --option=value
format, consistently. In the case of Dredd itself, both formats should work, I just wanted to choose one way to go and stick with it.
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.
Updated both of these.
Todo
|
Will require an update to the perl hook script to support the port/host arguments. Passing them in to the current version shouldn't break anything. (it will look for hookfiles files called --port=1234 and --host=127.0.0.1 but obviously won't find one and will skip them) Will make an update to accept the new params |
ungrim97/Dredd-Hooks#7 should cover whats needed to make the Perl version work for this |
c293998
to
47369b8
Compare
I'll check Python hooks and see if I can implement this feature quickly. |
47369b8
to
bf2e480
Compare
@honzajavorek @w-vi @ungrim97 so looks like all existing hooks servers will not be affected by this change except the Go ones. How do we want to handle that? I can get those updated soon but wanted to understand better what the plan was. |
Python hooks won't do anything bad, will skip the args so no issue here. |
But what I mean is do we want to continue down this path? It's going to cause existing go hook servers problems. All other hooks seem fine but still. |
I'm sorry for not being prompt in answering (got sick). @ddelnano thanks very much for checking all the hooks! This is amazing work. I see three options how to proceed:
What do you think? |
@honzajavorek I definitely want to avoid option 1 :). And since the |
@honzajavorek sorry for the long delay, had an unexpected hospital trip but I'm doing much better. Another way we could check the hooks server that I thought of that would be very dumb but get the job done. We could have dredd try and run the hooks server with the |
@ddelnano Whoa! 🚑 Whatever it was, I wish you to get better quickly! The fact there is no way we can hardcode a check for go hooks version is unfortunate. I'll think about the trial & error approach. At first sight, I don't like it very much, but at the same time, it can be the only way we're left with to save the situation 🙂 |
@honzajavorek thanks, things are back to normal now :). One thing I didn't think of for the hardcoded check. In the next version of the go hooks we could add a command to output the version and then if it doesn't support the version command we can assume that it won't support the |
@ddelnano What is the current behavior of go hooks if they're provided with |
It's going to crash... |
Then I think we're okay with what you proposed in #712 (comment). Dredd could try to run the hook handler with options and if it crashes, it tries to run it without the options. If it doesn't crash, Dredd respects the test results. |
Ok. Yea obviously not ideal but there aren't many options unfortunately. This weekend I will have some time I'll give that a shot. And work on getting the go hooks updated to use the new flags. |
I'm very sorry we were not able to get back to this. I need to close this as we're going to work on #705 first, which requires having no pending Pull Requests. We'll get back to this proposal as soon as we're addressing #917. Finishing this PR is listed on #917 as one of the necessary steps, so it shouldn't get forgotten. Thank you for the contribution! I hope we'll have the chance to tidy up the template soon. |
🚀 Why this change?
To allow compliant hooks servers to listen on different ports and ip addresses
📝 Related issues and Pull Requests
apiaryio/dredd-hooks-template#11
apiaryio/dredd-hooks-template#17
✅ What didn't I forget?
Still very much WIP since I believe there will need to be a discussion on what flags the hooks servers should look for (php already uses
--port
and--host
but this can be up for discussion), how to stage these changes amongst the projects, etc. I just wanted to get the simplest thing done so that I could run the dredd-hooks-php cucumber tests with this new test to validate it works properly.