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

Migrate finagle-thrift/finagle-stream tests to ScalaTest #291

Closed
wants to merge 12 commits into from

Conversation

bajohns
Copy link
Contributor

@bajohns bajohns commented Jul 5, 2014

In preparation for 2.11.x finagle-thrift tests will migrate to ScalaTest

Remaining Work:

  1. Finagle-Streams
  2. 2.11.x testing
  3. Conversation about FinagleClientThriftServerSpec structure
  4. Renaming tests from *Spec -> *Test
  5. Clean up commit history and conform to commit message standards

@bajohns
Copy link
Contributor Author

bajohns commented Jul 5, 2014

@mosesn - In issue #290 you mentioned testing 2.11.x compatibility but I have not seen a published 2.11 version of twitter/util.

Should I use falone/util - and publish-local - to test 2.11?

@mosesn
Copy link
Contributor

mosesn commented Jul 5, 2014

Yeah, that sounds promising. We'll probably publish our first 2.11 util in the next couple weeks.

@bajohns bajohns changed the title WIP Migrate finagle-thrift tests to ScalaTest WIP Migrate finagle-thrift/finagle-stream tests to ScalaTest Jul 13, 2014
bajohns added 2 commits July 12, 2014 23:39
Problem

ThriftTest has testing functionality that was marked flaky but currently
passes.  I am unsure if these are desired tests but they pass and may be
useful.

Solution

Given that there is a convention for including flaky tests by default
- and disabling via ENV variable - I reenabled test paths that pass.  For
paths that do not pass I created a skipThriftTest method.

Result

Potentially higher test coverage in the package.
@bajohns
Copy link
Contributor Author

bajohns commented Jul 13, 2014

@mosesn - I completed the specs -> scalatest conversion for finagle-thrift and finagle-stream.

Please let me know any feedback you may have so I can rebase the work into a set of final commits that conform to the commit standard.

Lastly, I came across two issues that I would like some more input on:

  1. finagle-thrift has test functionality in ThriftTest.scala that seems useful and is marked flaky. I uncommented parts of it and migrated it to checking an environment variable to determine whether to run or not. Based on other tests, this looks like the new convention for dealing with tests that have intermittent failures. Please see this commit: bajohns@1531023

  2. I have not found a good solution to replace the specs2 matcher must beLike. It is used a number of times in finagle-thrift and in a nested fashion in finagle-stream specs scalatest . Please let me know if you have other methods for migrating that construct.

@bajohns bajohns changed the title WIP Migrate finagle-thrift/finagle-stream tests to ScalaTest Migrate finagle-thrift/finagle-stream tests to ScalaTest Jul 13, 2014
@mosesn
Copy link
Contributor

mosesn commented Jul 16, 2014

Hey @bajohns this looks great! Unfortunately, I've been snowed in work-wise, and haven't had a chance to take a look at this yet. It's still on my plate, but it will take a little while to get to it. Sorry! 😬

@bajohns
Copy link
Contributor Author

bajohns commented Jul 26, 2014

Hey @mosesn, no rush I see there is a lot of activity around these change sets. Thanks for all your work to accept contributions!

val protocolFactory = new TBinaryProtocol.Factory()

test("async Thrift server should work"){
// ** Set up the server.
Copy link
Contributor

Choose a reason for hiding this comment

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

Rm the ** while we're in here.

@bajohns
Copy link
Contributor Author

bajohns commented Aug 4, 2014

@evnm - Thanks for reviewing. All comments handling in next commit: bajohns@255983d

@bajohns
Copy link
Contributor Author

bajohns commented Aug 9, 2014

Looks like the build failed only for artifact resolution. Rebuild should clear it out.

[error] (finagle-commons-stats/*:update) sbt.ResolveException: download failed: com.google.inject#guice;3.0!guice.jar
[error] Total time: 11 s, completed Aug 4, 2014 2:04:13 AM

import org.jboss.netty.handler.codec.http._
import org.scalatest.{OneInstancePerTest, FunSuite}

class EndToEndTest extends FunSuite with OneInstancePerTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love the style of OneInstancePerTest, it's not particularly idiomatic scalatest. Generally we just make a context class and import its contents in each test. By sticking to one style, it's easier for us to reason about different tests, and by having tightly scoped context classes, we can have more sophisticated fixtures if we have a big test suite, for example.

with BeforeAndAfter
with OneInstancePerTest
{
class ClientIdContextTest extends FunSuite with BeforeAndAfter with OneInstancePerTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this style, but probably not worth changing, since you don't need to change it for any other reason.

@mosesn
Copy link
Contributor

mosesn commented Aug 10, 2014

LGTM other than a couple style nits. The context class vs. OneInstancePerTest thing is up to you--I prefer having a single paradigm across finagle, and OneInstancePerTest is only used twelve times in finagle, but it does make the code cleaner, so maybe we'll want to investigate just using OneInstancePerTest across the board in the future.

@bajohns
Copy link
Contributor Author

bajohns commented Aug 15, 2014

I am going to take care of the feedback this weekend. I am more than willing to convert the tests from OneInstancePerTest to the context object - this would make the changeset larger. The specs default behavior is OneInstancePerTest-like so the shortest path forward was OIPT.

Unless I hear otherwise - I will do the work to migrate this from OIPT -> Context object pattern.

@bajohns
Copy link
Contributor Author

bajohns commented Sep 1, 2014

@mosesn - finished reviewing your feedback. Please confirm that my changes meet your expectations.

Re: ignore showing up for flaky - here is the test output https://gist.github.com/bajohns/e1a03cad4b401ae5fd83

@mosesn
Copy link
Contributor

mosesn commented Sep 3, 2014

This is looking pretty awesome, thanks a ton! 👍

LGTM

@bajohns
Copy link
Contributor Author

bajohns commented Sep 3, 2014

Great to hear - would you like me to squash commits down to a single? That was my plan to conform to the commit message standard.

@mosesn
Copy link
Contributor

mosesn commented Sep 3, 2014

That would be rad, it would probably help minimize conflicts too. Could you make a new PR though, so the history for this branch is still one to reason about?


class EndToEndTest extends FunSuite {

case class MyStreamResponse(
Copy link
Contributor

Choose a reason for hiding this comment

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

This indentation's a bit weird. Let's use:

case class MyStreamResponse(
  httpResponse: HttpResponse,
  messages: Offer[ChannelBuffer],
  error: Offer[Throwable]
) extends StreamResponse {

@evnm
Copy link
Contributor

evnm commented Sep 3, 2014

LGTM. Just some dumb style nits.

@bajohns bajohns force-pushed the thrift-to-scala-test branch from b524ea8 to 16f2a50 Compare September 7, 2014 04:23
@bajohns
Copy link
Contributor Author

bajohns commented Sep 7, 2014

Took care of feedback from @evnm

I will create a final pull request based on these commits.

@bajohns
Copy link
Contributor Author

bajohns commented Sep 7, 2014

Squashed and rebased against current master - the complete work in one commit is here: #308

@maciejjaskowski
Copy link

Any chances for this PR being merged ?

@mosesn
Copy link
Contributor

mosesn commented Sep 25, 2014

We're in the process of doing it today! 🎩

@bajohns
Copy link
Contributor Author

bajohns commented Oct 4, 2014

Looks like the other was used for internal merge. Closing this.

Thanks again @mosesn and @evnm

@bajohns bajohns closed this Oct 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants