-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Execute test-infra services via Camel JBang
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
- Loading branch information
Showing
82 changed files
with
1,249 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...nents/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/AvailablePort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.apache.camel.test; | ||
|
||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.net.InetSocketAddress; | ||
import java.net.ServerSocket; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class AvailablePort { | ||
private static final Logger LOG = LoggerFactory.getLogger(AvailablePort.class); | ||
|
||
/** | ||
* Probe a port to see if it is free | ||
* | ||
* @param port an integer port number to be tested. If port is 0, then the next available port is | ||
* returned. | ||
* @throws IllegalStateException if the port is not free or, in case of port 0, if there are no ports available at | ||
* all. | ||
* @return the port number itself if the port is free or, in case of port 0, the first | ||
* available port number. | ||
*/ | ||
public static int probePort(InetAddress address, int port) { | ||
|
||
try (ServerSocket ss = new ServerSocket()) { | ||
ss.setReuseAddress(true); | ||
ss.bind(new InetSocketAddress(address, port), 1); | ||
int probedPort = ss.getLocalPort(); | ||
LOG.info("Available port is -> {}", probedPort); | ||
return probedPort; | ||
} catch (IOException e) { | ||
throw new IllegalStateException("Cannot find free port", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/infra/InfraCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
|
||
static final ObjectMapper JSON_MAPPER = new ObjectMapper(); | ||
static final ObjectMapper YAML_MAPPER = new ObjectMapper(new YAMLFactory()); | ||
|
||
{ | ||
YAML_MAPPER.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); | ||
YAML_MAPPER.registerModule(new JavaTimeModule()); | ||
YAML_MAPPER.registerModule(new Jdk8Module()); | ||
} | ||
|
||
public InfraCommand(CamelJBangMain main) { | ||
super(main); | ||
} | ||
|
||
@Override | ||
public Integer doCall() throws Exception { | ||
// defaults to list | ||
new CommandLine(new InfraList(getMain())).execute(); | ||
return 0; | ||
} | ||
|
||
record TestInfraService(String service, String implementation, List<String> alias, List<String> aliasImplementation) { | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...el-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/infra/InfraList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")) { | ||
String json = new String(is.readAllBytes(), StandardCharsets.UTF_8); | ||
|
||
metadata = InfraCommand.JSON_MAPPER.readValue(json, new TypeReference<List<InfraCommand.TestInfraService>>() { | ||
}); | ||
} | ||
|
||
for (InfraCommand.TestInfraService service : metadata) { | ||
for (String alias : service.alias()) { | ||
if (!services.containsKey(alias)) { | ||
services.put(alias, new HashSet<>()); | ||
} | ||
|
||
if (service.aliasImplementation() != null) { | ||
for (String aliasImplementation : service.aliasImplementation()) { | ||
services.get(alias).add(aliasImplementation); | ||
} | ||
} | ||
} | ||
} | ||
|
||
printer().print(InfraCommand.YAML_MAPPER.writeValueAsString(services)); | ||
return 0; | ||
} | ||
|
||
} |
Oops, something went wrong.