Skip to content

Commit e472eb6

Browse files
committed
Skip container tests if docker is not available
Skip all container tests if no docker engine is running. Remove disabling the tests on Windows: also run these tests on Windows if a docker engine is available. (The CI Windows runners don't have docker.)
1 parent 96661c0 commit e472eb6

11 files changed

Lines changed: 12 additions & 108 deletions

File tree

sshd-common/src/test/java/org/apache/sshd/util/test/ContainerTestCase.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

sshd-core/pom.xml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -286,26 +286,5 @@
286286
</plugins>
287287
</build>
288288
</profile>
289-
<!-- this profile changes the maven-surefire-plugin plugin to skip tests with @Category(ContainerTestCase.class) -->
290-
<!-- it's activated on Windows, the GitHub actions Windows VMs do not have any Linux Docker support -->
291-
<profile>
292-
<id>no-containers-for-windows</id>
293-
<activation>
294-
<os>
295-
<family>windows</family>
296-
</os>
297-
</activation>
298-
<build>
299-
<plugins>
300-
<plugin>
301-
<groupId>org.apache.maven.plugins</groupId>
302-
<artifactId>maven-surefire-plugin</artifactId>
303-
<configuration>
304-
<excludedGroups>ContainerTestCase</excludedGroups>
305-
</configuration>
306-
</plugin>
307-
</plugins>
308-
</build>
309-
</profile>
310289
</profiles>
311290
</project>

sshd-core/src/test/java/org/apache/sshd/client/auth/pubkey/HostBoundPubKeyAuthTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
2929
import org.apache.sshd.util.test.BaseTestSupport;
3030
import org.apache.sshd.util.test.CommonTestSupportUtils;
31-
import org.junit.jupiter.api.Tag;
3231
import org.junit.jupiter.params.ParameterizedTest;
3332
import org.junit.jupiter.params.provider.MethodSource;
3433
import org.slf4j.Logger;
@@ -41,8 +40,7 @@
4140
import org.testcontainers.junit.jupiter.Testcontainers;
4241
import org.testcontainers.utility.MountableFile;
4342

44-
@Tag("ContainerTestCase")
45-
@Testcontainers
43+
@Testcontainers(disabledWithoutDocker = true)
4644
public class HostBoundPubKeyAuthTest extends BaseTestSupport {
4745

4846
private static final Logger LOG = LoggerFactory.getLogger(HostBoundPubKeyAuthTest.class);

sshd-core/src/test/java/org/apache/sshd/client/opensshcerts/ClientOpenSSHCertificatesTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import org.apache.sshd.util.test.CommonTestSupportUtils;
4444
import org.bouncycastle.jce.provider.BouncyCastleProvider;
4545
import org.junit.jupiter.api.BeforeAll;
46-
import org.junit.jupiter.api.Tag;
4746
import org.junit.jupiter.params.ParameterizedTest;
4847
import org.junit.jupiter.params.provider.MethodSource;
4948
import org.testcontainers.containers.GenericContainer;
@@ -52,8 +51,7 @@
5251
import org.testcontainers.junit.jupiter.Testcontainers;
5352
import org.testcontainers.utility.MountableFile;
5453

55-
@Tag("ContainerTestCase")
56-
@Testcontainers
54+
@Testcontainers(disabledWithoutDocker = true)
5755
public class ClientOpenSSHCertificatesTest extends BaseTestSupport {
5856

5957
/**

sshd-core/src/test/java/org/apache/sshd/common/cipher/OpenSshCipherTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.bouncycastle.jce.provider.BouncyCastleProvider;
3434
import org.junit.jupiter.api.AfterEach;
3535
import org.junit.jupiter.api.BeforeEach;
36-
import org.junit.jupiter.api.Tag;
3736
import org.junit.jupiter.params.ParameterizedTest;
3837
import org.junit.jupiter.params.provider.MethodSource;
3938
import org.slf4j.Logger;
@@ -46,15 +45,12 @@
4645
import org.testcontainers.junit.jupiter.Testcontainers;
4746
import org.testcontainers.utility.MountableFile;
4847

49-
import static org.junit.jupiter.api.Assertions.assertTrue;
50-
5148
/**
5249
* Test ciphers against OpenSSH. Force resetting ciphers every time to verify that they are res-initialized correctly.
5350
*
5451
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
5552
*/
56-
@Tag("ContainerTestCase")
57-
@Testcontainers
53+
@Testcontainers(disabledWithoutDocker = true)
5854
public class OpenSshCipherTest extends BaseTestSupport {
5955

6056
private static final Logger LOG = LoggerFactory.getLogger(OpenSshCipherTest.class);

sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingWithOpenSshTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,18 @@
4343
import org.apache.sshd.util.test.CoreTestSupportUtils;
4444
import org.junit.jupiter.api.AfterEach;
4545
import org.junit.jupiter.api.BeforeEach;
46-
import org.junit.jupiter.api.Tag;
4746
import org.junit.jupiter.api.io.TempDir;
4847
import org.junit.jupiter.params.ParameterizedTest;
4948
import org.junit.jupiter.params.provider.MethodSource;
5049
import org.slf4j.Logger;
5150
import org.slf4j.LoggerFactory;
52-
import org.testcontainers.Testcontainers;
5351
import org.testcontainers.containers.GenericContainer;
5452
import org.testcontainers.containers.output.Slf4jLogConsumer;
5553
import org.testcontainers.containers.wait.strategy.Wait;
5654
import org.testcontainers.images.builder.ImageFromDockerfile;
55+
import org.testcontainers.junit.jupiter.Testcontainers;
5756
import org.testcontainers.utility.MountableFile;
5857

59-
import static org.junit.jupiter.api.Assertions.assertFalse;
60-
import static org.junit.jupiter.api.Assertions.assertTrue;
61-
6258
/**
6359
* Test setup: run a gRPC server on localhost; run an Apache MINA sshd server on localhost. Run an OpenSSH client in a
6460
* container, set up to remote forward a port on the SSH server to the gRPC server. Then connect to the gRPC server via
@@ -79,7 +75,7 @@
7975
* @see <a href="https://issues.apache.org/jira/browse/SSHD-1055">SSHD-1055</a>
8076
* @see <a href="https://issues.apache.org/jira/browse/SSHD-1269">SSHD-1269</a>
8177
*/
82-
@Tag("ContainerTestCase")
78+
@Testcontainers(disabledWithoutDocker = true)
8379
public class PortForwardingWithOpenSshTest extends BaseTestSupport {
8480

8581
private static final Logger LOG = LoggerFactory.getLogger(PortForwardingWithOpenSshTest.class);
@@ -201,7 +197,7 @@ public void forwardingWithConnectionClose(String portToForward) throws Exception
201197
.waitingFor(Wait.forLogMessage(".*forwarding_success.*\n", 1))
202198
.withLogConsumer(new Slf4jLogConsumer(LOG));
203199
try {
204-
Testcontainers.exposeHostPorts(sshPort, gRpcPort);
200+
org.testcontainers.Testcontainers.exposeHostPorts(sshPort, gRpcPort);
205201
sshdContainer.start();
206202
forwardingSetup.await();
207203
assertTrue(forwardedPort > 0, "Server should listen on port");

sshd-core/src/test/java/org/apache/sshd/common/kex/OpenSshMlKemTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.bouncycastle.jce.provider.BouncyCastleProvider;
3232
import org.junit.jupiter.api.Assumptions;
3333
import org.junit.jupiter.api.BeforeAll;
34-
import org.junit.jupiter.api.Tag;
3534
import org.junit.jupiter.api.Test;
3635
import org.slf4j.Logger;
3736
import org.slf4j.LoggerFactory;
@@ -48,8 +47,7 @@
4847
*
4948
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
5049
*/
51-
@Tag("ContainerTestCase")
52-
@Testcontainers
50+
@Testcontainers(disabledWithoutDocker = true)
5351
class OpenSshMlKemTest extends BaseTestSupport {
5452

5553
private static final Logger LOG = LoggerFactory.getLogger(OpenSshMlKemTest.class);

sshd-core/src/test/java/org/apache/sshd/common/kex/extension/StrictKexInteroperabilityTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.apache.sshd.util.test.CommonTestSupportUtils;
3737
import org.junit.jupiter.api.AfterEach;
3838
import org.junit.jupiter.api.BeforeEach;
39-
import org.junit.jupiter.api.Tag;
4039
import org.junit.jupiter.api.Test;
4140
import org.slf4j.Logger;
4241
import org.slf4j.LoggerFactory;
@@ -45,10 +44,9 @@
4544
import org.testcontainers.containers.wait.strategy.Wait;
4645
import org.testcontainers.images.builder.ImageFromDockerfile;
4746
import org.testcontainers.images.builder.dockerfile.DockerfileBuilder;
47+
import org.testcontainers.junit.jupiter.Testcontainers;
4848
import org.testcontainers.utility.MountableFile;
4949

50-
import static org.junit.jupiter.api.Assertions.assertTrue;
51-
5250
/**
5351
* Tests to ensure that an Apache MINA sshd client can talk to OpenSSH servers with or without "strict KEX". This
5452
* implicitly tests the message sequence number handling; if sequence numbers get out of sync or are reset wrongly,
@@ -57,7 +55,7 @@
5755
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
5856
* @see <A HREF="https://github.com/apache/mina-sshd/issues/445">Terrapin Mitigation: &quot;strict-kex&quot;</A>
5957
*/
60-
@Tag("ContainerTestCase")
58+
@Testcontainers(disabledWithoutDocker = true)
6159
public class StrictKexInteroperabilityTest extends BaseTestSupport {
6260

6361
private static final Logger LOG = LoggerFactory.getLogger(StrictKexInteroperabilityTest.class);

sshd-scp/pom.xml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -211,26 +211,5 @@
211211
</build>
212212
</profile>
213213

214-
<!-- this profile changes the maven-surefire-plugin plugin to skip tests with @Category(ContainerTestCase.class) -->
215-
<!-- it's activated on Windows, the GitHub actions Windows VMs do not have any Linux Docker support -->
216-
<profile>
217-
<id>no-containers-for-windows</id>
218-
<activation>
219-
<os>
220-
<family>windows</family>
221-
</os>
222-
</activation>
223-
<build>
224-
<plugins>
225-
<plugin>
226-
<groupId>org.apache.maven.plugins</groupId>
227-
<artifactId>maven-surefire-plugin</artifactId>
228-
<configuration>
229-
<excludedGroups>ContainerTestCase</excludedGroups>
230-
</configuration>
231-
</plugin>
232-
</plugins>
233-
</build>
234-
</profile>
235214
</profiles>
236215
</project>

sshd-scp/src/test/java/org/apache/sshd/scp/client/ScpCharsetTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.sshd.scp.common.ScpException;
3232
import org.apache.sshd.util.test.BaseTestSupport;
3333
import org.apache.sshd.util.test.CommonTestSupportUtils;
34-
import org.junit.jupiter.api.Tag;
3534
import org.junit.jupiter.api.Test;
3635
import org.junit.jupiter.api.io.TempDir;
3736
import org.slf4j.Logger;
@@ -44,18 +43,14 @@
4443
import org.testcontainers.junit.jupiter.Testcontainers;
4544
import org.testcontainers.utility.MountableFile;
4645

47-
import static org.junit.jupiter.api.Assertions.assertEquals;
48-
import static org.junit.jupiter.api.Assertions.assertFalse;
49-
5046
/**
5147
* Tests transferring a file named "äöü.txt" via SCP from a container that uses ISO-8859-15 as locale. The UTF-8 and
5248
* IOS-8859-15 encodings of these characters are different, so the file should not be found when the command is sent as
5349
* UTF-8, but should be found when sent as ISO-8859-1.
5450
*
5551
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
5652
*/
57-
@Tag("ContainerTestCase")
58-
@Testcontainers
53+
@Testcontainers(disabledWithoutDocker = true)
5954
public class ScpCharsetTest extends BaseTestSupport {
6055

6156
private static final Logger LOG = LoggerFactory.getLogger(ScpCharsetTest.class);

0 commit comments

Comments
 (0)