Skip to content

Commit 5cf8b1c

Browse files
authored
CAMEL-22149: jbang-it, make tests Windows compatible (#21493)
1 parent bf8810a commit 5cf8b1c

File tree

26 files changed

+659
-70
lines changed

26 files changed

+659
-70
lines changed

dsl/camel-jbang/camel-jbang-it/README.adoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ To run tests use the dedicated Maven profile `jbang-it-test` activated by the sa
1313
mvn verify -Djbang-it-test
1414
----
1515

16+
== Run tests locally
17+
18+
To run tests using a local Camel CLI process instead of a container, activate the `local-camel-cli-process` profile:
19+
20+
[source,bash]
21+
----
22+
mvn verify -Djbang-it-test -Dcamel-cli.instance.type=local-camel-cli-process
23+
----
24+
25+
Tests tagged with `container-only` will be automatically excluded when this profile is active.
26+
1627
== Configuration
1728

1829
Camel CLI infra configuration is defined in link:../../../test-infra/camel-test-infra-cli/README.adoc[README.adoc]

dsl/camel-jbang/camel-jbang-it/pom.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@
232232
<maven.test.skip>false</maven.test.skip>
233233
<shared.data.folder>target/data</shared.data.folder>
234234
<shared.maven.local.repo>${settings.localRepository}</shared.maven.local.repo>
235+
<failsafe.forkCount>1C</failsafe.forkCount>
235236
<x11.display>:0</x11.display>
237+
<failsafe.excludedGroups/>
236238
</properties>
237239
<build>
238240
<plugins>
@@ -267,8 +269,9 @@
267269
</executions>
268270
<configuration>
269271
<argLine>-DforkNumber=${surefire.forkNumber}</argLine>
270-
<forkCount>1C</forkCount>
272+
<forkCount>${failsafe.forkCount}</forkCount>
271273
<groups>${export.runtime}</groups>
274+
<excludedGroups>${failsafe.excludedGroups}</excludedGroups>
272275
<rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</rerunFailingTestsCount>
273276
<systemPropertyVariables>
274277
<cli.service.data.folder>${shared.data.folder}</cli.service.data.folder>
@@ -287,6 +290,19 @@
287290
</plugins>
288291
</build>
289292
</profile>
293+
<profile>
294+
<id>local-camel-cli-process</id>
295+
<activation>
296+
<property>
297+
<name>camel-cli.instance.type</name>
298+
<value>local-camel-cli-process</value>
299+
</property>
300+
</activation>
301+
<properties>
302+
<failsafe.forkCount>1</failsafe.forkCount>
303+
<failsafe.excludedGroups>container-only</failsafe.excludedGroups>
304+
</properties>
305+
</profile>
290306
</profiles>
291307

292308
</project>

dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/CamelCatalogITCase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818

1919
import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
2020
import org.junit.jupiter.api.Test;
21+
import org.junit.jupiter.api.condition.DisabledOnOs;
2122

23+
import static org.junit.jupiter.api.condition.OS.WINDOWS;
24+
25+
@DisabledOnOs(WINDOWS)
2226
public class CamelCatalogITCase extends JBangTestSupport {
2327

2428
private static final String COMPONENT_REGEX

dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/CamelDebugITCase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020

2121
import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
2222
import org.junit.jupiter.api.Test;
23+
import org.junit.jupiter.api.condition.DisabledOnOs;
2324

25+
import static org.junit.jupiter.api.condition.OS.WINDOWS;
26+
27+
@DisabledOnOs(WINDOWS)
2428
public class CamelDebugITCase extends JBangTestSupport {
2529
@Test
2630
public void testDebug() throws IOException {

dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/CmdStartStopITCase.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@
2020

2121
import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
2222
import org.assertj.core.api.Assertions;
23+
import org.junit.jupiter.api.Tag;
2324
import org.junit.jupiter.api.Test;
25+
import org.junit.jupiter.api.condition.DisabledOnOs;
2426

27+
import static org.junit.jupiter.api.condition.OS.WINDOWS;
28+
29+
@DisabledOnOs(WINDOWS)
2530
public class CmdStartStopITCase extends JBangTestSupport {
2631

2732
@Test
@@ -43,7 +48,7 @@ public void testCmdStopByPID() throws IOException {
4348
String process = executeBackground(String.format("run %s/FromDirectoryRoute.java", mountPoint()));
4449
executeBackground(String.format("run %s/route2.yaml", mountPoint()));
4550
checkLogContains("Hello world!");
46-
execute("cmd stop-route " + getPID(process));
51+
execute("cmd stop-route " + process);
4752
checkCommandOutputsPattern("get route",
4853
"route1\\s+timer:\\/\\/(yaml|java)\\?period=1000\\s+Stopped.*\\n.*route2.*timer:\\/\\/(yaml|java)\\?period=1000\\s+Started",
4954
ASSERTION_WAIT_SECONDS);
@@ -82,7 +87,7 @@ public void testCmdStartByPID() throws IOException {
8287
executeBackground(String.format("run %s/route2.yaml", mountPoint()));
8388
checkLogContains("Hello world!");
8489
execute("cmd stop-route");
85-
execute("cmd start-route " + getPID(process));
90+
execute("cmd start-route " + process);
8691
checkCommandOutputsPattern("get route",
8792
"route1\\s+timer:\\/\\/(yaml|java)\\?period=1000\\s+Started.*\\n.*route2.*timer:\\/\\/(yaml|java)\\?period=1000\\s+Stopped",
8893
ASSERTION_WAIT_SECONDS);
@@ -102,6 +107,7 @@ public void testCmdStartAll() throws IOException {
102107
}
103108

104109
@Test
110+
@Tag("container-only")
105111
public void testCamelWatch() throws IOException {
106112
copyResourceInDataFolder(TestResources.ROUTE2);
107113
String process = executeBackground(String.format("run %s/route2.yaml", mountPoint()));
@@ -111,7 +117,7 @@ public void testCamelWatch() throws IOException {
111117
execInContainer(String.format("chmod +x %s/watch-sleep", mountPoint()));
112118
Assertions.assertThat(
113119
execInContainer(String.format("%s/watch-sleep", mountPoint())))
114-
.as("watch command should output PID" + getPID(process))
115-
.contains(getPID(process));
120+
.as("watch command should output PID" + process)
121+
.contains(process);
116122
}
117123
}

dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/CustomJarsITCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public class CustomJarsITCase extends JBangTestSupport {
2828
public void testCustomJars() throws IOException {
2929
copyResourceInDataFolder(TestResources.CIRCUIT_BREAKER);
3030
Assertions
31-
.assertThatCode(() -> execute(String.format("run %s/CircuitBreakerRoute.java --dep=camel-timer", mountPoint())))
31+
.assertThatCode(() -> execute(
32+
String.format("run %s/CircuitBreakerRoute.java --max-seconds=30", mountPoint())))
3233
.as("the application without dependency will cause error")
3334
.hasStackTraceContaining("Failed to create route: circuitBreaker")
3435
.hasStackTraceContaining(

dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/DevModeITCase.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.camel.dsl.jbang.it.support.JiraIssue;
3232
import org.assertj.core.api.Assertions;
3333
import org.assertj.core.api.SoftAssertions;
34+
import org.junit.jupiter.api.Tag;
3435
import org.junit.jupiter.api.Test;
3536

3637
public class DevModeITCase extends JBangTestSupport {
@@ -75,6 +76,7 @@ public void runDevConsoleTest() {
7576

7677
@Test
7778
@JiraIssue("CAMEL-20939")
79+
@Tag("container-only")
7880
public void runUsingProfileTest() throws IOException {
7981
copyResourceInDataFolder(TestResources.HELLO_NAME);
8082
copyResourceInDataFolder(TestResources.TEST_PROFILE_PROP);

dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/InfrastructureITCase.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@
2121
import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
2222
import org.assertj.core.api.Assertions;
2323
import org.awaitility.Awaitility;
24+
import org.junit.jupiter.api.Tag;
2425
import org.junit.jupiter.api.Test;
2526
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
27+
import org.junit.jupiter.api.condition.DisabledOnOs;
2628

29+
import static org.junit.jupiter.api.condition.OS.WINDOWS;
30+
31+
@Tag("container-only")
32+
@DisabledOnOs(WINDOWS)
2733
public class InfrastructureITCase extends JBangTestSupport {
2834
private static final String SERVICE = "ftp";
2935
private static final String IMPL_SERVICE = "artemis";

dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/JolokiaITCase.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
import org.assertj.core.api.Assertions;
2424
import org.awaitility.Awaitility;
2525
import org.junit.jupiter.api.Test;
26+
import org.junit.jupiter.api.condition.DisabledOnOs;
2627

28+
import static org.junit.jupiter.api.condition.OS.WINDOWS;
29+
30+
@DisabledOnOs(WINDOWS)
2731
public class JolokiaITCase extends JBangTestSupport {
2832

2933
@Test
@@ -37,7 +41,7 @@ public void testAttachJolokia() throws IOException {
3741
.contains("\"agentContext\":\"/jolokia\"");
3842
Assertions.assertThat(execute("jolokia FromDirectoryRoute --stop"))
3943
.as("Jolokia should stop")
40-
.contains("Stopped Jolokia for PID " + getPID(process));
44+
.contains("Stopped Jolokia for PID " + process);
4145
}
4246

4347
@Test

dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/OpenApiITCase.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
import org.apache.camel.dsl.jbang.it.support.InVersion;
3131
import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
3232
import org.assertj.core.api.Assertions;
33+
import org.junit.jupiter.api.Tag;
3334
import org.junit.jupiter.api.Test;
3435
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
3536

37+
@Tag("container-only")
3638
public class OpenApiITCase extends JBangTestSupport {
3739

3840
final HttpClient httpClient = HttpClient.newHttpClient();

0 commit comments

Comments
 (0)