diff --git a/docker-edge/.env b/docker-edge/.env index 44758df43d..dd550ac198 100644 --- a/docker-edge/.env +++ b/docker-edge/.env @@ -5,3 +5,6 @@ TB_VERSION=3.9.0-RC TB_EDGE_DOCKER_NAME=tb-edge TB_EDGE_VERSION=3.9.0EDGE-RC + +TB_EDGE_OLD_VERSION_3_7=3.7.0EDGE +TB_EDGE_OLD_VERSION_3_8=3.8.0EDGE diff --git a/docker-edge/docker-compose.postgres.yml b/docker-edge/docker-compose.postgres.yml index 8daa940367..441c628050 100644 --- a/docker-edge/docker-compose.postgres.yml +++ b/docker-edge/docker-compose.postgres.yml @@ -23,7 +23,7 @@ services: ports: - "5432" environment: - POSTGRES_MULTIPLE_DATABASES: '"thingsboard","tb_edge_1","tb_edge_2"' + POSTGRES_MULTIPLE_DATABASES: '"thingsboard","tb_edge_1","tb_edge_2","tb_edge_3","tb_edge_4"' POSTGRES_PASSWORD: postgres volumes: - ./tb-node/postgres:/var/lib/postgresql/data @@ -44,3 +44,13 @@ services: - tb-edge.env depends_on: - postgres + tb-edge-3: + env_file: + - tb-edge.env + depends_on: + - postgres + tb-edge-4: + env_file: + - tb-edge.env + depends_on: + - postgres \ No newline at end of file diff --git a/docker-edge/docker-compose.volumes.yml b/docker-edge/docker-compose.volumes.yml index 48f4ec9cb1..316faa6e5b 100644 --- a/docker-edge/docker-compose.volumes.yml +++ b/docker-edge/docker-compose.volumes.yml @@ -31,6 +31,14 @@ services: volumes: - tb-edge-log-volume-2:/var/log/tb-edge - tb-edge-data-volume-2:/data + tb-edge-3: + volumes: + - tb-edge-log-volume-3:/var/log/tb-edge + - tb-edge-data-volume-3:/data + tb-edge-4: + volumes: + - tb-edge-log-volume-4:/var/log/tb-edge + - tb-edge-data-volume-4:/data volumes: postgres-db-volume: external: @@ -49,4 +57,16 @@ volumes: name: ${TB_EDGE_LOG_VOLUME_2} tb-edge-data-volume-2: external: - name: ${TB_EDGE_DATA_VOLUME_2} \ No newline at end of file + name: ${TB_EDGE_DATA_VOLUME_2} + tb-edge-log-volume-3: + external: + name: ${TB_EDGE_LOG_VOLUME_3} + tb-edge-data-volume-3: + external: + name: ${TB_EDGE_DATA_VOLUME_3} + tb-edge-log-volume-4: + external: + name: ${TB_EDGE_LOG_VOLUME_4} + tb-edge-data-volume-4: + external: + name: ${TB_EDGE_DATA_VOLUME_4} diff --git a/docker-edge/docker-compose.yml b/docker-edge/docker-compose.yml index 9b849b4de0..13dc7efa13 100644 --- a/docker-edge/docker-compose.yml +++ b/docker-edge/docker-compose.yml @@ -35,6 +35,8 @@ services: - tb-edge.env volumes: - ./tb-edge/conf:/config + depends_on: + - tb-monolith tb-edge-2: restart: always image: "${DOCKER_REPO}/${TB_EDGE_DOCKER_NAME}:${TB_EDGE_VERSION}" @@ -54,6 +56,46 @@ services: - tb-edge.env volumes: - ./tb-edge/conf:/config + depends_on: + - tb-monolith + tb-edge-3: + restart: always + image: "${DOCKER_REPO}/${TB_EDGE_DOCKER_NAME}:${TB_EDGE_OLD_VERSION_3_8}" + ports: + - "8084" + - "1885" + environment: + CLOUD_ROUTING_KEY: "${CLOUD_ROUTING_KEY_3}" + CLOUD_ROUTING_SECRET: "${CLOUD_ROUTING_SECRET_3}" + SPRING_DATASOURCE_URL: "${SPRING_DATASOURCE_URL_3}" + CLOUD_RPC_HOST: "${CLOUD_RPC_HOST}" + HTTP_BIND_PORT: "8084" + CONF_FOLDER: "/config" + env_file: + - tb-edge.env + volumes: + - ./tb-edge/conf:/config + depends_on: + - tb-monolith + tb-edge-4: + restart: always + image: "${DOCKER_REPO}/${TB_EDGE_DOCKER_NAME}:${TB_EDGE_OLD_VERSION_3_7}" + ports: + - "8085" + - "1886" + environment: + CLOUD_ROUTING_KEY: "${CLOUD_ROUTING_KEY_4}" + CLOUD_ROUTING_SECRET: "${CLOUD_ROUTING_SECRET_4}" + SPRING_DATASOURCE_URL: "${SPRING_DATASOURCE_URL_4}" + CLOUD_RPC_HOST: "${CLOUD_RPC_HOST}" + HTTP_BIND_PORT: "8085" + CONF_FOLDER: "/config" + env_file: + - tb-edge.env + volumes: + - ./tb-edge/conf:/config + depends_on: + - tb-monolith kafka-edge-2: restart: always image: "bitnami/kafka:3.8.1" diff --git a/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/AbstractContainerTest.java b/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/AbstractContainerTest.java index a3d8dd6c96..cad67c50c0 100644 --- a/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/AbstractContainerTest.java +++ b/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/AbstractContainerTest.java @@ -112,7 +112,9 @@ public abstract class AbstractContainerTest { public static final List edgeConfigurations = Arrays.asList( new TestEdgeConfiguration("280629c7-f853-ee3d-01c0-fffbb6f2ef38", "g9ta4soeylw6smqkky8g", 8082, 1, "Edge-in-memory"), - new TestEdgeConfiguration("e29dadb1-c487-3b9e-1b5a-02193191c90e", "dmb17p71vz9svfl7tgnz", 8083, 2, "Edge-kafka")); + new TestEdgeConfiguration("e29dadb1-c487-3b9e-1b5a-02193191c90e", "dmb17p71vz9svfl7tgnz", 8083, 2, "Edge-kafka"), + new TestEdgeConfiguration("2cc28012-a2f3-8bff-7b1a-5e686c972e1e", "z2d2z90fqjylht011ram", 8084, 3, "Edge-version-3-8"), + new TestEdgeConfiguration("774e5e4e-8ec7-9945-1c6a-4d6ba08cb5fc", "om3zzzadzlugth03nibn", 8085, 4, "Edge-version-3-7")); protected static List testParameters = new ArrayList<>(); diff --git a/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java b/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java index 000a3337d3..f643f62830 100644 --- a/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java +++ b/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java @@ -22,9 +22,11 @@ import org.junit.extensions.cpsuite.ClasspathSuite; import org.junit.runner.RunWith; import org.testcontainers.containers.DockerComposeContainer; +import org.testcontainers.containers.wait.strategy.Wait; import java.io.File; import java.io.IOException; +import java.time.Duration; import java.util.HashMap; import java.util.UUID; @@ -72,6 +74,7 @@ public void stop() { super.stop(); tryDeleteDir(targetDir); } + } testContainer = new DockerComposeContainerImpl<>( @@ -84,12 +87,12 @@ public void stop() { .withTailChildContainers(true) .withEnv(installTb.getEnv()) .withEnv(env) - .withExposedService(TB_MONOLITH_SERVICE_NAME, 8080) - .withExposedService("kafka", 9092); + .withExposedService(TB_MONOLITH_SERVICE_NAME, 8080, Wait.defaultWaitStrategy().withStartupTimeout(Duration.ofMinutes(3))) + .withExposedService("kafka", 9092, Wait.defaultWaitStrategy().withStartupTimeout(Duration.ofMinutes(3))); for (TestEdgeConfiguration edgeConfiguration : edgeConfigurations) { - testContainer.withExposedService(TB_EDGE_SERVICE_NAME + "-" + edgeConfiguration.getIdx(), edgeConfiguration.getPort()); + testContainer.withExposedService(TB_EDGE_SERVICE_NAME + "-" + edgeConfiguration.getIdx(), edgeConfiguration.getPort(), Wait.defaultWaitStrategy().withStartupTimeout(Duration.ofMinutes(3))); if (edgeConfiguration.getName().contains("kafka")) { - testContainer.withExposedService("kafka-edge-" + edgeConfiguration.getIdx(), 9092); + testContainer.withExposedService("kafka-edge-" + edgeConfiguration.getIdx(), 9092, Wait.defaultWaitStrategy().withStartupTimeout(Duration.ofMinutes(3))); } } @@ -109,4 +112,5 @@ private static void tryDeleteDir(String targetDir) { log.error("Can't delete temp directory " + targetDir, e); } } + } diff --git a/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/ThingsBoardDbInstaller.java b/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/ThingsBoardDbInstaller.java index 14de7ef4da..04e374791b 100644 --- a/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/ThingsBoardDbInstaller.java +++ b/msa/edge-black-box-tests/src/test/java/org/thingsboard/server/msa/ThingsBoardDbInstaller.java @@ -29,6 +29,8 @@ import java.util.List; import java.util.Map; +import static org.thingsboard.server.msa.AbstractContainerTest.edgeConfigurations; + @Slf4j public class ThingsBoardDbInstaller extends ExternalResource { @@ -71,10 +73,13 @@ public ThingsBoardDbInstaller() { } env.put("POSTGRES_DATA_VOLUME", postgresDataVolume); env.put("TB_LOG_VOLUME", tbLogVolume); - for (int edgeEnv = 1; edgeEnv <= 2; edgeEnv++) { - env.put("SPRING_DATASOURCE_URL_" + edgeEnv, "jdbc:postgresql://postgres:5432/tb_edge_" + edgeEnv); - env.put("TB_EDGE_LOG_VOLUME_" + edgeEnv, tbEdgeLogVolume + "-" + edgeEnv); - env.put("TB_EDGE_DATA_VOLUME_" + edgeEnv, tbEdgeDataVolume + "-" + edgeEnv); + + for (TestEdgeConfiguration config : edgeConfigurations) { + env.put("SPRING_DATASOURCE_URL_" + config.getIdx(), "jdbc:postgresql://postgres:5432/tb_edge_" + config.getIdx()); + env.put("TB_EDGE_LOG_VOLUME_" + config.getIdx(), tbEdgeLogVolume + "-" + config.getIdx()); + env.put("TB_EDGE_DATA_VOLUME_" + config.getIdx(), tbEdgeDataVolume + "-" + config.getIdx()); + env.put("CLOUD_ROUTING_KEY_" + config.getIdx(), config.getRoutingKey()); + env.put("CLOUD_ROUTING_SECRET_" + config.getIdx(), config.getSecret()); } dockerCompose.withEnv(env); @@ -93,11 +98,11 @@ protected void before() throws Throwable { dockerCompose.withCommand("volume create " + tbLogVolume); dockerCompose.invokeDocker(); - for (int edgeEnv = 1; edgeEnv <= 2; edgeEnv++) { - dockerCompose.withCommand("volume create " + tbEdgeLogVolume + "-" + edgeEnv); + for (TestEdgeConfiguration config : edgeConfigurations) { + dockerCompose.withCommand("volume create " + tbEdgeLogVolume + "-" + config.getIdx()); dockerCompose.invokeDocker(); - dockerCompose.withCommand("volume create " + tbEdgeDataVolume + "-" + edgeEnv); + dockerCompose.withCommand("volume create " + tbEdgeDataVolume + "-" + config.getIdx()); dockerCompose.invokeDocker(); } @@ -107,14 +112,14 @@ protected void before() throws Throwable { dockerCompose.withCommand("run --no-deps --rm -e INSTALL_TB=true -e LOAD_DEMO=true tb-monolith"); dockerCompose.invokeCompose(); - for (int edgeEnv = 1; edgeEnv <= 2; edgeEnv++) { - dockerCompose.withCommand("run --no-deps --rm -e INSTALL_TB_EDGE=true -e LOAD_DEMO=true tb-edge" + "-" + edgeEnv); + for (TestEdgeConfiguration config : edgeConfigurations) { + dockerCompose.withCommand("run --no-deps --rm -e INSTALL_TB_EDGE=true -e LOAD_DEMO=true tb-edge" + "-" + config.getIdx()); dockerCompose.invokeCompose(); } dockerCompose.withCommand("exec -T postgres psql -U postgres -d thingsboard -f /custom-sql/thingsboard.sql"); dockerCompose.invokeCompose(); - for (int edgeEnv = 1; edgeEnv <= 2; edgeEnv++) { - dockerCompose.withCommand("exec -T postgres psql -U postgres -d tb_edge" + "_" + edgeEnv + " -f /custom-sql/tb_edge.sql"); + for (TestEdgeConfiguration config : edgeConfigurations) { + dockerCompose.withCommand("exec -T postgres psql -U postgres -d tb_edge" + "_" + config.getIdx() + " -f /custom-sql/tb_edge.sql"); dockerCompose.invokeCompose(); } } finally { @@ -130,11 +135,11 @@ protected void before() throws Throwable { @Override protected void after() { try { - for (int edgeEnv = 1; edgeEnv <= 2; edgeEnv++) { + for (TestEdgeConfiguration config : edgeConfigurations) { copyLogs(tbLogVolume, "./target/tb-logs/"); - copyLogs(tbEdgeLogVolume + "-" + edgeEnv, "./target/tb-edge-logs/"); + copyLogs(tbEdgeLogVolume + "-" + config.getIdx(), "./target/tb-edge-logs/"); - dockerCompose.withCommand("volume rm -f " + postgresDataVolume + " " + tbLogVolume + " " + tbEdgeLogVolume + "-" + edgeEnv); + dockerCompose.withCommand("volume rm -f " + postgresDataVolume + " " + tbLogVolume + " " + tbEdgeLogVolume + "-" + config.getIdx()); dockerCompose.invokeDocker(); } } catch (Exception e) {