Skip to content
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

QuickCheck experiment #3

Merged
merged 9 commits into from
Oct 11, 2013
Merged

QuickCheck experiment #3

merged 9 commits into from
Oct 11, 2013

Conversation

seliopou
Copy link
Collaborator

This pull requests includes QuickCheck tests for the OpenFlow0x01.Wildcards module. During the course of implementing the tests, I found that the nw_src and nw_dst have type int but those should be uint, if OCaml had such a type.

Some questions:

  • Is it worth going doing roudtrip testing with QuickCheck for all the serializable types in this package?
  • A subordinate question: Doing so requires exposing currently private functions (i.e., marshal and parse). Is this acceptable?
  • Where should QuickCheck "instances" reside? Separate from the module providing the datatype requires that the datatype no longer be abstract.

For my perspective, the answer to these questions are: yes, yes, and it should go in the module where the datatype is defined.

@reitblatt
Copy link
Collaborator

On Thu, Oct 10, 2013 at 11:29 AM, Spiros Eliopoulos <
notifications@github.com> wrote:

This pull requests includes QuickCheck tests for the
OpenFlow0x01.Wildcards module. During the course of implementing the tests,
I found that the nw_src and nw_dst have type int but those should be unit,
if OCaml had such a type.

Do you mean uint? OCaml int types are quite a pain, I personally think we
shouldn't be using "int" at all in that module. Those should probably be
Int32.

Some questions:

  • Is it worth going doing roudtrip testing with QuickCheck for all the
    serializable types in this package?

Yes! But that's a bit of a task. I would actually prioritize OpenFlow0x04
since that's what we're using for the PLDI development. The first 7 cases
of OpenFlow0x04.Messages.t are probably what we really should cover.

  • A subordinate question: Doing so requires exposing currently private
    functions (i.e., marshal and parse). Is this acceptable?
  • Where should QuickCheck "instances" reside? Separate from the module
    providing the datatype requires that the datatype no longer be abstract.

For my perspective, the answer to these questions are: yes, yes, and it
should go in the module where the datatype is defined.

I agree. I don't know what unit test Best Practices (TM) are, but this
seems reasonable to me. So would we then have a test() method in each
module that gets called from Test.ml?


You can merge this Pull Request by running

git pull https://github.com/frenetic-lang/ocaml-openflow quickcheck

Or view, comment on, or merge it at:

#3
Commit Summary

  • qc: add quickcheck as a dependency
  • qc: expose 0x01.Wildcards parse and marshal
  • qc: Implement 0x01.Wildcards roundtrip tests
  • qc: note OF0x01.Wildcards fields that are unsigned

File Changes

Patch Links:

@seliopou
Copy link
Collaborator Author

Yep that was a typo. I meant uint.

Are the OpenFlow0x04 datatypes completely independent from OpenFlow0x01? Arbitrary instances do tend to build on top of each other, but if they're independent I'll start looking at OpenFlow0x04 sooner rather than later.

I envision having just the arbitrary instance in the module where the datatype was defined, exposing parse and marshal, and then putting it all together in Test.ml. I'll make those changes before this is merged in.

@reitblatt
Copy link
Collaborator

On Thu, Oct 10, 2013 at 12:34 PM, Spiros Eliopoulos <
notifications@github.com> wrote:

Yep that was a typo. I meant uint.

Are the OpenFlow0x04 datatypes completely independent from OpenFlow0x01?
Arbitrary instances do tend to build on top of each other, but if they're
independent I'll start looking at OpenFlow0x04 sooner rather than later.

Not quite sure what you mean by arbitrary instances, but OpenFlow0x04
diverged a fair bit from OpenFlow0x01 for most of the message types. I'd
say they're fairly independent, but Marco/Arjun have been in that code much
more recently than I have.

I envision having just the arbitrary instance in the module where the
datatype was defined, exposing parse and marshal, and then putting it all
together in Test.ml. I'll make those changes before this is merged in.

Sweet! With unit tests, we might be able to pass for a real software
project!

@jnfoster
Copy link
Member

Small correction: I suggest not prioritizing 0x04 over 0x01 (Mark's paper
is not the only project using this).

-N

On Thu, Oct 10, 2013 at 12:34 PM, Spiros Eliopoulos <
notifications@github.com> wrote:

Yep that was a typo. I meant uint.

Are the OpenFlow0x04 datatypes completely independent from OpenFlow0x01?
Arbitrary instances do tend to build on top of each other, but if they're
independent I'll start looking at OpenFlow0x04 sooner rather than later.

I envision having just the arbitrary instance in the module where the
datatype was defined, exposing parse and marshal, and then putting it all
together in Test.ml. I'll make those changes before this is merged in.


Reply to this email directly or view it on GitHubhttps://github.com//pull/3#issuecomment-26069325
.

@reitblatt
Copy link
Collaborator

On Thu, Oct 10, 2013 at 12:44 PM, Nate Foster notifications@github.comwrote:

Small correction: I suggest not prioritizing 0x04 over 0x01 (Mark's paper
is not the only project using this).

True, but OpenFlow0x01 has been fairly stable for a while now, right? While
OpenFlow0x04 was just hacked up. So, testing should be directed at the more
complicated/less tested code, no?

As per the discussion on #3, arbitrary instances will reside in the
module where the datatype it's testing resides. Because of this, the
quickcheck library is now a dependency for the openflow library, as well
as the test suite.
@ghost ghost assigned arjunguha Oct 10, 2013
@@ -20,7 +20,8 @@ Library openflow
cstruct,
cstruct.syntax,
lwt.syntax,
packet
packet,
quickcheck
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend making this an optional dependency, by creating an openflow.quickcheck sub-library. See how it is done here:

https://github.com/frenetic-lang/netkat/blob/master/_oasis

@arjunguha
Copy link
Member

I recommend putting *_arbitrary into a separate library. Keep the structure flat. I'd like to also flatten the structure of the OpenFlow parsers by using OCaml 4.01

@jnfoster
Copy link
Member

0x01 is unfortunately not all that stable. But the code is a bit more
structured and polished. So not to micromanage, but I think it makes sense
to vet / harden it first, then build on that experience to impose the same
level of rigor on the 0x04 code. And we need 0x01 for the abstraction layer
anyway.

-N

On Thu, Oct 10, 2013 at 12:50 PM, Mark Reitblatt
notifications@github.comwrote:

On Thu, Oct 10, 2013 at 12:44 PM, Nate Foster <notifications@github.com

wrote:

Small correction: I suggest not prioritizing 0x04 over 0x01 (Mark's paper
is not the only project using this).

True, but OpenFlow0x01 has been fairly stable for a while now, right? While
OpenFlow0x04 was just hacked up. So, testing should be directed at the more
complicated/less tested code, no?


Reply to this email directly or view it on GitHubhttps://github.com//pull/3#issuecomment-26070570
.

@arjunguha
Copy link
Member

Nate, Mark, you need to get on our hangout with marco and spiros. It is caleld FLAT TIRE.

Use the OpenFlow0x01_Arbitrary signature to build all the components of
a roundtrip test. Then it will be straightforward to run a test using
the values defined in the module that conforms to that signature:

    module M : OpenFlow0x01_Arbitrary

    quickCheck M.arbitrary M.to_string M.parse M.marshal
@seliopou
Copy link
Collaborator Author

@arjunguha This should be good to go.

arjunguha added a commit that referenced this pull request Oct 11, 2013
@arjunguha arjunguha merged commit ee1e5d0 into master Oct 11, 2013
mcanini pushed a commit that referenced this pull request Jul 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants