You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "Croway (via GitHub)" <gi...@apache.org> on 2025/01/10 11:13:26 UTC

[PR] Expose test-infra services via Camel JBang [camel]

Croway opened a new pull request, #16773:
URL: https://github.com/apache/camel/pull/16773

   This PR adds two commands to Camel JBang that expose test-infra services via CLI
   
   `camel infra list` - Lists all the available services
   ```
   ➜  camel git:(execute-test-infra-camel-cli) CamelJBang infra list
   ---
   ignite: []
   azure-storage-queue:
   - "storage-queue"
   openldap: []
   event-bridge: []
   xmpp: []
   kinesis: []
   redis: []
   aws-lambda: []
   aws-config: []
   lambda: []
   elastic-search: []
   aws-secrets-manager: []
   elasticsearch: []
   hazelcast: []
   arangodb: []
   aws-kinesis: []
   chatscript: []
   azure:
   - "storage-queue"
   - "storage-blob"
   aws-dynamo-db: []
   ...
   ```
   
   `camel infra run $SERVICE` - Run any services available in the list
   ```
   ➜  camel git:(execute-test-infra-camel-cli) CamelJBang infra run redis
   Starting service redis
   ---
   port: 32771
   host: "localhost"
   getServiceAddress: "localhost:32771"
   
   To stop the execution press q
   ```
   
   In order to do so, after decoupling junit from test-infra, the following was done:
   
   - Added a new marker annotation @InfraService, the annotation is used to describe the services (ala google AutoService with more informations related to the test service)
   - A maven Mojo [CamelTestInfraGenerateMetadataMojo.java](https://github.com/apache/camel/compare/main...Croway:execute-test-infra-camel-cli?expand=1#diff-b5cdcfab9c50ae3a4c73e0c219f7f5979be580201feb0f727cdbfb3a5e63f78c) that gathers all the annotations via jandex index and create a json file containing all the information, service class, aliases, implementation class, and implementation alias
   - A new test-infra module, camel-test-infra-all that gathers all the test-infra dependencies and execute the Mojo to generate the json file
   - The actual implementation in Camel JBang that reads the generated JSON file and visualizes it (let's discuss how, right now aliases and implementationAliases are exposed as yaml) or, in case of run, uses the reflection to run the service and print the informations provided by the Service Interface


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #16773:
URL: https://github.com/apache/camel/pull/16773#discussion_r1911925447


##########
tooling/spi-annotations/src/main/java/org/apache/camel/spi/annotations/InfraService.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spi.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Target({ ElementType.TYPE })
+public @interface InfraService {

Review Comment:
   Add javadoc to document this API



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #16773:
URL: https://github.com/apache/camel/pull/16773#discussion_r1910235963


##########
components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/AvailablePort.java:
##########
@@ -0,0 +1,36 @@
+package org.apache.camel.test;

Review Comment:
   Missing license. Minor finding.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #16773:
URL: https://github.com/apache/camel/pull/16773#issuecomment-2582526236

   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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #16773:
URL: https://github.com/apache/camel/pull/16773#issuecomment-2582524644

   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 some of the options like `--gav` `--sort` and `--filter`
   Also it can have a `--json` dump that 3rd party tooling can use.
   
   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.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #16773:
URL: https://github.com/apache/camel/pull/16773#issuecomment-2582528451

   this can be done in new PRs I think a first cut is to make the `run` command work great. The list/dump/ and show nice is 2nd priority


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #16773:
URL: https://github.com/apache/camel/pull/16773#discussion_r1910275899


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/infra/InfraList.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.infra;
+
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = "list", description = "Displays available external services", sortOptions = false,
+                     showDefaultValues = true)
+public class InfraList extends CamelCommand {
+
+    public InfraList(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doCall() throws Exception {
+        Map<String, Set<String>> services = new HashMap<>();
+
+        List<InfraCommand.TestInfraService> metadata;
+
+        try (InputStream is
+                = this.getClass().getClassLoader().getResourceAsStream("META-INF/test-infra-metadata.json")) {

Review Comment:
   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



##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/infra/InfraCommand.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.infra;
+
+import java.util.List;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = "infra",
+                     description = "List and Run external services for testing and prototyping")
+public class InfraCommand extends CamelCommand {

Review Comment:
   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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "orpiske (via GitHub)" <gi...@apache.org>.
orpiske commented on code in PR #16773:
URL: https://github.com/apache/camel/pull/16773#discussion_r1910306359


##########
test-infra/camel-test-infra-xmpp/src/main/java/org/apache/camel/test/infra/xmpp/services/XmppLocalContainerInfraService.java:
##########
@@ -16,12 +16,14 @@
  */
 package org.apache.camel.test.infra.xmpp.services;
 
+import org.apache.camel.spi.annotations.InfraService;
 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" })

Review Comment:
   We may need to add a note about this in the test infra documentation (if we don't generate it automatically). 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "orpiske (via GitHub)" <gi...@apache.org>.
orpiske commented on code in PR #16773:
URL: https://github.com/apache/camel/pull/16773#discussion_r1910305687


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/infra/InfraRun.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.infra;
+
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Scanner;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.test.infra.common.services.InfrastructureService;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = "run",
+                     description = "Run an external service")
+public class InfraRun extends CamelCommand {
+
+    @CommandLine.Parameters(description = "Service name", arity = "1")
+    private List<String> serviceName;
+
+    public InfraRun(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doCall() throws Exception {
+        if (serviceName == null || serviceName.isEmpty()) {
+            return 0;
+        }
+
+        String service = serviceName.get(0);
+        String serviceImplementation = serviceName.size() > 1 ? serviceName.get(1) : null;
+
+        run(service, serviceImplementation);
+
+        return 0;
+    }
+
+    private void run(String testService, String testServiceImplementation) throws Exception {
+        List<InfraCommand.TestInfraService> metadata;
+
+        try (InputStream is
+                = this.getClass().getClassLoader().getResourceAsStream("META-INF/test-infra-metadata.json")) {
+            String json = new String(is.readAllBytes(), StandardCharsets.UTF_8);
+
+            metadata = InfraCommand.JSON_MAPPER.readValue(json, new TypeReference<List<InfraCommand.TestInfraService>>() {
+            });
+        }
+
+        List<InfraCommand.TestInfraService> services = metadata;
+
+        InfraCommand.TestInfraService testInfraService = services
+                .stream()
+                .filter(service -> {
+                    if (testServiceImplementation != null && !testServiceImplementation.isEmpty()
+                            && service.aliasImplementation() != null) {
+                        return service.alias().contains(testService)
+                                && service.aliasImplementation().contains(testServiceImplementation);
+                    } else if (testServiceImplementation == null) {
+                        return service.alias().contains(testService)
+                                && (service.aliasImplementation() == null || service.aliasImplementation().isEmpty());
+                    }
+
+                    return false;
+                })
+                .findFirst()
+                .orElseThrow(() -> {
+                    String message = ", use the list command for the available services";
+                    if (testServiceImplementation != null) {
+                        return new IllegalArgumentException(
+                                "service " + testService + " with implementation " + testServiceImplementation + " not found"
+                                                            + message);
+                    }
+
+                    return new IllegalArgumentException("service " + testService + " not found" + message);
+                });
+
+        String serviceInterface = testInfraService.service();
+        String serviceImpl = testInfraService.implementation();
+
+        printer().println("Starting service " + testService);
+
+        InfrastructureService actualService = (InfrastructureService) Class.forName(serviceImpl)
+                .getDeclaredConstructor(null)
+                .newInstance(null);

Review Comment:
   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). 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway merged PR #16773:
URL: https://github.com/apache/camel/pull/16773


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "orpiske (via GitHub)" <gi...@apache.org>.
orpiske commented on code in PR #16773:
URL: https://github.com/apache/camel/pull/16773#discussion_r1910308825


##########
test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedInfraService.java:
##########
@@ -19,13 +19,21 @@
 
 import java.io.File;
 
+import org.apache.camel.spi.annotations.InfraService;
+import org.apache.camel.test.infra.ftp.services.FtpInfraService;
 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 {

Review Comment:
   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. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #16773:
URL: https://github.com/apache/camel/pull/16773#discussion_r1910366330


##########
test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/FtpsEmbeddedInfraService.java:
##########
@@ -19,13 +19,21 @@
 
 import java.io.File;
 
+import org.apache.camel.spi.annotations.InfraService;
+import org.apache.camel.test.infra.ftp.services.FtpInfraService;
 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 {

Review Comment:
   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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on PR #16773:
URL: https://github.com/apache/camel/pull/16773#issuecomment-2582908013

   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 `--json` for the tooling
   list output (I'll review some annotations to avoid cases like `azure-storage-queue  storage-queue`)
   ```
    ALIAS                   IMPLEMENTATION              
    ignite                                              
    azure-storage-queue     storage-queue               
    openldap                                            
    event-bridge                                        
    kinesis                                             
    xmpp                                                
    redis                                               
    aws-lambda                                          
    aws-config                                          
    lambda                                              
    elastic-search                                      
    aws-secrets-manager                                 
    elasticsearch                                       
    hazelcast                                           
    arangodb                                            
    aws-kinesis                                         
    chatscript                                          
    aws-dynamo-db                                       
    aws-sns                                             
    azure                   storage-queue, storage-blob 
    hashicorp-vault         vault                       
    s3                                                  
    torch-serve                                         
    zookeeper                                           
    etcd3                                               
    ollama                                              
    google                  pub-sub                     
    dynamodb                                            
    aws-cloud-watch                                     
    aws-sqs                                             
    aws-iam                                             
    aws-ec2                                             
    cassandra                                           
    aws-kms                                             
    kafka                   redpanda, strimzi           
    aws-s3                                              
    sftp                                                
    couchdb                                             
    milvus                                              
    pulsar                                              
    hashicorp               vault                       
    cloud-watch                                         
    nats                                                
    qdrant                                              
    hive-mq                 sparkplug                   
    fhir                                                
    smb                                                 
    minio                                               
    dynamo-db                                           
    ec2                                                 
    aws-sts                                             
    couchbase                                           
    solr                                                
    mongodb                                             
    postgres                                            
    google-pub-sub          pub-sub                     
    ftps                                                
    artemis                 amqp, mqtt, persistent      
    hivemq                  sparkplug                   
    ftp                                                 
    microprofile            lra                         
    rocketmq                                            
    rabbitmq                                            
    aws-event-bridge                                    
    infinispan                                          
    mosquitto                                           
    azure-storage-blob      storage-blob                
    microprofile-lra        lra                         
    chat-script                          
    ```
    list output json `[{"aliasImplementation":"","alias":"ignite"},{"aliasImplementation":"storage-queue","alias":"azure-storage-queue"},{"aliasImplementation":"","alias":"openldap"},{"aliasImplementation":"","alias":"event-bridge"},{"aliasImplementation":"","alias":"kinesis"},{"aliasImplementation":"","alias":"xmpp"},{"aliasImplementation":"","alias":"redis"},{"aliasImplementation":"","alias":"aws-lambda"},{"aliasImplementation":"","alias":"aws-config"},{"aliasImplementation":"","alias":"lambda"},{"aliasImplementation":"","alias":"elastic-search"},{"aliasImplementation":"","alias":"aws-secrets-manager"},{"aliasImplementation":"","alias":"elasticsearch"},{"aliasImplementation":"","alias":"hazelcast"},{"aliasImplementation":"","alias":"arangodb"},{"aliasImplementation":"","alias":"aws-kinesis"},{"aliasImplementation":"","alias":"chatscript"},{"aliasImplementation":"","alias":"aws-dynamo-db"},{"aliasImplementation":"","alias":"aws-sns"},{"aliasImplementation":"storage-queue, storage-bl
 ob","alias":"azure"},{"aliasImplementation":"vault","alias":"hashicorp-vault"},{"aliasImplementation":"","alias":"s3"},{"aliasImplementation":"","alias":"torch-serve"},{"aliasImplementation":"","alias":"zookeeper"},{"aliasImplementation":"","alias":"etcd3"},{"aliasImplementation":"","alias":"ollama"},{"aliasImplementation":"pub-sub","alias":"google"},{"aliasImplementation":"","alias":"dynamodb"},{"aliasImplementation":"","alias":"aws-cloud-watch"},{"aliasImplementation":"","alias":"aws-sqs"},{"aliasImplementation":"","alias":"aws-iam"},{"aliasImplementation":"","alias":"aws-ec2"},{"aliasImplementation":"","alias":"cassandra"},{"aliasImplementation":"","alias":"aws-kms"},{"aliasImplementation":"redpanda, strimzi","alias":"kafka"},{"aliasImplementation":"","alias":"aws-s3"},{"aliasImplementation":"","alias":"sftp"},{"aliasImplementation":"","alias":"couchdb"},{"aliasImplementation":"","alias":"milvus"},{"aliasImplementation":"","alias":"pulsar"},{"aliasImplementation":"vault","alias":
 "hashicorp"},{"aliasImplementation":"","alias":"cloud-watch"},{"aliasImplementation":"","alias":"nats"},{"aliasImplementation":"","alias":"qdrant"},{"aliasImplementation":"sparkplug","alias":"hive-mq"},{"aliasImplementation":"","alias":"fhir"},{"aliasImplementation":"","alias":"smb"},{"aliasImplementation":"","alias":"minio"},{"aliasImplementation":"","alias":"dynamo-db"},{"aliasImplementation":"","alias":"ec2"},{"aliasImplementation":"","alias":"aws-sts"},{"aliasImplementation":"","alias":"couchbase"},{"aliasImplementation":"","alias":"solr"},{"aliasImplementation":"","alias":"mongodb"},{"aliasImplementation":"","alias":"postgres"},{"aliasImplementation":"pub-sub","alias":"google-pub-sub"},{"aliasImplementation":"","alias":"ftps"},{"aliasImplementation":"amqp, mqtt, persistent","alias":"artemis"},{"aliasImplementation":"sparkplug","alias":"hivemq"},{"aliasImplementation":"","alias":"ftp"},{"aliasImplementation":"lra","alias":"microprofile"},{"aliasImplementation":"","alias":"rocket
 mq"},{"aliasImplementation":"","alias":"rabbitmq"},{"aliasImplementation":"","alias":"aws-event-bridge"},{"aliasImplementation":"","alias":"infinispan"},{"aliasImplementation":"","alias":"mosquitto"},{"aliasImplementation":"storage-blob","alias":"azure-storage-blob"},{"aliasImplementation":"lra","alias":"microprofile-lra"},{"aliasImplementation":"","alias":"chat-script"}]`
    
    run command output `camel infra run kafka redpanda`
    ```
    Starting service kafka with implementation redpanda
   {
     "getBootstrapServers" : "localhost:32783"
   }
   To stop the execution press q
   ```
   
   @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  `/camel/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/test-infra/metadata.json` but I do not know if this is a good approach, given that the other generated files are generated by the camel-package-maven-plugin during runtime.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on PR #16773:
URL: https://github.com/apache/camel/pull/16773#issuecomment-2582467611

   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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #16773:
URL: https://github.com/apache/camel/pull/16773#discussion_r1910364837


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/infra/InfraRun.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.infra;
+
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Scanner;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.test.infra.common.services.InfrastructureService;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = "run",
+                     description = "Run an external service")
+public class InfraRun extends CamelCommand {
+
+    @CommandLine.Parameters(description = "Service name", arity = "1")
+    private List<String> serviceName;
+
+    public InfraRun(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doCall() throws Exception {
+        if (serviceName == null || serviceName.isEmpty()) {
+            return 0;
+        }
+
+        String service = serviceName.get(0);
+        String serviceImplementation = serviceName.size() > 1 ? serviceName.get(1) : null;
+
+        run(service, serviceImplementation);
+
+        return 0;
+    }
+
+    private void run(String testService, String testServiceImplementation) throws Exception {
+        List<InfraCommand.TestInfraService> metadata;
+
+        try (InputStream is
+                = this.getClass().getClassLoader().getResourceAsStream("META-INF/test-infra-metadata.json")) {
+            String json = new String(is.readAllBytes(), StandardCharsets.UTF_8);
+
+            metadata = InfraCommand.JSON_MAPPER.readValue(json, new TypeReference<List<InfraCommand.TestInfraService>>() {
+            });
+        }
+
+        List<InfraCommand.TestInfraService> services = metadata;
+
+        InfraCommand.TestInfraService testInfraService = services
+                .stream()
+                .filter(service -> {
+                    if (testServiceImplementation != null && !testServiceImplementation.isEmpty()
+                            && service.aliasImplementation() != null) {
+                        return service.alias().contains(testService)
+                                && service.aliasImplementation().contains(testServiceImplementation);
+                    } else if (testServiceImplementation == null) {
+                        return service.alias().contains(testService)
+                                && (service.aliasImplementation() == null || service.aliasImplementation().isEmpty());
+                    }
+
+                    return false;
+                })
+                .findFirst()
+                .orElseThrow(() -> {
+                    String message = ", use the list command for the available services";
+                    if (testServiceImplementation != null) {
+                        return new IllegalArgumentException(
+                                "service " + testService + " with implementation " + testServiceImplementation + " not found"
+                                                            + message);
+                    }
+
+                    return new IllegalArgumentException("service " + testService + " not found" + message);
+                });
+
+        String serviceInterface = testInfraService.service();
+        String serviceImpl = testInfraService.implementation();
+
+        printer().println("Starting service " + testService);
+
+        InfrastructureService actualService = (InfrastructureService) Class.forName(serviceImpl)
+                .getDeclaredConstructor(null)
+                .newInstance(null);

Review Comment:
   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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #16773:
URL: https://github.com/apache/camel/pull/16773#issuecomment-2582461858

   :star2: Thank you for your contribution to the Apache Camel project! :star2: 
   
   :robot: CI automation will test this PR automatically.
   
   :camel: Apache Camel Committers, please review the following items:
   
   * First-time contributors **require MANUAL approval** for the GitHub Actions to run
   
   * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot.
   
   * You can label PRs using `build-all`, `build-dependents`, `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
   
   * Build and test logs are available in the Summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary. 
   
   * :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expose test-infra services via Camel JBang [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #16773:
URL: https://github.com/apache/camel/pull/16773#issuecomment-2582538127

   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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org