-
Notifications
You must be signed in to change notification settings - Fork 232
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
[WIP] RFC ###### - Protocol Driven Development #11
Comments
On Tue, Jun 09, 2015 at 09:55:51AM -0700, David Dias wrote:
I'd expect many of our protocols to be asynchronous, so “order” should
should be a valid response. We'll want to ensure the protocol can Or are we only running a single command thread per connection in this |
@jbenet's comments
Can we be more specific? How about:
"network" can mean connection, but can also mean more. May not be the best way to place the "online" vs "offline" distinction, but should mention it somewhere. (Btw, HTTP is an example of an asynchronous (or semi-asynchronous) protocol, because the REQ/RES pair can happen even if the network breaks. In practice, HTTP rides on TCP, and TCP is mostly an online protocol (because of the windowing), but if requests are small enough, HTTP/TCP behaves asynchronously, which is really good for all sorts of perf concerns.
Beautiful 👍 !
Hm, this is tricky, because we may have protocols that may have optional ( Maybe it makes sense to enable writing an implementation "distiller" (not the best name for this...) that produces the exact output we want to check
So the distiller could drop optional pieces, or know how to glean out the exact information. This is --of course-- tricky too, because differences on how optional things are implemented may break other implementations. But this gives a bit of freedom that may be hard to get without?
Yes, beautiful!! 👍 |
@diasdavid liking this very much! |
Awesome, thank you for the rad input!
Good point! I believe that we can come up with a "Protocol Test Spec DSL" that covers this cases, such as:
So taking from that examples we would have:
This means that A must be ACK'ed, but it doesn't have to be the next message, Heartbeats are option and the B message stream has order and that must be respected.
Yes we can, just updated :)
Indeed, I think we can accommodate this with the Protocol Test Spec DSL described above, so that once we have a "pristine implementation" (aka first implementation to appear that we trust it conforms with the spec),1: we extract the outputs for the tests in place, 2: take those outputs and use them as the comparison unit for other implementations 3: use a "protocol asserts" that instead of comparing both outputs in a rigid way, take what's defined on the Protocol Test Spec DSL and verify the "flow" was respected. Apologies if the above is confusing, I've just finished doing the Protocol Compliance tests for MultiStream and I am writing now it as a "case study/example" to make how things work more evident. |
On Wed, Jun 10, 2015 at 09:43:39AM -0700, David Dias wrote:
It would be awesome if we could find an already-written version of I'm not saying that designing a good protocol DSL isn't a worthy goal,
Can we only get heartbeats after B-1? I think it's better to make a protocol = handshake *parallel-stream [close] but you'd need to tweak things somewhat because a response and a
Since I favor a more abstract protocol definition, I don't think |
@wking agree that if there is something out there that can be used, it can be great. Going to ping some folks around and do some research on that. However, we will can start with the uses cases we have and what feels right and iterate over it (like its own Protocol?) Here goes a brain dump from what I've been thinking, working and doing for MultiStream PDD for MultiStream (example/use case)ProtocolDefined here:
Protocol Compliance Tests SpecGiven the protocol spec, an implementation of the multistream-select protocol has to comply with the following scenarios: 1 - push-streamIn a push-stream example (one-way stream), we have two agents:
Compliance test 1 (human readable format):
2 - duplex-streamIn a duplex-stream example (interactive conversation), we have two agents:
Compliance test 2 (human readable format):
Wire outSince this protocol is not fully plaintext, we have to capture the messages/packets that transmited by one of the agents to make sure we get the transformations right (and therefore doing development driven by what is going on in the wire, which is defined by the Protocol (PDD ftw!)) With a first implementation written, we can capture the messages switched on the wire, so that later, we can require other implementations to conform. For the multistream scenario, tests are organized by the following:
Protocol Compliance Test SuitThe protocol compliance test suit for multistream-select can be found on I think now would be a good time to write this up in a .md file so more people can proactively contribute with their suggestions? |
On Wed, Jun 10, 2015 at 03:38:57PM -0700, David Dias wrote:
Yeah, that makes sense.
Is this just for making sure the silent listener doesn't barf into the Are push streams sent via broadcast-only protocols (e.g. UDP to a
Hmm, how do we differentiate push-streams from duplex-streams? Or is How do you leave a protocol? And how does this multiplex? Or do we With a connection established between interactive - select< 0 /multistream/1.0.0
Looks good to me, and you could always use symlinks (or IPFS!) to You probably also need a way to prime the test implementation.
Seems reasonable to me. |
@wking your questions show a very valid point, which is the fact that since we had some side channel conversations of the protocol, without describing its implementation on the Protocol Spec or not point to a reference implementation, questions like "how we know the role of each side", appear. A lot of that is answered here: ipfs/js-ipfs#13 (comment) . One of my goals with PDD is also to answer those questions as soon as possible when we design a protocol, since we will have to ask ourselves what will be the questions made by whom is implementing it. Just to clarify, multistream is to multiplex streams, it is not focused on the connection itself, so in order to reuse the connection for several protocols, we could do:
Indeed we have, I hadn't thought of how to represent it in text. In the MultiStream scenario, in order to properly tested it, we didn't only have to start the protocol but also register handlers, so that features get tested, you can see by the example that a /dogs/0.1.0 was registered, so that the request to connect it was successful, while the /mouse/1.1.0 wasn't, and therefore we tested for the "na" scenario. I've moved the writing of PDD to #12, so we can avoid the copy and paste for commenting and reviewing :) |
@diasdavid +1 to the indentation |
This is in reference to #11. Thanks @diasdavid for the suggestion.
Abstract
Introduction
Cross compatibility through several implementations and runtimes is historically an hard goal to achieve. Each framework/language offers different testing suits and implement a different flavour of testing (BDD, TDD, RDD, etc). We need a better way to test compatibility across different implementations.
Instead of the common API tests, we can achieve cross implementation testing by leveraging interfaces offered through the network and defined by the Protocol. We call this Protocol Driven Development.
In order for a code artefact to be PDD compatible
Objectives
The objectives for Protocol Driven Development are:
Process
In order to achieve compliance, we have to follow four main steps:
1 - Define the desired Protocol Spec that is going to be implemented
2 - Design the compliance tests that prove that a certain implementation conforms with the spec
3 - Once an implementation is done, capture the messages traded on the wire using that implementation, so that the behaviour of both participants can be replicated without the agent
4 - Create the Protocol Compliance Tests (consisting on injecting the packets/messages generated in the last step in the other implementations and comparing outputs)
Protocol Spec
Should define the goals, motivation, messages traded between participants and some use cases. It should not cover language or framework specifics.
Protocol Compliance Tests Spec
Defines what are the necessary “use stories” in which the Protocol implementation must be tested to assure it complies with the Protocol Spec. For e.g:
A test would pass if the messages transmitted by an implementation follow the expected format and order and it would fail if format and order are not respected, plus if any extra message is transmitted that is was not defined.
Tests should be deterministic, so that different implementations produce the same results:
So that a diff between two results should yield 0 results
Interchange Packet/Message Capture
Since most of these protocols define leverage some type of encoded format for messages, we have to replicate the transformations applied to those messages before being sent. The other option is capturing the messages being sent by one of the implementations, which should suffice the majority of the scenarios.
Protocol Compliance Tests Suite
These tests offer the last step to test different implementations independently. By sending the packets/messages and evaluating their responses and comparing across different implementations, we can infer that in fact they are compatible
Example use case - go-multistream and node-multistream tests
(experimenting, will report soon :) )
The text was updated successfully, but these errors were encountered: