Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of edge older versions in BBT #137

Open
wants to merge 2 commits into
base: rc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docker-edge/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 11 additions & 1 deletion docker-edge/docker-compose.postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
22 changes: 21 additions & 1 deletion docker-edge/docker-compose.volumes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -49,4 +57,16 @@ volumes:
name: ${TB_EDGE_LOG_VOLUME_2}
tb-edge-data-volume-2:
external:
name: ${TB_EDGE_DATA_VOLUME_2}
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}
42 changes: 42 additions & 0 deletions docker-edge/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ public abstract class AbstractContainerTest {
public static final List<TestEdgeConfiguration> 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<TestEdgeRuntimeParameters> testParameters = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -72,6 +74,7 @@ public void stop() {
super.stop();
tryDeleteDir(targetDir);
}

}

testContainer = new DockerComposeContainerImpl<>(
Expand All @@ -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)));
}
}

Expand All @@ -109,4 +112,5 @@ private static void tryDeleteDir(String targetDir) {
log.error("Can't delete temp directory " + targetDir, e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
Expand All @@ -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();
}

Expand All @@ -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 {
Expand All @@ -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) {
Expand Down