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

CAMEL-18201 Enhance CamelTestSupport to turn off context stopping #7813

Merged

Conversation

JiriOndrusek
Copy link
Contributor

fixes https://issues.apache.org/jira/browse/CAMEL-18201

This PR adds an option to turn off the context stopping. It is possible by junit5's ConfigurationProperty (which falls back also to system variable - used in the junit test). If context does not stop automatically method doSetUp is not called if context already exists.

I added 2 tests to cover both option values (off and on).

@github-actions
Copy link
Contributor

⚠️ This PR changes Camel components and will be tested automatically.

@JiriOndrusek
Copy link
Contributor Author

WDYT? @davsclaus This change will allow camel quarkus to run CamelTestSupport based tests (See apache/camel-quarkus#3511) and will allow users to reuse old camel tests in camel-quarkus JVM mode (without need of bigger refactor)..

@davsclaus
Copy link
Contributor

Hmmm so this seems a bit like the camelContextPerClass functionality that is already there.
And the name of this option is maybe a bit unclear as it will reuse the previous context in the following tests.

@JiriOndrusek
Copy link
Contributor Author

Functionality may look similar but it is not. PerClass functionality will stop context after each class. This option won't stop context after each class, it will never stop context.

As for the name, I see that it may be a bit unclear, what about NEVER_STOP_CONTEXT/DONT_STOP_CONTEXT or SHARE_CONTEXT_FOR_ALL_TEST/SHARE_CONTEXT?

@davsclaus
Copy link
Contributor

Maybe what CEQ needs is being able to override some protected methods in CamelTestSupport to control more fine grained what CEQ needs to do in the doSetup and teardown methods.

Then CEQ can override these methods and do something different.

Maybe the existing doStopCamelContext and setup is useable as-is, eg you can try to implement this in CEQ and then override doStopCamelContext to not stop camel, or only stop when really needed. And doSetup you can then skip calling super if already started.

Then maybe this is possible to just do in CEQ only and keep camel core as-is

@JiriOndrusek
Copy link
Contributor Author

JiriOndrusek commented Jun 17, 2022

Overriding method in CEQ was me preferred solution, unfortunately method I need to override is private static private static void doStopCamelContext(

If making it non-static protected is a better solution, I will use that. (I chose a configurable option, as I saw similar options there)

If you agree, I'll modify the PR to change method signature and allow overriding of it.

@davsclaus
Copy link
Contributor

Yeah its better to make the method protected

@JiriOndrusek JiriOndrusek force-pushed the camel-test-support-not-stopping-context branch 2 times, most recently from 6dacb4f to bd510e5 Compare June 17, 2022 12:00
@JiriOndrusek
Copy link
Contributor Author

Thank you! I change only 2 signatures and keep 1 test covering the overriding of both methods.

@github-actions
Copy link
Contributor

✔️ Finished component verification: 0 component(s) test failed out of 1 component(s) tested

@davsclaus
Copy link
Contributor

LGTM great work @JiriOndrusek

@github-actions
Copy link
Contributor

❌ Finished component verification: 1 component(s) test failed out of 14 component(s) tested

1 similar comment
@github-actions
Copy link
Contributor

❌ Finished component verification: 1 component(s) test failed out of 14 component(s) tested

@davsclaus
Copy link
Contributor

There seems to be 1 error now

Failed components/camel-test test test: 14 verified / 1 failed

@JiriOndrusek
Copy link
Contributor Author

I'll check it.

@JiriOndrusek
Copy link
Contributor Author

I see that problem is happening in the camel-test, therefore it will be probably caused by the PR.
I can not find any error log and my local execution ends successfully.
Do ou know how to find any information about the failure?

I see in the log:

2022-06-17T13:21:21.9391844Z Logging test to /home/runner/work/camel/camel/automated-build-log/components-camel-test.log
2022-06-17T13:21:49.0895677Z Failed components/camel-test test test: 14 verified / 1 failed
2022-06-17T13:21:49.0913884Z There is no log file to copy at target/camel-test-test.log
2022-06-17T13:21:49.0999844Z ##[error]Process completed with exit code 1.

My local execution ends with

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Camel :: Test :: Parent 3.18.0-SNAPSHOT:
[INFO] 
[INFO] Camel :: Test :: Parent ............................ SUCCESS [  1.214 s]
[INFO] Camel :: Test (deprecated) ......................... SUCCESS [ 15.547 s]
[INFO] Camel :: Test :: CDI (deprecated) .................. SUCCESS [  4.576 s]
[INFO] Camel :: Test :: JUnit5 ............................ SUCCESS [ 15.502 s]
[INFO] Camel :: Test :: CDI :: JUnit5 ..................... SUCCESS [  6.283 s]
[INFO] Camel :: Test :: Spring (deprecated) ............... SUCCESS [ 26.590 s]
[INFO] Camel :: Test :: Spring :: JUnit5 .................. SUCCESS [ 29.012 s]
[INFO] Camel :: Test :: Main :: JUnit5 .................... SUCCESS [  8.806 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:47 min

@davsclaus
Copy link
Contributor

No I dont know how to grab the test logs, @otavioprado knows how-to

@JiriOndrusek JiriOndrusek force-pushed the camel-test-support-not-stopping-context branch from bd510e5 to a4afdbc Compare June 17, 2022 14:10
@JiriOndrusek
Copy link
Contributor Author

JiriOndrusek commented Jun 17, 2022

I've found the reason in https://github.com/apache/camel/actions/runs/2515347416

[ERROR] Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.17.1:validate (validate) on project camel-test-junit5: File '/home/runner/work/camel/camel/components/camel-test/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/CamelTestSupporOneContextForAllTest.java' has not been previously formatted.  Please format file and commit before running validation! -> [Help 1]

fixed by running mvn process-resources -Pformat

@github-actions
Copy link
Contributor

✔️ Finished component verification: 0 component(s) test failed out of 15 component(s) tested

@davsclaus davsclaus merged commit 62fb557 into apache:main Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants