Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dsl/camel-jbang/camel-jbang-it/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ To run tests use the dedicated Maven profile `jbang-it-test` activated by the sa
mvn verify -Djbang-it-test
----

== Run tests locally

To run tests using a local Camel CLI process instead of a container, activate the `local-camel-cli-process` profile:

[source,bash]
----
mvn verify -Djbang-it-test -Dcamel-cli.instance.type=local-camel-cli-process
----

Tests tagged with `container-only` will be automatically excluded when this profile is active.

== Configuration

Camel CLI infra configuration is defined in link:../../../test-infra/camel-test-infra-cli/README.adoc[README.adoc]
Expand Down
18 changes: 17 additions & 1 deletion dsl/camel-jbang/camel-jbang-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@
<maven.test.skip>false</maven.test.skip>
<shared.data.folder>target/data</shared.data.folder>
<shared.maven.local.repo>${settings.localRepository}</shared.maven.local.repo>
<failsafe.forkCount>1C</failsafe.forkCount>
<x11.display>:0</x11.display>
<failsafe.excludedGroups/>
</properties>
<build>
<plugins>
Expand Down Expand Up @@ -267,8 +269,9 @@
</executions>
<configuration>
<argLine>-DforkNumber=${surefire.forkNumber}</argLine>
<forkCount>1C</forkCount>
<forkCount>${failsafe.forkCount}</forkCount>
<groups>${export.runtime}</groups>
<excludedGroups>${failsafe.excludedGroups}</excludedGroups>
<rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</rerunFailingTestsCount>
<systemPropertyVariables>
<cli.service.data.folder>${shared.data.folder}</cli.service.data.folder>
Expand All @@ -287,6 +290,19 @@
</plugins>
</build>
</profile>
<profile>
<id>local-camel-cli-process</id>
<activation>
<property>
<name>camel-cli.instance.type</name>
<value>local-camel-cli-process</value>
</property>
</activation>
<properties>
<failsafe.forkCount>1</failsafe.forkCount>
<failsafe.excludedGroups>container-only</failsafe.excludedGroups>
</properties>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;

import static org.junit.jupiter.api.condition.OS.WINDOWS;

