-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Expose test-infra services via Camel JBang #16773
base: main
Are you sure you want to change the base?
Conversation
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🤖 CI automation will test this PR automatically. 🐫 Apache Camel Committers, please review the following items:
|
Documentation is missing, I'll work on it, moreover, I'd like to discuss the output of the list and run command, any idea is welcomed, right now, I am just dumping some object to yaml |
6a3840a
to
27f532f
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 impressive. Thanks for this. Just a missing license found.
components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/AvailablePort.java
Show resolved
Hide resolved
f00e136
to
1eb6619
Compare
It would be good to make the list dump in a table like (camel catalog component) and have a description to go with. And maybe we can have since version as well when we add new test-infra modules then the tool knows what version of Camel includes that. |
Also I wonder if the test-infra is executed before camel-catalog, then we can maybe include the json dump in the catalog and include APIs there too. It makes it easier for other tooling to know without the need for the jbang commands. the json file can be copied into the src/generated/..../test-infra folder (see what else is there already) |
this can be done in new PRs I think a first cut is to make the |
|
||
@CommandLine.Command(name = "infra", | ||
description = "List and Run external services for testing and prototyping") | ||
public class InfraCommand extends CamelCommand { |
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.
In the future this command should not be yaml, but as in the comments more like camel catalog component
and we should not have jackson-yaml or other dependencies directly in camel-jbang-core
List<InfraCommand.TestInfraService> metadata; | ||
|
||
try (InputStream is | ||
= this.getClass().getClassLoader().getResourceAsStream("META-INF/test-infra-metadata.json")) { |
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.
In the future we should have this in camel-catalog, and in camel-tooling-model so we can use this API directly instead of jackson
Before we cut 4.10 LTS it would be good to avoid jackson yaml and make this first class in camel-catalog and camel-tooling-model |
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 really cool! I can barely wait to see all the cool things we'll be able to do with it.
InfrastructureService actualService = (InfrastructureService) Class.forName(serviceImpl) | ||
.getDeclaredConstructor(null) | ||
.newInstance(null); |
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.
Food for thought: I think it would be interesting if, in the future, we could pass arguments to the service we are starting, so that it would be possible to configure it in different ways (i.e.: think of something like providing a configuration class for a message broker that configures different protocols, auth mechanisms, behaviors, etc).
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.
yeah, that would be nice, so far most of the Services have an empty constructor with a default configuration, but some of them, sftp for example, need a security configuration.
I guess that we can add some information into the annotation, or the Service itself
import org.apache.camel.test.infra.common.LocalPropertyResolver; | ||
import org.apache.camel.test.infra.common.services.ContainerService; | ||
import org.apache.camel.test.infra.xmpp.common.XmppProperties; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@InfraService(service = XmppInfraService.class, serviceAlias = { "xmpp" }) |
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 may need to add a note about this in the test infra documentation (if we don't generate it automatically).
import org.apache.ftpserver.FtpServerFactory; | ||
import org.apache.ftpserver.listener.ListenerFactory; | ||
import org.apache.ftpserver.ssl.SslConfigurationFactory; | ||
|
||
@InfraService(service = FtpInfraService.class, serviceAlias = { "ftps" }) | ||
public class FtpsEmbeddedInfraService extends FtpEmbeddedInfraService { |
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 probably the only one I am a bit concerned about: by using an embedded service, we'll end up bringing all the dependencies used for that (this, for instance may expose us to a higher incidence of CVEs).
I don't think we must solve this now, but it's something I think we should consider for the future 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.
good point, same for Artemis, but I do not think we have many embedded implementations, most probably it can be refactored in the future to use testcontainers
Thanks for your inputs @davsclaus @orpiske @oscerd , in the latest commit I removed the jackson-yaml dependency in favour of asciitable for the list and json serialization for the Service properties, we do not know a priori what's inside a Service object (in some case can be a complex object), this is why a table cannot be used and I am still using json. But I added a flag
list output json run command output
@davsclaus regarding the camel-catalog, I do not know how easy it is, right now I am using camel-test-infra-all module that contain all the test-infra dependencies, the jandex index and executes the Mojo to generate the json file, probably the json file can be simply copied under |
ca58f79
to
1bf98e1
Compare
tooling/spi-annotations/src/main/java/org/apache/camel/spi/annotations/InfraService.java
Show resolved
Hide resolved
fc34baf
to
d586a51
Compare
12b9b7d
to
44394be
Compare
Add non-test-jar dependency for component test-infra Signed-off-by: Tom Cunningham <[email protected]> Revert "Add non-test-jar dependency for component test-infra" This reverts commit 954da18. Add non-test-jar dependency for component test-infra CAMEL-21452 Changes to xmpp/zookeeper CAMEL-21452 Decouple the infrastructure from the testing API CAMEL-21452 Decouple the infrastructure from the testing API aws azure cassandra chatscript consul couchbase couchdb elasticsearch etcd3 fhir ftp jms/artemis Create a test-jar that contain main and test classes Align all components let camel compile Fix langchain4j compilation Revert Jetty test-infra Rebase Execute test-infra with camel jbang Add Camel JBang command Fix camel jbang infra run let mvnd compile Sort import Remove yaml output in favor of json/table Add javadoc Use Camel standard workflow for generated sources test-infra JUnit decouple documentation Add Camel JBang Infra Docs test infra metadata json Use LinkedHashSet for ordering
44394be
to
4da5ff5
Compare
This PR adds two commands to Camel JBang that expose test-infra services via CLI
camel infra list
- Lists all the available servicescamel infra run $SERVICE
- Run any services available in the listIn order to do so, after decoupling junit from test-infra, the following was done: