-
Notifications
You must be signed in to change notification settings - Fork 194
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
CamelTestSupport style of testing #3511 #3847
Conversation
Just to let you know that in case of |
@essobedo Thanks for showing me the latest approach used in camel. My POC aims to help users migrating the old tests extending |
@JiriOndrusek I see it makes sense indeed. It was just in case it could be helpful to know sorry for the noice 😄 |
b22e387
to
42f0630
Compare
I think we have an option to disable the autoStart? Lines 75 to 82 in f8604b5
|
@zhfeng Thanks for pointing to the config! I'll try to integrate it into the PoC |
@JiriOndrusek But I'm not very sure that the option is effect since we have no any test for bootstrap options. :( |
I think we should create a new top level module for this stuff. I see So maybe we do like Quarkus does and have a Agree with @essobedo that annotation driven tests would be good to have eventually. The more consistency we have with the other Camel runtimes, the better it is for our users. But lets take things one step at a time.... |
@jamesnetherton creating a Using annotation driven tests seems to be nice. I still think that this mid-step (supporting old testing approaches for migration of tests) makes sense. |
I'd prefer to not add suffixes to the artifact ids and cover native not being supported with documentation and / or code that can detect that scenario. |
42f0630
to
6a0a509
Compare
@jamesnetherton I reworked the draft and put the sources into It's possible to not use
I'm not sure how find all features which may be affected but not-restarting came context. Therefore introducing this functionality for the test would be 100% covering solution (in comparison to clear the context in quarkus test callbacks) |
Change in Camel |
6a0a509
to
393ee4d
Compare
e22eb3f
to
1ce446f
Compare
1dea37e
to
303c2ce
Compare
a46daef
to
0ceae66
Compare
0ceae66
to
c0828a0
Compare
@jamesnetherton The selection of tests, which are currently in the draft, works -> all of them are successful.
I'm leveraging the fact, that I can "suspend" and "resume" camel context. If context is suspended, camel skips several configurations (like start of the routes) because camel "thinks" that context is not started. I can then resume context and make it work even when context was in reality not stopped. I know that this is still a PoC, but it seems promising. I personally think that i need to run more tests using I plan to create copies of "an interesting tests" from camel (usually core ones), which could "break" this feature - to see how stable it is. |
Is there already a piece of user guide that would sketch how to use this? I have not seen it in this PR, but maybe I have just overseen it because there are many files. |
That seems like a decent approach to me. I'm guessing you've already done this, but there are a bunch of test framework tests in Camel that we could probably take inspiration from in these modules: https://github.com/apache/camel/tree/main/components/camel-test BTW if you want the CI build to stay stable, I'd avoid |
Missing doc is another issue here, I forgot to write it into my comment. Thanks for noticing. I'll write the documentation. |
df9faa0
to
cc6a69f
Compare
test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/TestConfigSourceFactory.java
Outdated
Show resolved
Hide resolved
cc6a69f
to
fc23601
Compare
I know that this PR brings a lot of changes, but from my PoV it is ready to merge. |
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.
Some suggestions inline
test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java
Show resolved
Hide resolved
test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java
Outdated
Show resolved
Hide resolved
test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java
Outdated
Show resolved
Hide resolved
test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java
Outdated
Show resolved
Hide resolved
test-framework/junit5/src/main/java/org/apache/camel/quarkus/test/CamelQuarkusTestSupport.java
Outdated
Show resolved
Hide resolved
@ppalaga Thanks for the above comments. I'll incorporate it into the PR. |
...t5-extension-tests/src/test/java/org/apachencamel/quarkus/test/extensions/HelloResource.java
Outdated
Show resolved
Hide resolved
6e166bb
to
5dec04e
Compare
Majority of the issues is fixed, I'll close appropriate conversations tomorrow morning. |
d904a5b
to
9239d22
Compare
I closed appropriate conversations and kept 3 opened - with my questions.
|
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<runOrder>alphabetical</runOrder> |
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.
@ppalaga There are 2 tests, which asserts whether methods like afterAll
was called (and the number of their executions) . In camel component code the test starts runnable and logs an error if there is a problem after a while (see test
Unfortunately there is no way how to fail a test with such failure.
I kept the same code in our tests
- and I created second test, which is alphabetically after the first one (
CallbacksPerTestFalse01Test
andCallbacksPerTestFalse02Test
). The second test verifies the tmp files (files in /target/) and fails in case that there is a problem. For that purpose I configuredmaven-surefire-plugin
to use alphabetical order of test classes. I know that this is not standard approach, so I'm pointing at it, whether it is acceptable.
I found a small difference between
The closest method to use with similar use-case in camel-QuarkusTestSupport`` is
I'll add the difference into the documentation. I just wanted to point it out. |
9948ee4
to
f0886ac
Compare
f0886ac
to
9d29288
Compare
@JiriOndrusek Are we done with changes now? |
Yes, the last 2 changes was the fix pointed by my last comment. Sorry for not stating clearly, that work is finished. |
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 great work, @JiriOndrusek !
Many thanks @JiriOndrusek for the great work ! |
fixes #3511
This is a draft with a simple POC to start a discussion about camel way of testing in camel-quarkus.
I tried to add a functionality of
CamelTestSupport
into the camel-quarkus.I created our own annotation
CamelQuarkusTest
, which should be helpful for creating some Processors to enhance test functionality, but in this POC it is unused.I copied some tests from the camel core tests (from this module/package repo), which should cover bigger part of the required functionality.
As you can see in the draft, each test has to be annotated with
@CamelQuarkusTest
and should extendCamelQuarkusTestSupport
.There are a few limitations:
@TestProfile
, which instructs Quarkus to restart the engine before running the test.BeforeEachCallback
. added by this draft)UseOverridePropertiesWithPropertiesComponentTest
)Injectionpointsprocessor
to detect duplications of the synthetic beans, produced by tests. This code is just a "basic" POC to show theway of proper solution. (We can not register synthetic beans for each tests, becauseall of them are part of the context and there can be no duplicated beans. It is not possible to produce different beans with the same name)Some little changes has to be done also on camel side (to allow overriding of some test methods). For the POC, following changes are necessaery: apache/camel@camel-3.17.0...JiriOndrusek:camel-quarkus-test-support
WDYT? @ppalaga @jamesnetherton @zhfeng @aldettinger
I thinng that this "feature" is quite complicated and should be discussed. In this POC I tried to show one possible way of resolving some problems. From my POV similar approach should work and should be helpful for users. In case we can add the full stop and start capabilty of the camel context, this would help this case a lot. Even without it, users should be able to use a big part of the functionality of camel test support. In case that tests are written safely, there might not be necessary to use
@TestProfile
and therefore avoid the performance issues.