Skip to content

[PR for discussion] Showing Reactive Streams TCK, proposing some #407

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

Closed

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Jan 31, 2018

The purpose of this PR is to show how to start using the reactive-streams tck (documented here: https://github.com/reactive-streams/reactive-streams-jvm/tree/master/tck ) to validate existing RS implementations in this library. Reactive streams implementations must pass the TCK in order to ensure good inter-op between all libraries.

This PR will fail, as not all implementations are currently compliant.

I can help making them compliant, but wanted to reach first with this preview PR to ask if you'd like to separate our the TCK tests into a separate project, or if you're ok keeping them side by side the other ones like this? They are a bit slow sometimes, as they test many runs, and also await for "things did not happen" etc.

Running the tests will show which specification rules have been violated which should help getting the library compliant pretty quickly, esp as the implementations I've seen are pretty simple so far.

Let me know if you'd want more assistance making all the implementations valid, or if you'd like to take the TCK for a spin yourself first -- I've seen you're aware of the specification requirements in some TODO/FIXME's, so perhaps this is something you've not yet gotten to yet?

Hope this helps, let me know what would be the best way to help you out here.

Refs #406 and #405

// FIXME: onSubscribe is user code, and could be ill behaved, as library we should protect from this,
// FIXME: This is covered by spec rule 2.13; proposal:
// As per 2.13, this method must return normally (i.e. not throw).
// try {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

guards such as this are required by the spec, they're not hard to add. The TCK will fail and show which rule has been broken in the existing implemenations pointing these out.

@@ -82,6 +82,7 @@ public ResponseT complete() {
/**
* {@link Subscriber} implementation that writes chunks to a file.
*/
// FIXME cover with Reactive Streams TCK, looks ok from a first brief look, but could be missing some edge cases
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is not (at least yet), intended to be merged, please assume those are just markers for myself to know where/how many implementations are there and what we should cover with tests.

Copy link
Contributor Author

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Added some comments in-line.

Mostly awaiting info if you want to give it a shot to fix the spec violations on your own using the TCK or would ask for some more help with it.

Thanks in advance!

@@ -72,7 +72,7 @@ static String userAgent() {

ua = ua
.replace("{platform}", "java")
.replace("{version}", VersionInfo.SDK_VERSION)
.replace("{version}", "MOCK")//VersionInfo.SDK_VERSION)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FIXME: had a compile error here, remove in case we'd intend to merge this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

If you run a mvn generate-sources -pl :core it should generate the VersionInfo class for you and add it to the generated-sources directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

public Publisher<ByteBuffer> createFailedPublisher() {
return AsyncRequestProvider.fromFile(fileDoesNotExist.toPath());
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

simple usage of the TCK. If you want me to submit a complete PR for these things, I'd suggest we use JimFS here, so we can avoid real IO in the testsuite. Would it be ok to include it in the test dependencies? https://github.com/google/jimfs

We're using jimfs for testing such Publishers etc in Akka and it's been pretty reliable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't have any problems using this from a licensing perspective (it's Apache 2.0) - and I'd be OK adding as long as it's only in the test scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent, thanks for confirming

@kiiadi
Copy link
Contributor

kiiadi commented Jan 31, 2018

@ktoso I like the idea of including tests that validate that we are in compliance with the reactive spec. When you say slow - what are we talking about here? ideally unit tests would be fast and not perform I/O - if this is the case I'd say they could run as part of the regular mvn install lifecycle. However if they are slow then we should put them in the it source folder and have them run as integration tests.

<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
<version>${reactive-streams.version}</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

It's interesting that you had to explicitly pull this in - was this required or was it just a best practise thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly just since I wanted to be on 1.0.2 and I think the Netty adapter library is on previous version. I will double check. It is backwards compatible, so we can use a newer version here (both semantically and binary)

@@ -72,7 +72,7 @@ static String userAgent() {

ua = ua
.replace("{platform}", "java")
.replace("{version}", VersionInfo.SDK_VERSION)
.replace("{version}", "MOCK")//VersionInfo.SDK_VERSION)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you run a mvn generate-sources -pl :core it should generate the VersionInfo class for you and add it to the generated-sources directory.

@ktoso
Copy link
Contributor Author

ktoso commented Feb 3, 2018

Got a long inter continental flight coming up now so I’ll work on this a bit more in flight I think.

@ktoso
Copy link
Contributor Author

ktoso commented Feb 3, 2018

When you say slow - what are we talking about here? ideally unit tests would be fast and not perform I/O - if this is the case I'd say they could run as part of the regular mvn install lifecycle.

I'd say "tens of seconds". We can avoid real IO thanks to Jimfs, so I'll do that and see how long things take. Will move them to it if indeed still slow -- likely a good idea anyway. The reason they're slow is mostly that they have many checks in the form of "wait 100ms hoping that no more signals happen" etc. (checking that no stray, or "late" onNext signals are sent, after stream completion etc)

@ktoso
Copy link
Contributor Author

ktoso commented Feb 3, 2018

Worked a bit on this during my flight; not complete yet, more cleanups/fixes to follow.

@joost-de-vries
Copy link

@ktoso I made the FileAsyncRequestPublisherTckTest pass. (Apart from required_spec317_mustNotSignalOnErrorWhenPendingAboveLongMaxValue since creating a file with int max_value blocks is not an option)
And fixed the merge conflicts. You can find my fork here.
@kiiadi Is this sufficient for merging?

@dagnir
Copy link
Contributor

dagnir commented May 30, 2018

@ktoso LGTM! Thank you for helping us get started with this! Happy to merge this in! If you would, could you update you rebase your branch against the latest tip of master?

@dagnir
Copy link
Contributor

dagnir commented Jun 12, 2018

Closing this since the work here was incorporated into #519.

@dagnir dagnir closed this Jun 12, 2018
aws-sdk-java-automation pushed a commit that referenced this pull request Feb 8, 2019
…f0fc7276

Pull request: release <- staging/4bbfb7ac-0e2a-494d-bf52-2876f0fc7276
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