Skip to content

feat(testcontainers): refactor vshard and cartridge testcontainers#64

Open
Alex-pvl wants to merge 1 commit intomasterfrom
crud_tests_refactor
Open

feat(testcontainers): refactor vshard and cartridge testcontainers#64
Alex-pvl wants to merge 1 commit intomasterfrom
crud_tests_refactor

Conversation

@Alex-pvl
Copy link
Copy Markdown
Contributor

@Alex-pvl Alex-pvl commented Apr 1, 2026

I haven't forgotten about:

  • Tests
  • Changelog
  • Documentation
    • JavaDoc was written
  • Commit messages comply with the guideline
  • Cleanup the code for review. See checklist

Related issues:

@Alex-pvl Alex-pvl force-pushed the crud_tests_refactor branch 11 times, most recently from b4d9cf1 to 8da9e80 Compare April 3, 2026 06:03
@Alex-pvl Alex-pvl force-pushed the crud_tests_refactor branch from 8da9e80 to b3bed3d Compare April 3, 2026 06:57
@Alex-pvl Alex-pvl marked this pull request as ready for review April 3, 2026 06:58
@Alex-pvl Alex-pvl self-assigned this Apr 3, 2026
@Alex-pvl Alex-pvl requested a review from nickkkccc April 3, 2026 06:58
}

private static Integer parsePort(String uri) {
if (uri == null || uri.isEmpty()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (uri == null || uri.isEmpty()) {
if (uri == null || uri.isBlank()) {

Или trim и после проверять на empty

} else {
addExposedPorts(ArrayUtils.toPrimitive(configParser.getExposablePorts()));

if (!getDirectoryBinding().isEmpty()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!getDirectoryBinding().isEmpty()) {
if (!getDirectoryBinding().isBlank()) {

withFileSystemBind(getDirectoryBinding(), getInstanceDir(), BindMode.READ_WRITE);
}

if (!instanceNames.isEmpty()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!instanceNames.isEmpty()) {
if (!instanceNames.isBlank()) {

Comment on lines +487 to +510
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);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше вообще убрать Yaml зависимость, более эффективно использовать Jackson.

Для путей и директорий лучше всегда использовать Path, начиная с Java 8

}

protected String getFileName(String filePath) {
if (filePath == null || filePath.isEmpty()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (filePath == null || filePath.isEmpty()) {
if (filePath == null || filePath.isBlank()) {

if (lastColon >= 0) {
normalized = normalized.substring(lastColon + 1);
}
return Integer.parseInt(normalized);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return Integer.parseInt(normalized);
return Integer.parseUnsignedInt(normalized);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему решил не использовать org.testcontainers.containers.tarantool.config.ConfigurationUtils, в котором есть уже удобные методы для работы с конфигурацией Tarantool 3.x?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Идея была сделать единообразный интерфейс взаимодействия с кластером тестовым посредством конфигураторов (пример таких - 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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно использовать Jackson

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кажется это не относится к этому МР

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants