-
Notifications
You must be signed in to change notification settings - Fork 352
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
Testing Camel K integrations #600
Comments
@christophd FYI |
@davsclaus, @oscerd, @lburgazzoli, @astefanutti, @valdar, @jamesnetherton any ideas/suggestions? |
I have started to give some thought to it. I really like the idea of test code to be part of the deployment, because then the test framework is able to interact with other services as part of the K8s platform. This is especially useful when the test code itself needs to provide a mocked service as part of the test. This mocked service could be provided as part of K8s as any other service.
I once put a little POC together (as part of the test framework Citrus https://github.com/citrusframework/citrus-remote-demo) where the integration tests (e.g. based on JUnit and Citrus) get deployed to Docker/K8s as part of a small web application. The web application (built as fat jar) provided a REST API to execute tests and to get its reports. The tests can also auto start upon deployment. The POC also included a Maven plugin to create the test web application, execute the tests as part of the Maven build lifecycle and collect the reports.
I think the answer is yes. You loose the ability to invoke the integration via direct endpoint as well as using the mock endpoint though as you would probably do with unit tests. But in general the integration should be invoked either via timer or some accessible endpoint I believe. All outbound calls to 3rd party services can be mocked with frameworks like Citrus.
I can imagine the test code to be a Camel DSL, too. That would be most comfortable for the user because it is not yet another DSL (e.g. Citrus) to learn. Integration into the IDE is quite important in my eyes. You get a lot of integration with tools and IDE for free when being compliant with frameworks like JUnit. JUnit5 provides a brilliant way to incorporate own frameworks and extensions.
I think Citrus (https://github.com/citrusframework/citrus) can help to mock messaging transports and verify message content with Json, XML, plaintext validators. As already mentioned JUnit5 is a wonderful base framework with wide spread tools and IDE support. In general BDD (Behavior Driven Development) principles can help as testers and managers love it |
After some brainstorming here and there I'd proceed with a POC about that. We want to remain without project structure for camel k integrations, to keep everything simple and portable. For this reason, testing frameworks requiring a structure and complex dependencies are not well suited. We want to focus on integration testing, so a framework like Citrus is well suited for this and Citrus already supports many kind of Gherking statements. We'll add some of ours. E.g. taken from Citrus doc:
Tests can be very simple or also complex with this approach. Although it won't reach the complexity allowed in a Java test class. We can create a "IntegrationTest" custom resource to drive the test. Tests will be still using Citrus under the hood and they'll be driven by the operator. This way the test is independent on any CLI but we can still obtain the state of the tests from CLI. Having them as resources also help integrating tests with a CI.
|
We could then report test results through conditions |
All this ended up in YAKS |
An attendee at a recent conf asked for a way to test Camel K integrations.
Tests that should be done on a Camel K integration are not unit tests, they should involve external systems as well. Maybe they will run on a special environment where external services are mocked, but we should define a way to declare testing together with the integration.
I'm thinking to the following scenario:
-test
is recognized by default)kamel test integration.groovy
Questions are:
@davsclaus, @oscerd, @lburgazzoli, @astefanutti, @valdar, @jamesnetherton
The text was updated successfully, but these errors were encountered: