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
[JBTM-3294] adding HTTP version headers for coordinator #1783
[JBTM-3294] adding HTTP version headers for coordinator #1783
Conversation
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/84/ |
LRA profile tests failed (http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/84/): LRA Test failed |
7b355fe
to
cfedc9a
Compare
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/85/ |
LRA profile tests failed (http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/85/): LRA Test failed |
|
||
return Response.status(status).build(); | ||
private void verifyVersion(String versionString) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems it should be encapsulated in the APIVersion class and reused for the client in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And do you mean to move the APIVersion
under service-base
module, right?
That could be an option. I was thiking the APIVersion is rather internal for the coordinator. How that could be reused for the client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Client is not going to also verify the version of the server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, I will address your point. Thanks.
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/api/JaxRsActivator.java
Outdated
Show resolved
Hide resolved
* Any bigger version is considered as unimplemented and unknown. | ||
* Any lower version is considered as older, implemented but deprecated and in case not supported. | ||
*/ | ||
public static final String LRA_API_VERSION_STRING = "1.0-RC1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would strongly suggest not tightening Narayana API to LRA API in this way. We can maybe in the future want to change our API async from the LRA releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not an intention in any way. But marking the initial API with version 1.0 sounds me reasonable.
Would be more understandable for you if I change the variable name to NARAYANA_LRA_API_VERSION_STRING
(+ changing the comment)? Or do you suggest some different way of approaching this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, to both points. Make it clear this is narayana specific and not tight to MP LRA in any way. Also why not use also micros? More flexibility for us to do updates in the future? So the first one should be IMO 1.0.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really for (at most) major.minor
.
I was inspired from other APIs and there are either v1
(e.g. github) or major.minor
(eg. facebook, M$) or timestamps (twillio). There are even APIs that does not support versioning as they consider it non-RESTful. A bit what I summarized is here: https://docs.google.com/document/d/1ecyNgFY-ywTSA7uVH7MhhkhaooEQ5tF-daHkYtOoKiw/edit#
If there isn't some good reason/example where it's used the micro versions I would go with major.minor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the suffix -RC1
. If 1.0 hasn't been released yet then just drop the suffix - the user will know he is using unreleased software so adding the suffix makes the code (on both the client and server ends) and policy more complex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I missed this point. It makes sense and I will remove the -RC1
handling code then.
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/domain/service/LRAService.java
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/internal/APIVersion.java
Outdated
Show resolved
Hide resolved
rts/lra/service-base/src/main/java/io/narayana/lra/logging/lraI18NLogger.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApi_1_0_IT.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApi_1_0_IT.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApi_1_0_IT.java
Outdated
Show resolved
Hide resolved
cfedc9a
to
2f0f7db
Compare
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/87/ |
LRA profile tests passed - Job complete http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/87/ |
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/internal/APIVersion.java
Outdated
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/internal/APIVersion.java
Outdated
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/internal/APIVersion.java
Outdated
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/internal/APIVersion.java
Outdated
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/api/Coordinator.java
Outdated
Show resolved
Hide resolved
rts/lra/service-base/src/main/java/io/narayana/lra/LRAData.java
Outdated
Show resolved
Hide resolved
rts/lra/service-base/src/main/java/io/narayana/lra/logging/lraI18NLogger.java
Outdated
Show resolved
Hide resolved
*/ | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class CoordinatorApi_1_0_IT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a test for incompatible versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests for incompatible versions are placed at the end of the test file. Is that enough or do you consider something more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still not clear what constitutes an incompatible version, the 3 versions rule is somewhat arbitrary.
How are those tests determining incompatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the client asks for version e.g. 3.0
then the coordinator replies either "I don't know that version" or "responds with the content that is implemented for version 3.0
. This test consider a client asking for version 1.0
, ie. when client asks for 1.0
will it get the right content? When somebody changes the code in future then 1.0
has to still be returning what was returning. If the code change will start returning something else the tests start to blame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not understand your response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not understand your question.
I understand it that you're asking how these tests finds incompatibility with version 3.0. They are not addressing it.
These tests address the compatibility with 1.0. The implementation has to be still working with 1.0 even when a new version is released. If the implementation works with 1.0 - which these tests ensures - we are still fine and compatible.
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApi_1_0_IT.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I tried to address all the comments or I added my perspective.
Those which I considered resolved I marked as 'resolved', if you think differently please just re-open.
I'm now pushing the version without rebasing on top of the current master. I need to do it in the next step.
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/api/Coordinator.java
Outdated
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/api/Coordinator.java
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/api/Coordinator.java
Outdated
Show resolved
Hide resolved
rts/lra/service-base/src/main/java/io/narayana/lra/LRAData.java
Outdated
Show resolved
Hide resolved
rts/lra/service-base/src/main/java/io/narayana/lra/logging/lraI18NLogger.java
Outdated
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/internal/APIVersion.java
Outdated
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/domain/service/LRAService.java
Outdated
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/domain/model/LRARecord.java
Outdated
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/api/Coordinator.java
Outdated
Show resolved
Hide resolved
APIVersion apiVersion = null; | ||
try { | ||
apiVersion = APIVersion.instanceOf(versionString); | ||
if (apiVersion.compareTo(currentAPIVersion) > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right that it could be good to have some guideline about this. The API compatibility is verified by the CoordinatorAPI_IT
test which checks if the API is working with 1.0
version.
When a change is done then a new test case should be created under a new test file. The way how the code determines the version could be various. I was discussing that when we talk about API and some summary is at https://docs.google.com/document/d/1ecyNgFY-ywTSA7uVH7MhhkhaooEQ5tF-daHkYtOoKiw/edit
I think it could be good to have the ideas documented somewhere in the repo. Do you think such poits belong to README
of the lra
module? Or maybe creating an API.adoc
that will be linked from the README
?
For now I added the API.adoc
document for this being documented.
2f0f7db
to
349bcf3
Compare
LRA profile tests failed (http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/91/): Narayana rebase on master failed. Please rebase it manually |
349bcf3
to
5b49630
Compare
LRA profile tests failed (http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/92/): Narayana rebase on master failed. Please rebase it manually |
5b49630
to
c2153a4
Compare
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/94/ |
LRA profile tests passed - Job complete http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/94/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am trying to grasp the implications of the scheme you have introduced:
- We might want to maintain an old version for a valued customer.
- It breaks the content negotiation pillar of REST principles.
- The version header is now hidden data and not discoverable which many REST APIs do support.
- The 3 version rule is arbitrary and not normal for REST APIs.
- The version on the request path needs to permit the caller to announce that it can supports multiple versions. The one selected by the implementation would then be indicated on the response path. This comment is referring to standard REST content negotiation where the caller indicates what kind of response it is capable of parsing.
== API definition as Open API document | ||
|
||
The Narayana LRA API is documented with Open API annotations at the java | ||
classes. The Open API definition needs to be published at the http://narayana.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will reference it in my PR for JBTM-2929 (Create LRA documentation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mention API versioning in my community docs update, sorry
rts/lra/API.adoc
Outdated
which demands (via HTTP header `Narayana-LRA-API-version`) version | ||
higher than the current API version (ie. the highest version that the API | ||
is created for). | ||
The unsupported version could be one that is already deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is the "support for at least two previous major versions" rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and we can rephrase. If you have idea to say it better I'm glad to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have already discussed supporting multiple versions. An "unsupported version is one that is not supported", which sounds empty of content, but if you indicate how the user can discover which version(s) are supported then it has meaning. You could then add something like "typically the last 3 versions are supported but older version may also be maintained".
You can indicate how the user can discover supported versions with text similar to (I am just showing this as an example of the kind of text that is unambiguous):
Multiple versions of the API may be supported in parallel. The current version can be discovered by:
- either looking at xyz (API.adoc or narayana.io website or wherever)
- and/or by sending a request without the version header. The response will include the version header > containing the latest supported version
To discover which versions are supported send request with a header that asks for an invalid version
(recall that you have specified valid formats for versions so the user knows how to request an invalid
format).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, agree. I took your text just the last part seems to me duplicate to the items above. I didn't include it to PR. If that was wrong understanding, let me know I will change the text.
rts/lra/API.adoc
Outdated
But for the start there is expected similar pattern like following | ||
|
||
NOTE: The verification of the highest supported API version could | ||
be part of the `ContainerRequestFilter`/`ContainerResponseFilter`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How we implement it is private to our implementation whereas this API.adoc is user facing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API.adoc was meant to be at the boundary of the developer and the outside world. It talks about code and best practices.
I can remove the code part and some points on internals. Would you prefer so?
I would probably move that text to wiki if it's fine with you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean why does the user need to know that the coordinator is using filters to validate the version header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that the document was meant to be read by Narayana developers as well. But I removed the part about code changes. Hopefully now it's related only for API users.
rts/lra/client/src/main/java/io/narayana/lra/client/NarayanaLRAClient.java
Outdated
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/api/Coordinator.java
Show resolved
Hide resolved
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/api/Coordinator.java
Show resolved
Hide resolved
* This class is not expected to be changed. The Narayana LRA API of version 1.0 is not expected to be changed.<br/> | ||
* When Coordinator changes the API there will be updated the API version for such change. | ||
* The new or changed behaviour belongs to a separate test class | ||
* which verifies the behaviour of the particular API version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And when a version is no longer supported will we remove the associated test class?
And are most incompatibilities addition of functionality. How is that handled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if the version is no longer supported then there is no reason having a test class which would be failing.
Incompatibilities could be rather changes in functionality, providing different enpoints, changing type of result etc. With such thing we need a new version and a new way of handling. And new test for such functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking more about the situation where we add functionality then it seems overkill to have to write a new test for it. Is inheritance and option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's not overkill. The API should be working as it is for 1.0 it's what the client expects to be working. My thinking is that if there is not a bug in test or implementation of 1.0 this should be reflecting the state of 1.0.
The inheritance is an option. Then when a new functionality is added then there could be tested that functionality not to be copied all from here. But it depends.
*/ | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class CoordinatorApi_1_0_IT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still not clear what constitutes an incompatible version, the 3 versions rule is somewhat arbitrary.
How are those tests determining incompatibility?
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApi_1_0_IT.java
Outdated
Show resolved
Hide resolved
You closed conversation #1783 (comment) prematurely. The recursion happens on the line where I made the comment ie |
|
We need documentation for each supported version. Is the OpenAPI document sufficient for this purpose? |
c2153a4
to
02d8bd3
Compare
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/99/ |
02d8bd3
to
99b8804
Compare
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/100/ |
ad ad ad) ad) I found one thing which I'm now unsure. Now we have the ad |
LRA profile tests passed - Job complete http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/99/ |
LRA profile tests passed - Job complete http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/100/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed minor code changes based on the review.
rts/lra/API.adoc
Outdated
|
||
The Narayana LRA REST API is expected to support for at least two previous | ||
`major` versions (ie. support is expected in parallel at least of versions 1.x, | ||
2.x and 3.x until the 4.0 is released). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand it. My perspective would be probably to go with 1 version backwards in parallel instead of 2 but on the other hand @mmusgrov has valid points to maybe prolong the support even longer.
There are different perspectives. Maybe the requirements could be adjusted based on changes happening in the code and the feedback from the community.
rts/lra/client/src/main/java/io/narayana/lra/client/NarayanaLRAClient.java
Outdated
Show resolved
Hide resolved
rts/lra/client/src/main/java/io/narayana/lra/client/NarayanaLRAClient.java
Outdated
Show resolved
Hide resolved
description = "API version string in format [major].[minor]-[prerelease]. Major and minor are required and to be numbers, prerelease part is optional.") | ||
}, | ||
headers = { | ||
@Header(name = LRAConstants.LRA_API_VERSION_HEADER_NAME, description = "Narayana LRA API version that processed the request") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used only for reference (in Coordinator
it's the 'ref = ...) - the components from
@Infoare not being shown directly by openapi (as far as I can say). The PR uses the reference from both from
@Headerand from
@Parameter`. So I needed to declare it for both.
rts/lra/coordinator/src/main/java/io/narayana/lra/coordinator/domain/service/LRAService.java
Show resolved
Hide resolved
} else if (preRelease != null && anotherVersion.preRelease == null) { | ||
result = -1; | ||
} else { | ||
result = preRelease.compareTo(anotherVersion.preRelease); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I made the string comparison intentional this way as the preRelease
is definitive for the release and it's good for proposals. There could be arbitrary string which makes sense for the proposal and for its verification. What's important is the major
, minor
.
@mmusgrov I made a comment previously checking for unofficial versions that was never addressed
I'm sorry I had to miss your question. May you, please, repeat your arguments for that? (I mean why the preRelease
is unnecessary?)
*/ | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class CoordinatorApi_1_0_IT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not understand your question.
I understand it that you're asking how these tests finds incompatibility with version 3.0. They are not addressing it.
These tests address the compatibility with 1.0. The implementation has to be still working with 1.0 even when a new version is released. If the implementation works with 1.0 - which these tests ensures - we are still fine and compatible.
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApi_1_0_IT.java
Outdated
Show resolved
Hide resolved
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/106/ |
5c5d3d8
to
c8fc322
Compare
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/107/ |
LRA profile tests passed - Job complete http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/106/ |
LRA profile tests passed - Job complete http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/107/ |
c8fc322
to
4d93f33
Compare
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/115/ |
@mmusgrov per our discussion I tried to address all the points in your comment #1783 (comment) |
LRA profile tests passed - Job complete http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/115/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put my comments inline. I also was unable to review the tests (CoordinatorApiIT.java, CoordinatorApiWrongVersionIT.java , ValidTestVersions.java, ValidTestVersionsRule.java), sorry. I found them too complicated. Perhaps we could get one of the other team members to look at those (ie Manuel or Mayank).
|
||
String apiVersionString = requestContext.getHeaderString(LRAConstants.LRA_API_VERSION_HEADER_NAME); | ||
|
||
// request contains multiple API version headers, using first one and printing a warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifying multiple versions can be a way for the client to indicate that it willing to process multiple different versions/formats. This means it is not a user error and there should be no logging of the situation. In fact the ascii doc is explicit here, quote:
If the caller is able to accept more than one version then the caller should include the header for each one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I would like to leave the logging for the investigation purposes if you are not strictly against such approach. Moving the log level to debug and changing the message.
== API definition as Open API document | ||
|
||
The Narayana LRA API is documented with Open API annotations at the java | ||
classes. The Open API definition needs to be published at the http://narayana.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mention API versioning in my community docs update, sorry
rts/lra/API.adoc
Outdated
in Narayana LRA coordinator service. | ||
This document is written for developer of Narayana LRA services. | ||
|
||
The version format is `major.minor`[`-preRelease`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You said you were going to remove the pre release handling code (#1783 (comment))
There are also other comments still left unaddressed from the first review round. I will comment below on the API.adoc and on the version header testsuite since I know that is where we had most discussion, ie I am not going to do an exhaustive review until I know that the comments from the first round have been discussed and/or resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this is my omission. The text about the preRelease should be removed. The required is major.minor
.
rts/lra/API.adoc
Outdated
|
||
The Narayana LRA REST API is expected to support for at least two previous | ||
`major` versions (ie. support is expected in parallel at least of versions 1.x, | ||
2.x and 3.x until the 4.0 is released). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you still haven't said that versions other than the last three may be supported.
Also how does the client discover which versions are supported? The natural place would have been to add it to the API.adoc section:
== Unsupported version errors
where multiple version headers are set in the response indicate which versions are supported. I have also added related comments below in section covering API.adoc.
rts/lra/API.adoc
Outdated
which demands (via HTTP header `Narayana-LRA-API-version`) version | ||
higher than the current API version (ie. the highest version that the API | ||
is created for). | ||
The unsupported version could be one that is already deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have already discussed supporting multiple versions. An "unsupported version is one that is not supported", which sounds empty of content, but if you indicate how the user can discover which version(s) are supported then it has meaning. You could then add something like "typically the last 3 versions are supported but older version may also be maintained".
You can indicate how the user can discover supported versions with text similar to (I am just showing this as an example of the kind of text that is unambiguous):
Multiple versions of the API may be supported in parallel. The current version can be discovered by:
- either looking at xyz (API.adoc or narayana.io website or wherever)
- and/or by sending a request without the version header. The response will include the version header > containing the latest supported version
To discover which versions are supported send request with a header that asks for an invalid version
(recall that you have specified valid formats for versions so the user knows how to request an invalid
format).
the same version with `-preRelease` part. | ||
|
||
Client may demand behaviour based on particular API version | ||
by providing HTTP header link:./service-base/src/main/java/io/narayana/lra/LRAConstants.java[`Narayana-LRA-API-version`] on the call. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You make the assumption that the value in the version header must exactly match the supported version, ie white space is significant. I guess that requirement is implicit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. But we can state it in the document. Or if you think the behaviour should be "less" strict.
Some text suggestion would be great in such case.
|
||
/** | ||
* The Narayana API version for LRA coordinator supported for the release. | ||
* Any higher version is considered as unimplemented and unknown. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also remark that valid version formats are defined in API.adoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added that note to the prior javadoc section.
"Reason: '%s'") | ||
void warn_move_lra_record(String failedUid, String exceptionMessage); | ||
|
||
@LogMessage(level = WARN) | ||
@Message(id = 25029, value = "Multiple version headers '%s' were provided for the request '%s'. " + | ||
"Consider to provide only one such header, there will be used value '%s' for now.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my earlier comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this.
@@ -53,15 +53,15 @@ | |||
* which is deployed when the app server starts. | |||
*/ | |||
public void handleAfterStartup(@Observes AfterStart event, Container container) throws Exception { | |||
if(!container.getName().contains(CONTAINER_NAME_RECOGNITION)) { | |||
if (!container.getName().contains(CONTAINER_NAME_RECOGNITION)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is clear that String LRA_COORDINATOR_DEPLOYMENT_NAME = "lra-coordinator";
is built into the deployment.
But it is not clear how String CONTAINER_NAME_RECOGNITION = "as-coordinator";
is set and used (for example it is not present in arquillian-wildfly.xml
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a bit of text in the definition of the field. I've extended it a little bit now.
import java.util.List; | ||
|
||
/** | ||
* Parameterized Arquillian JUnit runner adding the possibility to run parameterized JUnit test cases , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"parameterized JUnit" test cases sounds good but what are they?
I guess it is something to do with simplifying the version conformance test suite, maybe.
It is not at all clear what the purpose of this class is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parametrized JUnit tests are tests which runs several times with different parameters - e.g. something here https://www.tutorialspoint.com/junit/junit_parameterized_test.htm
This is an adjustment of the Arquillian runner to be capable to run in the similar manner. It's for a generic use. The point is to use it for versions right now but it can be used in different tests as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
I like that you introduced parameters in the Arquillian runner. Good idea :-)
4d93f33
to
969fec6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmusgrov I tried to address your inline comments. When you have time, please, take a look.
|
||
String apiVersionString = requestContext.getHeaderString(LRAConstants.LRA_API_VERSION_HEADER_NAME); | ||
|
||
// request contains multiple API version headers, using first one and printing a warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I would like to leave the logging for the investigation purposes if you are not strictly against such approach. Moving the log level to debug and changing the message.
the same version with `-preRelease` part. | ||
|
||
Client may demand behaviour based on particular API version | ||
by providing HTTP header link:./service-base/src/main/java/io/narayana/lra/LRAConstants.java[`Narayana-LRA-API-version`] on the call. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. But we can state it in the document. Or if you think the behaviour should be "less" strict.
Some text suggestion would be great in such case.
rts/lra/API.adoc
Outdated
in Narayana LRA coordinator service. | ||
This document is written for developer of Narayana LRA services. | ||
|
||
The version format is `major.minor`[`-preRelease`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this is my omission. The text about the preRelease should be removed. The required is major.minor
.
rts/lra/API.adoc
Outdated
|
||
The Narayana LRA REST API is expected to support for at least two previous | ||
`major` versions (ie. support is expected in parallel at least of versions 1.x, | ||
2.x and 3.x until the 4.0 is released). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry for this. I remember we talked about it but I forgot to include it.
rts/lra/API.adoc
Outdated
which demands (via HTTP header `Narayana-LRA-API-version`) version | ||
higher than the current API version (ie. the highest version that the API | ||
is created for). | ||
The unsupported version could be one that is already deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, agree. I took your text just the last part seems to me duplicate to the items above. I didn't include it to PR. If that was wrong understanding, let me know I will change the text.
.get() | ||
.get(QUERY_TIMEOUT, TimeUnit.SECONDS); | ||
.request() | ||
.header(LRA_API_VERSION_HEADER_NAME, LRAConstants.CURRENT_API_VERSION_STRING) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NarayanaLRAClient
is a library which can be used in Java for the call to coordinator. I would suggest to users to use it. But if a user wants to run a service which is not MP compatible or if other language is used then information about API versioning is a good idea.
|
||
/** | ||
* The Narayana API version for LRA coordinator supported for the release. | ||
* Any higher version is considered as unimplemented and unknown. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added that note to the prior javadoc section.
"Reason: '%s'") | ||
void warn_move_lra_record(String failedUid, String exceptionMessage); | ||
|
||
@LogMessage(level = WARN) | ||
@Message(id = 25029, value = "Multiple version headers '%s' were provided for the request '%s'. " + | ||
"Consider to provide only one such header, there will be used value '%s' for now.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this.
@@ -53,15 +53,15 @@ | |||
* which is deployed when the app server starts. | |||
*/ | |||
public void handleAfterStartup(@Observes AfterStart event, Container container) throws Exception { | |||
if(!container.getName().contains(CONTAINER_NAME_RECOGNITION)) { | |||
if (!container.getName().contains(CONTAINER_NAME_RECOGNITION)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a bit of text in the definition of the field. I've extended it a little bit now.
import java.util.List; | ||
|
||
/** | ||
* Parameterized Arquillian JUnit runner adding the possibility to run parameterized JUnit test cases , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parametrized JUnit tests are tests which runs several times with different parameters - e.g. something here https://www.tutorialspoint.com/junit/junit_parameterized_test.htm
This is an adjustment of the Arquillian runner to be capable to run in the similar manner. It's for a generic use. The point is to use it for versions right now but it can be used in different tests as well.
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/116/ |
@mayankkunwar @jmfinelli per Mike's comment, do you think you would have time to take a look at this PR and review the testcases (CoordinatorApiIT.java, CoordinatorApiWrongVersionIT.java , ValidTestVersions.java, ValidTestVersionsRule.java) and the handling around? |
LRA profile tests failed (http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/116/): narayana build failed |
969fec6
to
308a03f
Compare
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/117/ |
LRA profile tests passed - Job complete http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/117/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per @mmusgrov request, I reviewed the testing part of this PR. My main points are about using a tuple instead of an array of String to parameterise the Test Class CoordinatorApiIT.java
and using TestRule
instead of MethodRule
. The rest of the comments are about clarifying error messages and descriptions of test classes. Please, find comments below.
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/ValidTestVersionsRule.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/ValidTestVersionsRule.java
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/ValidTestVersionsRule.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/ValidTestVersions.java
Outdated
Show resolved
Hide resolved
import java.util.List; | ||
|
||
/** | ||
* Parameterized Arquillian JUnit runner adding the possibility to run parameterized JUnit test cases , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
I like that you introduced parameters in the Arquillian runner. Good idea :-)
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApiIT.java
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApiIT.java
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApiIT.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApiIT.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApiIT.java
Show resolved
Hide resolved
308a03f
to
e4875c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jmfinelli for your exhaustive review. I tried to address your notes. Please take a look.
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApiIT.java
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApiIT.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApiIT.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApiIT.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApiIT.java
Outdated
Show resolved
Hide resolved
...ra/test/basic/src/test/java/io/narayana/lra/arquillian/api/CoordinatorApiWrongVersionIT.java
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/ValidTestVersions.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/ValidTestVersionsRule.java
Outdated
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/ValidTestVersionsRule.java
Show resolved
Hide resolved
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/api/ValidTestVersionsRule.java
Outdated
Show resolved
Hide resolved
Started testing this pull request with LRA profile: http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/120/ |
LRA profile tests passed - Job complete http://narayanaci1.eng.hst.ams2.redhat.com/job/btny-pulls-narayana/PROFILE=LRA,jdk=jdk8.latest,label=linux/120/ |
@jmfinelli thanks for the review and the approval :-) |
https://issues.redhat.com/browse/JBTM-3294
I'm publishing this withouth having finished similar work which I would like to do with
RecoveryCoordinator
. I hope forCoordinator
this is acceptable to be discussed and hopefully merged.!MAIN !CORE !QA_JTA !QA_JTS_JDKORB !QA_JTS_OPENJDKORB !QA_JTS_JACORB !BLACKTIE !XTS !PERF NO_WIN !RTS !AS_TESTS !TOMCAT !JACOCO
LRA
/cc @xstefank