@DisabledOnOs(WINDOWS)
public class CamelCatalogITCase extends JBangTestSupport {

private static final String COMPONENT_REGEX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;

import static org.junit.jupiter.api.condition.OS.WINDOWS;

@DisabledOnOs(WINDOWS)
public class CamelDebugITCase extends JBangTestSupport {
@Test
public void testDebug() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@

import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;

import static org.junit.jupiter.api.condition.OS.WINDOWS;

@DisabledOnOs(WINDOWS)
public class CmdStartStopITCase extends JBangTestSupport {

@Test
Expand All @@ -43,7 +48,7 @@ public void testCmdStopByPID() throws IOException {
String process = executeBackground(String.format("run %s/FromDirectoryRoute.java", mountPoint()));
executeBackground(String.format("run %s/route2.yaml", mountPoint()));
checkLogContains("Hello world!");
execute("cmd stop-route " + getPID(process));
execute("cmd stop-route " + process);
checkCommandOutputsPattern("get route",
"route1\\s+timer:\\/\\/(yaml|java)\\?period=1000\\s+Stopped.*\\n.*route2.*timer:\\/\\/(yaml|java)\\?period=1000\\s+Started",
ASSERTION_WAIT_SECONDS);
Expand Down Expand Up @@ -82,7 +87,7 @@ public void testCmdStartByPID() throws IOException {
executeBackground(String.format("run %s/route2.yaml", mountPoint()));
checkLogContains("Hello world!");
execute("cmd stop-route");
execute("cmd start-route " + getPID(process));
execute("cmd start-route " + process);
checkCommandOutputsPattern("get route",
"route1\\s+timer:\\/\\/(yaml|java)\\?period=1000\\s+Started.*\\n.*route2.*timer:\\/\\/(yaml|java)\\?period=1000\\s+Stopped",
ASSERTION_WAIT_SECONDS);
Expand All @@ -102,6 +107,7 @@ public void testCmdStartAll() throws IOException {
}

@Test
@Tag("container-only")
public void testCamelWatch() throws IOException {
copyResourceInDataFolder(TestResources.ROUTE2);
String process = executeBackground(String.format("run %s/route2.yaml", mountPoint()));
Expand All @@ -111,7 +117,7 @@ public void testCamelWatch() throws IOException {
execInContainer(String.format("chmod +x %s/watch-sleep", mountPoint()));
Assertions.assertThat(
execInContainer(String.format("%s/watch-sleep", mountPoint())))
.as("watch command should output PID" + getPID(process))
.contains(getPID(process));
.as("watch command should output PID" + process)
.contains(process);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class CustomJarsITCase extends JBangTestSupport {
public void testCustomJars() throws IOException {
copyResourceInDataFolder(TestResources.CIRCUIT_BREAKER);
Assertions
.assertThatCode(() -> execute(String.format("run %s/CircuitBreakerRoute.java --dep=camel-timer", mountPoint())))
.assertThatCode(() -> execute(
String.format("run %s/CircuitBreakerRoute.java --max-seconds=30", mountPoint())))
.as("the application without dependency will cause error")
.hasStackTraceContaining("Failed to create route: circuitBreaker")
.hasStackTraceContaining(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.camel.dsl.jbang.it.support.JiraIssue;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

public class DevModeITCase extends JBangTestSupport {
Expand Down Expand Up @@ -75,6 +76,7 @@ public void runDevConsoleTest() {

@Test
@JiraIssue("CAMEL-20939")
@Tag("container-only")
public void runUsingProfileTest() throws IOException {
copyResourceInDataFolder(TestResources.HELLO_NAME);
copyResourceInDataFolder(TestResources.TEST_PROFILE_PROP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
import org.assertj.core.api.Assertions;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import org.junit.jupiter.api.condition.DisabledOnOs;

import static org.junit.jupiter.api.condition.OS.WINDOWS;

@Tag("container-only")
@DisabledOnOs(WINDOWS)
public class InfrastructureITCase extends JBangTestSupport {
private static final String SERVICE = "ftp";
private static final String IMPL_SERVICE = "artemis";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
import org.assertj.core.api.Assertions;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;

import static org.junit.jupiter.api.condition.OS.WINDOWS;

@DisabledOnOs(WINDOWS)
public class JolokiaITCase extends JBangTestSupport {

@Test
Expand All @@ -37,7 +41,7 @@ public void testAttachJolokia() throws IOException {
.contains("\"agentContext\":\"/jolokia\"");
Assertions.assertThat(execute("jolokia FromDirectoryRoute --stop"))
.as("Jolokia should stop")
.contains("Stopped Jolokia for PID " + getPID(process));
.contains("Stopped Jolokia for PID " + process);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
import org.apache.camel.dsl.jbang.it.support.InVersion;
import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;

@Tag("container-only")
public class OpenApiITCase extends JBangTestSupport {

final HttpClient httpClient = HttpClient.newHttpClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
import org.assertj.core.api.Assertions;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static org.junit.jupiter.api.condition.OS.LINUX;
import static org.junit.jupiter.api.condition.OS.WINDOWS;

public class RunCommandITCase extends JBangTestSupport {

Expand Down Expand Up @@ -80,6 +81,7 @@ public void runWithProperties() throws IOException {
}

@Test
@Tag("container-only")
public void runRoutesFromMultipleFilesUsingWildcardTest() {
execute("init one.yaml --directory=/tmp/one");
execute("init two.xml --directory=/tmp/two");
Expand Down Expand Up @@ -126,6 +128,7 @@ public void runRouteFromGistTest() {
}

@Test
@Tag("container-only")
public void runDownloadedFromGithubTest() {
execute("init https://github.com/apache/camel-kamelets-examples/tree/main/jbang/dependency-injection");
Assertions.assertThat(containerService.listDirectory(DEFAULT_ROUTE_FOLDER))
Expand Down Expand Up @@ -156,7 +159,7 @@ public void runSpecificVersionTest(String version) {
final String process = executeBackground(String.format("run %s/cheese.xml --camel-version=%s", mountPoint(), version));
checkLogContainsPattern(String.format(" Apache Camel %s .* started", version));
checkLogContains(DEFAULT_MSG);
execute("stop " + getPID(process));
execute("stop " + process);
}

@Test
Expand All @@ -168,7 +171,8 @@ public void runCamelKCRDTest() throws IOException {
}

@Test
@EnabledOnOs(LINUX)
@DisabledOnOs(WINDOWS)
@Tag("container-only")
@DisabledIf(value = "java.awt.GraphicsEnvironment#isHeadless")
public void runFromClipboardTest() throws IOException {
Assumptions.assumeTrue(execInHost("command -v ssh").contains("ssh"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
import org.apache.camel.test.infra.mosquitto.services.MosquittoLocalContainerService;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.GenericContainer;

@Tag("container-only")
public class RunCommandOnMqttITCase extends JBangTestSupport {

private static int mqttPort = AvailablePortFinder.getNextAvailable();
Expand Down Expand Up @@ -54,7 +56,7 @@ public void sendMessageWithoutEndpoint() throws IOException {
checkLogContains("Started route1 (kamelet:mqtt5-source)");
final String payloadFile = "payload.json";
newFileInDataFolder(payloadFile, "{\"value\": 21}");
sendCmd(String.format("%s/%s", mountPoint(), payloadFile), getPID(process));
sendCmd(String.format("%s/%s", mountPoint(), payloadFile), process);
checkLogContains("The temperature is 21");
}

Expand All @@ -63,7 +65,7 @@ public void testStub() throws IOException {
copyResourceInDataFolder(TestResources.STUB_ROUTE);
final String process = executeBackground(String.format("run %s/%s --stub=jms",
mountPoint(), TestResources.STUB_ROUTE.getName()));
checkCommandOutputs("cmd send --body='Hello camel from stubbed jms' " + getPID(process), "Sent (success)");
checkCommandOutputs("cmd send --body='Hello camel from stubbed jms' " + process, "Sent (success)");
checkCommandOutputs("cmd stub --browse", "Hello camel from stubbed jms", ASSERTION_WAIT_SECONDS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;

import static org.junit.jupiter.api.condition.OS.WINDOWS;

@DisabledOnOs(WINDOWS)
public class ScriptingWithPipesITCase extends JBangTestSupport {
@Test
public void testPipeScript() throws IOException {
Expand Down
Loading