-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add the @TestTransaction annotation #11798
Add the @TestTransaction annotation #11798
Conversation
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 like the idea!
Added some comments...
test-framework/common/src/main/java/io/quarkus/test/TestTransaction.java
Outdated
Show resolved
Hide resolved
@@ -96,6 +114,40 @@ public void build(NarayanaJtaRecorder recorder, | |||
recorder.setDefaultTimeout(transactions); | |||
} | |||
|
|||
@BuildStep | |||
void testTx(LaunchModeBuildItem lm, BuildProducer<GeneratedBeanBuildItem> generatedBeanBuildItemBuildProducer) { |
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.
Hm, so you generate an interceptor class because you can't add the @TestTransaction
interceptor binding, right? Ok, that's probably the simplest solution. However, I'd move as much as possible logic to the parent class, i.e. injection field of UserTransaction
and the whole @AroundInvoke
method. If it doesn't work then we have a bug in ArC...
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 didn't work, although I did not have time to look into why.
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 it's because the parent class is not part of the index?
WDYT about flushing the |
f7b47c8
to
cda28c3
Compare
Done |
cda28c3
to
3a2e670
Compare
This allows you to run tests in a rollback only transaction. Fixes quarkusio#6463
@stuartwdouglas FYI I'm going to rebase this PR, resolve conflicts and find out why the logic in the parent class did now work... |
- add basic support for interceptor's inheritance - other unsupported use cases are described here: quarkusio#11942
3a2e670
to
a2d057f
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.
Looks good from my POV.
|
||
static final List<TestTransactionCallback> CALLBACKS; | ||
|
||
static { |
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 having considered my flush()
-suggestion. Very cool approach with this new TestTransactionInterceptor
!
I am wondering whether this block could kick in cases where it is not really needed? Usually ServiceLoader
calls are not super-cheap.
I used to apply https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom in my projects but I don't know whether this would make any difference here.
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.
Hm, the callbacks are only loaded once per test config...
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.
That said, we could easily turn the list into a io.quarkus.arc.impl.LazyValue<List<TestTransactionCallback>>
...
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 current code is fine. ServiceLoader is expensive in terms of 'don't do this every request so you are doing it tens of thousands of times per second', its fine for 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.
Ok, thanks for your feedback.
I suppose this is not going to be included in 1.8.0.Final? |
This allows you to run tests in a rollback only transaction.
Fixes #6463