feat(testcontainers): refactor vshard and cartridge testcontainers#64
feat(testcontainers): refactor vshard and cartridge testcontainers#64
Conversation
b4d9cf1 to
8da9e80
Compare
8da9e80 to
b3bed3d
Compare
| } | ||
|
|
||
| private static Integer parsePort(String uri) { | ||
| if (uri == null || uri.isEmpty()) { |
There was a problem hiding this comment.
| if (uri == null || uri.isEmpty()) { | |
| if (uri == null || uri.isBlank()) { |
Или trim и после проверять на empty
| } else { | ||
| addExposedPorts(ArrayUtils.toPrimitive(configParser.getExposablePorts())); | ||
|
|
||
| if (!getDirectoryBinding().isEmpty()) { |
There was a problem hiding this comment.
| if (!getDirectoryBinding().isEmpty()) { | |
| if (!getDirectoryBinding().isBlank()) { |
| withFileSystemBind(getDirectoryBinding(), getInstanceDir(), BindMode.READ_WRITE); | ||
| } | ||
|
|
||
| if (!instanceNames.isEmpty()) { |
There was a problem hiding this comment.
| if (!instanceNames.isEmpty()) { | |
| if (!instanceNames.isBlank()) { |
| protected String getFileName(String filePath) { | ||
| if (filePath == null || filePath.isEmpty()) { | ||
| throw new IllegalArgumentException("File path must not be null or empty"); | ||
| } | ||
| int idx = filePath.lastIndexOf('/'); | ||
| return idx >= 0 ? filePath.substring(idx + 1) : filePath; | ||
| } | ||
|
|
||
| private List<String> parseInstanceNames(String instancesPath) { | ||
| try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(instancesPath)) { | ||
| if (inputStream == null) { | ||
| throw new IllegalArgumentException( | ||
| String.format("No resource path found for the specified resource %s", instancesPath)); | ||
| } | ||
| Object parsed = new Yaml().load(inputStream); | ||
| if (!(parsed instanceof Map<?, ?>)) { | ||
| return Collections.emptyList(); | ||
| } | ||
| return ((Map<?, ?>) parsed) | ||
| .keySet().stream().map(String::valueOf).collect(Collectors.toList()); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } |
There was a problem hiding this comment.
Лучше вообще убрать Yaml зависимость, более эффективно использовать Jackson.
Для путей и директорий лучше всегда использовать Path, начиная с Java 8
| } | ||
|
|
||
| protected String getFileName(String filePath) { | ||
| if (filePath == null || filePath.isEmpty()) { |
There was a problem hiding this comment.
| if (filePath == null || filePath.isEmpty()) { | |
| if (filePath == null || filePath.isBlank()) { |
| if (lastColon >= 0) { | ||
| normalized = normalized.substring(lastColon + 1); | ||
| } | ||
| return Integer.parseInt(normalized); |
There was a problem hiding this comment.
| return Integer.parseInt(normalized); | |
| return Integer.parseUnsignedInt(normalized); |
There was a problem hiding this comment.
Почему решил не использовать org.testcontainers.containers.tarantool.config.ConfigurationUtils, в котором есть уже удобные методы для работы с конфигурацией Tarantool 3.x?
There was a problem hiding this comment.
Идея была сделать единообразный интерфейс взаимодействия с кластером тестовым посредством конфигураторов (пример таких - TDGConfigurator). И чтобы контейнеры имели один и тот же API
| import org.testcontainers.containers.utils.SslContext; | ||
| import org.testcontainers.containers.utils.TarantoolContainerClientHelper; | ||
| import org.testcontainers.images.builder.ImageFromDockerfile; | ||
| import org.yaml.snakeyaml.Yaml; |
There was a problem hiding this comment.
Нужно использовать Jackson
There was a problem hiding this comment.
Кажется это не относится к этому МР
I haven't forgotten about:
Related issues: