Add option compatibility for DockerComposeContainer to work locally with docker compose

This commit is contained in:
Andrii Landiak 2023-06-05 13:14:44 +03:00
parent c2a87aba60
commit 72423991b9
2 changed files with 15 additions and 4 deletions

View File

@ -156,6 +156,7 @@ public class ContainerTestSuite {
testContainer = new DockerComposeContainerImpl<>(composeFiles) testContainer = new DockerComposeContainerImpl<>(composeFiles)
.withPull(false) .withPull(false)
.withLocalCompose(true) .withLocalCompose(true)
.withOptions("--compatibility")
.withTailChildContainers(!skipTailChildContainers) .withTailChildContainers(!skipTailChildContainers)
.withEnv(installTb.getEnv()) .withEnv(installTb.getEnv())
.withEnv(queueEnv) .withEnv(queueEnv)

View File

@ -68,6 +68,7 @@ public class ThingsBoardDbInstaller {
public ThingsBoardDbInstaller() { public ThingsBoardDbInstaller() {
log.info("System property of blackBoxTests.redisCluster is {}", IS_REDIS_CLUSTER); log.info("System property of blackBoxTests.redisCluster is {}", IS_REDIS_CLUSTER);
log.info("System property of blackBoxTests.redisCluster is {}", IS_REDIS_SENTINEL);
log.info("System property of blackBoxTests.hybridMode is {}", IS_HYBRID_MODE); log.info("System property of blackBoxTests.hybridMode is {}", IS_HYBRID_MODE);
List<File> composeFiles = new ArrayList<>(Arrays.asList( List<File> composeFiles = new ArrayList<>(Arrays.asList(
new File("./../../docker/docker-compose.yml"), new File("./../../docker/docker-compose.yml"),
@ -240,13 +241,22 @@ public class ThingsBoardDbInstaller {
dockerCompose.withCommand("volume rm -f " + postgresDataVolume + " " + tbLogVolume + dockerCompose.withCommand("volume rm -f " + postgresDataVolume + " " + tbLogVolume +
" " + tbCoapTransportLogVolume + " " + tbLwm2mTransportLogVolume + " " + tbHttpTransportLogVolume + " " + tbCoapTransportLogVolume + " " + tbLwm2mTransportLogVolume + " " + tbHttpTransportLogVolume +
" " + tbMqttTransportLogVolume + " " + tbSnmpTransportLogVolume + " " + tbVcExecutorLogVolume + " " + tbMqttTransportLogVolume + " " + tbSnmpTransportLogVolume + " " + tbVcExecutorLogVolume + resolveComposeVolumeLog());
(IS_REDIS_CLUSTER
? IntStream.range(0, 6).mapToObj(i -> " " + redisClusterDataVolume + '-' + i).collect(Collectors.joining())
: redisDataVolume));
dockerCompose.invokeDocker(); dockerCompose.invokeDocker();
} }
private String resolveComposeVolumeLog() {
if (IS_REDIS_CLUSTER) {
return IntStream.range(0, 6).mapToObj(i -> " " + redisClusterDataVolume + "-" + i).collect(Collectors.joining());
}
if (IS_REDIS_SENTINEL) {
return redisSentinelDataVolume + "-" + "master " + " " +
redisSentinelDataVolume + "-" + "slave" + " " +
redisSentinelDataVolume + " " + "sentinel";
}
return redisDataVolume;
}
private void copyLogs(String volumeName, String targetDir) { private void copyLogs(String volumeName, String targetDir) {
File tbLogsDir = new File(targetDir); File tbLogsDir = new File(targetDir);
tbLogsDir.mkdirs(); tbLogsDir.mkdirs();