Browse Source

Move CE-style edge cutoff back to 4.4.1

pull/16261/head
Nikita Mazurenko 2 months ago
parent
commit
b74cdd59b7
  1. 4
      application/src/main/java/org/thingsboard/server/service/agent/template/AppTemplateMaterializer.java
  2. 2
      application/src/main/java/org/thingsboard/server/service/agent/template/VersionFolders.java
  3. 16
      application/src/test/java/org/thingsboard/server/service/agent/template/AgentAppTemplateSyncServiceTest.java
  4. 14
      application/src/test/java/org/thingsboard/server/service/agent/template/AppTemplateMaterializerTest.java
  5. 4
      dao/src/main/java/org/thingsboard/server/dao/edge/EdgeEditionStyle.java

4
application/src/main/java/org/thingsboard/server/service/agent/template/AppTemplateMaterializer.java

@ -169,8 +169,8 @@ public class AppTemplateMaterializer {
/**
* Load the compose body for {@code path}, taking the file from the newest version folder that has it. For version
* {@code 4.4.1} and {@code compose/edge/4.4/kafka.yml} with folders {@code 4.3, 4.4, 4.4.0.1} under
* {@code compose/edge}, this tries {@code compose/edge/4.4.0.1/kafka.yml}, then {@code compose/edge/4.4/kafka.yml},
* {@code 4.4.2} and {@code compose/edge/4.4/kafka.yml} with folders {@code 4.3, 4.4, 4.4.1} under
* {@code compose/edge}, this tries {@code compose/edge/4.4.1/kafka.yml}, then {@code compose/edge/4.4/kafka.yml},
* then {@code compose/edge/4.3/kafka.yml}. Falls through to an error (so the version is skipped) only when no
* candidate exists.
*/

2
application/src/main/java/org/thingsboard/server/service/agent/template/VersionFolders.java

@ -9,7 +9,7 @@ import java.util.List;
import java.util.regex.Pattern;
/**
* Version-named folders of the templates repo (e.g. {@code templates/since/4.4.0.1}, {@code compose/edge/4.4}): a
* Version-named folders of the templates repo (e.g. {@code templates/since/4.4.1}, {@code compose/edge/4.4}): a
* folder applies to its own version and every later one, until a newer folder exists.
*/
final class VersionFolders {

16
application/src/test/java/org/thingsboard/server/service/agent/template/AgentAppTemplateSyncServiceTest.java

@ -151,7 +151,7 @@ class AgentAppTemplateSyncServiceTest {
}
@Test
void appendEdgeVersionSuffixSwitchesToCeStyleFrom4401() {
void appendEdgeVersionSuffixSwitchesToCeStyleFrom441() {
List<AppVersionDescriptor> result = AgentAppTemplateSyncService.appendEdgeVersionSuffix(List.of(
new AppVersionDescriptor("4.3.1.6", "4.4.0", true),
new AppVersionDescriptor("4.4.0", "4.4.0.1", false),
@ -159,9 +159,9 @@ class AgentAppTemplateSyncServiceTest {
new AppVersionDescriptor("4.4.1", null, false)));
assertThat(result).extracting(AppVersionDescriptor::getVersion)
.containsExactly("4.3.1.6EDGEPE", "4.4.0EDGEPE", "4.4.0.1EDGE", "4.4.1EDGE");
.containsExactly("4.3.1.6EDGEPE", "4.4.0EDGEPE", "4.4.0.1EDGEPE", "4.4.1EDGE");
assertThat(result).extracting(AppVersionDescriptor::getNextVersion)
.containsExactly("4.4.0EDGEPE", "4.4.0.1EDGE", "4.4.1EDGE", null);
.containsExactly("4.4.0EDGEPE", "4.4.0.1EDGEPE", "4.4.1EDGE", null);
}
@Test
@ -175,19 +175,19 @@ class AgentAppTemplateSyncServiceTest {
@Test
void sinceFolderReplacesOnlyTheTemplatesItContains() {
AgentAppTemplateSyncService service = serviceWithTemplateFiles("4.4.0.1PE-SNAPSHOT");
AgentAppTemplateSyncService service = serviceWithTemplateFiles("4.4.1PE-SNAPSHOT");
assertThat(service.getTemplateFiles()).extracting(RepoFile::path).containsExactlyInAnyOrder(
"templates/since/4.4.0.1/template-EDGE-DOCKER_COMPOSE.json",
"templates/since/4.4.1/template-EDGE-DOCKER_COMPOSE.json",
"templates/template-GATEWAY-DOCKER_COMPOSE.json");
}
@Test
void versionWithoutItsOwnSinceFolderUsesTheNewestLowerOne() {
AgentAppTemplateSyncService service = serviceWithTemplateFiles("4.4.1");
AgentAppTemplateSyncService service = serviceWithTemplateFiles("4.4.2");
assertThat(service.getTemplateFiles()).extracting(RepoFile::path).containsExactlyInAnyOrder(
"templates/since/4.4.0.1/template-EDGE-DOCKER_COMPOSE.json",
"templates/since/4.4.1/template-EDGE-DOCKER_COMPOSE.json",
"templates/template-GATEWAY-DOCKER_COMPOSE.json");
}
@ -209,7 +209,7 @@ class AgentAppTemplateSyncServiceTest {
file("templates/README.md")));
when(gitSyncService.listFiles("agent-app-templates", "templates/since", 3, FileType.FILE)).thenReturn(List.of(
file("templates/since/4.9/template-EDGE-DOCKER_COMPOSE.json"),
file("templates/since/4.4.0.1/template-EDGE-DOCKER_COMPOSE.json"),
file("templates/since/4.4.1/template-EDGE-DOCKER_COMPOSE.json"),
file("templates/since/4.5/template-GATEWAY-DOCKER_COMPOSE.json"),
file("templates/since/4.11/template-GATEWAY-DOCKER_COMPOSE.json"),
file("templates/since/draft/template-EDGE-DOCKER_COMPOSE.json")));

14
application/src/test/java/org/thingsboard/server/service/agent/template/AppTemplateMaterializerTest.java

@ -14,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class AppTemplateMaterializerTest {
private static final Function<String, List<String>> EDGE_FOLDERS = parent -> parent.equals("compose/edge")
? List.of("3.9", "4.3", "4.4", "4.4.0.1", "4.10", "latest")
? List.of("3.9", "4.3", "4.4", "4.4.1", "4.10", "latest")
: List.of();
@Test
@ -27,25 +27,25 @@ class AppTemplateMaterializerTest {
@Test
void versionWithItsOwnFolderUsesItFirst() {
assertThat(candidates("compose/edge/4.4/kafka.yml", "4.4", "4.4.0.1EDGE")).startsWith(
"compose/edge/4.4.0.1/kafka.yml",
assertThat(candidates("compose/edge/4.4/kafka.yml", "4.4", "4.4.1EDGE")).startsWith(
"compose/edge/4.4.1/kafka.yml",
"compose/edge/4.4/kafka.yml");
}
@Test
void versionWithoutItsOwnFolderFallsBackToTheNewestLowerOne() {
assertThat(candidates("compose/edge/4.4/kafka.yml", "4.4", "4.4.1EDGE")).startsWith(
"compose/edge/4.4.0.1/kafka.yml",
assertThat(candidates("compose/edge/4.4/kafka.yml", "4.4", "4.4.2EDGE")).startsWith(
"compose/edge/4.4.1/kafka.yml",
"compose/edge/4.4/kafka.yml");
assertThat(candidates("compose/edge/4.5/kafka.yml", "4.5", "4.5.0EDGE")).startsWith(
"compose/edge/4.4.0.1/kafka.yml");
"compose/edge/4.4.1/kafka.yml");
}
@Test
void foldersAreComparedAsVersions() {
assertThat(candidates("compose/edge/4.10/kafka.yml", "4.10", "4.10.0EDGE")).startsWith(
"compose/edge/4.10/kafka.yml",
"compose/edge/4.4.0.1/kafka.yml");
"compose/edge/4.4.1/kafka.yml");
}
@Test

4
dao/src/main/java/org/thingsboard/server/dao/edge/EdgeEditionStyle.java

@ -17,11 +17,11 @@ public enum EdgeEditionStyle {
private final String packageSuffix;
public static EdgeEditionStyle getEdgeEditionStyle(String edgeVersion) {
return TbVersionUtils.compare(edgeVersion, "4.4.0.1") >= 0 ? CE : PE;
return TbVersionUtils.compare(edgeVersion, "4.4.1") >= 0 ? CE : PE;
}
/**
* The edge version with the tag suffix its release is published under, e.g. {@code 4.4.0EDGEPE}, {@code 4.4.0.1EDGE}.
* The edge version with the tag suffix its release is published under, e.g. {@code 4.4.0EDGEPE}, {@code 4.4.1EDGE}.
* Agent app templates are registered under these versions.
*/
public static String withVersionSuffix(String edgeVersion) {

Loading…
Cancel
Save