-
Notifications
You must be signed in to change notification settings - Fork 280
Writing hooks in other languages e.g. Ruby, Python, PHP, Java, etc.. #134
Comments
Hi @netmilk, I was thinking about that this morning in relation with #100. In Ruby environments, there are usually resources available that could be used to do the tests setup (e.g. FactoryGirl) and tear down (e.g. DatabaseCleaner). Usually, those resources are themselves tested (e.g. factories validity checking is part of the test suite) and it makes a lot of sense - in my opinion - to use them if possible. Do you have ideas about how the communication could be established between the Javascript program and support scripts written in other languages? (I can only imagine a stop/resume mecanism: Dredd runs until there is time to trigger a hook, it stops returning the hook name, the hook then runs and resumes Dredd. But I doesn't seem to be a good idea to me.) |
Hi @gonzalo-bulnes, thank you very much for your ideas. FactoryGirl, DatabaseCleaner and company in other languages are definitely tools which are testing-friendly people used to use and I definitely want to make them available in Dredd envronment. About bowels inside: When Dredd want to execute some hoook, it will emit JSON with type of hook, compiled HTTP transaction and its name to the pipe and it will wait for the response form hook worker/workers. Worker in some specific language will process all related hooks for passed transaction and after hook execution it will return transaction back to Dredd for execution and/or examination of transaction result. All ideas, thoughts, improvements, requirements, or contributions are more than welcome! :) |
I've no idea of how signals, named pipes or sockets work but I'd love to implement the Ruby side of something alike! I'm doing some research. By the way, pointers are welcome if there is any documentation you specially appreciate on these topics ; ) |
Hi @netmilk, I did some experiments of inter-process communication with named pipes. Unless I'm missing something, in order to allow Dredd to send the JSON with type of hook, compiled HTTP transaction and its name to the pipe (let's say the hook request) one named pipe should be defined which Dredd could write and the hooks handler could read. And in order to hold the response, another named pipe should be defined which the hooks handler could write and Dredd could read. Am I right? Now this question: could these two named pipes be provided to Dredd as command-line arguments? (That could be seen as some kind of worker registration.) # Example: the tmp/dredd_to_worker.pipe can be written by Dredd and
# the tmp/worker_to_dredd.pipe will contain the resulting transaction
# once the hook will be processed
dredd doc/*.apib.md http://localhost:4567 --additional-hooks-handler-input tmp/dredd_to_worker.pipe --additional-hooks-handler-output tmp/worker_to_dredd.pipe
# the flags names are arbitrary and were only chosen to be unambiguous If they could, then I have an idea about how the communication between Dredd and a Ruby test suite could be implemented (see this example, where the main program would be Dredd, and the worker_provider would be part of a Ruby test suite). Is that more or less what you had in mind? I'm looking forward for comments : ) Best regards! |
it's totally cool what you did! I did some investigation about how to figure it out as well and I found out that the most straightforward solution will probably be to use a netowrk socket instead of named pipes. The reason is that node.js doesn't support named pipes, so there is not available Adam |
Hi @netmilk, I'm glad you liked the examples! I'll take a look at sockets, for what I've seen so far, using them instead of pipes sounds right to me. (By the way, note that Ruby doen't support creating named pipes either - at least I didn't found how to create them. Both maned pipes do pre-exist in the examples I wrote.) Regards! |
Hi @gonzalo-bulnes, here are some notes about working proof of concept for hooks in Ruby. Let me know what you think, please. |
Remove CoffeeScript dev dependencies
I'm curious if it is limiting for anyone to write hooks only in JavaScirpt/CoffeeScript.
Is anyone interested in possibility to write hooks in native language for specific System Under Test? e.g. when my backend is in Rails it could be more comfortable to write hooks in Ruby.
The text was updated successfully, but these errors were encountered: