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

!tck #12 Migrated TCK to plain Java #15

Merged
merged 2 commits into from Apr 14, 2014

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Apr 14, 2014

Migrated TCK to plain Java.
Had to replicate trait behaviour by delegating manually, so there's a bit more duplication (Processor test), but we're not locked to a concrete Scala version.

Please review and I'll rename the classes Java* => * and remove the Scala versions of them - then let's merge.

// cc @viktorklang

libraryDependencies += "org.testng" % "testng" % "5.14.10"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will add auto autoScalaLibrary := false when removing the Scala versions of the classes

@ktoso
Copy link
Contributor Author

ktoso commented Apr 14, 2014

Implementing from Scala now looks like this:

class ActorProducerTest(_system: ActorSystem, env: JavaTestEnvironment, publisherShutdownTimeout: Long)
  extends JavaPublisherVerification[Int](env, publisherShutdownTimeout)
  with WithActorSystem with TestNGSuiteLike {

  implicit val system = _system
  import system.dispatcher

  def this(system: ActorSystem) {
    this(system, new JavaTestEnvironment(Timeouts.defaultTimeoutMillis(system)), Timeouts.publisherShutdownTimeoutMillis)
  }
  def this() {
    this(ActorSystem(classOf[ActorProducerTest].getSimpleName, AkkaSpec.testConf))
  }

This is in order to make defaultTimeoutMillis dilated (so the actor system must come in from the constructor, and not from a trait.

@viktorklang
Copy link
Contributor

Just before I go through the code; have we've verified that the current akka-streams impl passes the migrated TCK?

@ktoso
Copy link
Contributor Author

ktoso commented Apr 14, 2014

Yes, I've got it migrated to use the new TCK and it's all green.
Will pull request there once this one is OK-ed (I want to trim the Java... prefixes from the classes here).

@viktorklang
Copy link
Contributor

Ok, just wanted to make sure that it flies :)


T x = nextT();
sendNext(x);
expectNextElement(sub, x);
Copy link
Contributor

Choose a reason for hiding this comment

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

These three lines seem common enough to warrant a helper

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1, added sendNextTFromUpstream

@ktoso
Copy link
Contributor Author

ktoso commented Apr 14, 2014

Updated PR

* Override in your test if you want to enable completed-state verification.
* If you don't override the respective tests will be ignored.
*/
public Publisher<T> createCompletedStatePublisher() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these should be abstract methods so the implementor has to implement them. i.e. no hidden surprises.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make abstract but keep the style of return null == ignore these tests? Akka streams don't use the error publisher for exampe

Copy link
Contributor

Choose a reason for hiding this comment

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

Document on the method what one should do. :)

@smaldini
Copy link
Contributor

Can't wait for this :) thanks a lot.

new TestSetup(env, testBufferSize) {{
TestEnvironment.ManualSubscriber<T> sub = newSubscriber();
sub.cancel();
expectCancelling();
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw, how does expectCancelling know which Subscriber we expect to get cancelled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test does something slightly different - so if all down-stream's are cancelled, we call cancel on the upstream one. (so expectCancelling actually only cares if the ManualPublisher decides to cancel it's upstream subscription).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, that's pretty hard to see from just looking at the code.

@patriknw
Copy link
Contributor

LGTM, great work @ktoso


// then
for (String publisherTest : publisherTests) {
String msg = String.format("%d tests in %s did not include %s!", processorTests.size(), IdentityProcessorVerification.class, publisherTest);
Copy link
Contributor

Choose a reason for hiding this comment

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

This output message doesn't seem to make sense for the processorTests.size(), am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, read as "[n tests, in the "delegator test suite] test in "delegator" did not include [expected test to be delegated to]"; seems ok to me? // Extracted this loop as method.

@bantonsson
Copy link

LGTM

private static final Optional NONE = new Optional() {
@Override
public Object get() {
throw new RuntimeException(".get call on None!");
Copy link
Contributor

Choose a reason for hiding this comment

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

NoSuchElementException :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

* In which we trade off less-DRY in order to be scala-version independent.
* TCK does not depend on Scala at all now.
* Added tests testing the TCK, if we properly delegate all tests from Processor -> {Producer, Subscriber}
* Made SBT run the TestNG test
* Made the "pending" tests (decided by returning null in the special create... methods) actualy visible as PENDING to testNG
@ktoso
Copy link
Contributor Author

ktoso commented Apr 14, 2014

Pushed final squash which addresses all of Viktor's latest feedback, so should be good to go (also tested akka-streams with it and we're green). Highlights include:

  • some string interpolation was left in the migrated Java code - is now String.format
  • by throwing SkipException() we're able to let TestNG know that a test is "pending". Tested it in akka-stream and it works as expected (versus previously we'd just "not run" these tests)
  • Replaced instances of == with equals where checking what a stream produced - no one forces a stream to return the same instance of something
  • Includes test to check that the Processor test delegates to all test methods in Subscriber and Producer
  • sbt now runs this test in TCK

Thanks for the awesome code review!

@viktorklang
Copy link
Contributor

Fantastic work, Konrad!

LGTM 👍

@viktorklang
Copy link
Contributor

I guess we're awaiting a couple of extra +1's before we merge! :-)

@rkuhn
Copy link
Member

rkuhn commented Apr 14, 2014

I’m trying out the publishing and cannot build the javadoc due to source duplication, will need to fix the build. But I’ll open a new PR for that once this one is merged, which I’d therefore like to do soon-ish.

@viktorklang
Copy link
Contributor

Excellent, just in time!

@ktoso
Copy link
Contributor Author

ktoso commented Apr 14, 2014

@rkuhn what command is failing? I worked using publishLocal, that built javadoc well too, hmm...

@rkuhn
Copy link
Member

rkuhn commented Apr 14, 2014

I happened to have the old generated .java files still lying around and could therefore reproduce what @smaldini had seen last week, and this time I noticed the duplication in the logs. It turns out that we can now just remove all genjavadoc stuff, you can also do that on this PR. (i.e. delete 1 file and 2 lines)

@viktorklang
Copy link
Contributor

Sounds great

@ktoso
Copy link
Contributor Author

ktoso commented Apr 14, 2014

Included @rkuhn's javadoc patch; Waiting for last LGTMs / merge and we'll release

@rkuhn
Copy link
Member

rkuhn commented Apr 14, 2014

Will merge and publish a 0.3 now (since the first sync to Maven Central can take a lot longer). We can in any case publish a 0.4 if there are things to be fixed.

rkuhn added a commit that referenced this pull request Apr 14, 2014
@rkuhn rkuhn merged commit b42fec3 into reactive-streams:master Apr 14, 2014
@viktorklang
Copy link
Contributor

Perfect. Great turn-around time for this one, guys!

@ktoso ktoso deleted the 12-port-tck-to-java-ktoso branch April 14, 2014 20:54
@rkuhn rkuhn mentioned this pull request Apr 15, 2014
@ktoso
Copy link
Contributor Author

ktoso commented Apr 16, 2014

lol :) Ok, will make those public; (in a few minutes)

@sirthias
Copy link

Great, thanks, Konrad!

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.

None yet

9 participants