Skip to content

Commit 5408621

Browse files
fjtiradotreblereel
authored andcommitted
Disable test if docker is not
Signed-off-by: fjtirado <ftirados@redhat.com> Signed-off-by: Dmitrii Tikhomirov <chani.liet@gmail.com>
1 parent a908e3e commit 5408621

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

impl/test/src/test/java/io/serverlessworkflow/impl/test/ContainerTest.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,45 @@
4141
import org.junit.jupiter.api.AfterAll;
4242
import org.junit.jupiter.api.BeforeAll;
4343
import org.junit.jupiter.api.Test;
44+
import org.junit.jupiter.api.condition.DisabledIf;
45+
import org.slf4j.Logger;
46+
import org.slf4j.LoggerFactory;
4447

48+
@DisabledIf("checkDocker")
4549
public class ContainerTest {
4650

4751
private static DockerClient dockerClient;
48-
private static WorkflowApplication app;
52+
private static Logger logger = LoggerFactory.getLogger(ContainerTest.class);
4953

50-
@BeforeAll
51-
static void init() {
54+
{
5255
DefaultDockerClientConfig defaultConfig =
5356
DefaultDockerClientConfig.createDefaultConfigBuilder().build();
5457
dockerClient =
5558
DockerClientImpl.getInstance(
5659
defaultConfig,
5760
new ApacheDockerHttpClient.Builder().dockerHost(defaultConfig.getDockerHost()).build());
61+
}
62+
63+
@SuppressWarnings("unused")
64+
private static boolean checkDocker() {
65+
try {
66+
dockerClient.pingCmd().exec();
67+
return false;
68+
} catch (Exception ex) {
69+
logger.warn("Docker is not running, disabling container test");
70+
return true;
71+
}
72+
}
73+
74+
private static WorkflowApplication app;
75+
76+
@BeforeAll
77+
static void init() {
5878
app = WorkflowApplication.builder().build();
5979
}
6080

6181
@AfterAll
6282
static void cleanup() throws IOException {
63-
dockerClient.close();
6483
app.close();
6584
}
6685

0 commit comments

Comments
 (0)