Skip to content

Commit 2b7a5ed

Browse files
committed
feat(testcontainers): edit vshard and cartridge
1 parent ed78301 commit 2b7a5ed

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,6 @@
396396
<include>**/integration/**/*Crud*Test.java</include>
397397
<include>**/crud/**/*Test.java</include>
398398
</includes>
399-
<excludes>
400-
<exclude>**/io/tarantool/spring/data*/integration/**/*Test.java</exclude>
401-
</excludes>
402399
<argLine>@{argLine} -Xmx1024m</argLine>
403400
</configuration>
404401
</plugin>

testcontainers/src/main/java/org/testcontainers/containers/TarantoolCartridgeContainer.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public class TarantoolCartridgeContainer extends GenericContainer<TarantoolCartr
5454
protected static final int TIMEOUT_ROUTER_UP_CARTRIDGE_HEALTH_IN_SECONDS = 60;
5555

5656
private static final String TMP_DIR = "/tmp";
57+
private static final String TARANTOOL_VERSION =
58+
System.getenv().getOrDefault("TARANTOOL_VERSION", "2.11.8-ubuntu20.04");
59+
private static final boolean IS_TARANTOOL2 = TARANTOOL_VERSION.startsWith("2.");
60+
private static final String TT_COMMAND = IS_TARANTOOL2 ? "tarantoolctl" : "tt";
61+
private static final String ECHO_COMMAND_TEMPLATE = "echo \"%s\" | %s connect %s:%s@localhost:%d";
5762

5863
/**
5964
* Runs a Lua command inside the container by connecting via net.box and returns YAML-encoded
@@ -662,8 +667,14 @@ public ExecResult executeCommand(String command) {
662667
throw new IllegalStateException("Cannot execute commands in stopped container");
663668
}
664669
command = command.replace("\"", "\\\"").replace("\'", "\\\'");
665-
String bashCommand =
666-
String.format(COMMAND_TEMPLATE, routerPort, routerUsername, routerPassword, command);
670+
String bashCommand;
671+
if (IS_TARANTOOL2) {
672+
bashCommand = String.format(COMMAND_TEMPLATE, routerPort, routerUsername, routerPassword, command);
673+
} else {
674+
bashCommand =
675+
String.format(
676+
ECHO_COMMAND_TEMPLATE, command, TT_COMMAND, routerUsername, routerPassword, routerPort);
677+
}
667678
return execInContainer("sh", "-c", bashCommand);
668679
} catch (IOException | InterruptedException e) {
669680
throw new RuntimeException(e);

testcontainers/src/main/java/org/testcontainers/containers/VshardClusterContainer.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ public class VshardClusterContainer extends GenericContainer<VshardClusterContai
5252
protected static final int TIMEOUT_CRUD_HEALTH_IN_SECONDS = 60;
5353

5454
private static final String TMP_DIR = "/tmp";
55-
private static final String ECHO_COMMAND_TEMPLATE = "echo \"%s\" | tt connect %s:%s@localhost:%d";
55+
private static final String TARANTOOL_VERSION =
56+
System.getenv().getOrDefault("TARANTOOL_VERSION", "2.11.8-ubuntu20.04");
57+
private static final String TT_COMMAND = TARANTOOL_VERSION.startsWith("2.") ? "tarantoolctl" : "tt";
58+
private static final String ECHO_COMMAND_TEMPLATE =
59+
"echo \"%s\" | %s connect %s:%s@localhost:%d";
5660

5761
protected final String TARANTOOL_RUN_DIR;
5862
private final TarantoolConfigParser configParser;
@@ -340,6 +344,7 @@ protected boolean crudIsUp() {
340344
String.format(
341345
ECHO_COMMAND_TEMPLATE,
342346
"return require('crud')._VERSION",
347+
TT_COMMAND,
343348
routerUsername,
344349
routerPassword,
345350
routerPort));
@@ -374,7 +379,8 @@ public ExecResult executeCommand(String command) {
374379
}
375380
command = command.replace("\"", "\\\"");
376381
String bashCommand =
377-
String.format(ECHO_COMMAND_TEMPLATE, command, routerUsername, routerPassword, routerPort);
382+
String.format(
383+
ECHO_COMMAND_TEMPLATE, command, TT_COMMAND, routerUsername, routerPassword, routerPort);
378384
return execInContainer("/bin/sh", "-c", bashCommand);
379385
} catch (IOException | InterruptedException e) {
380386
throw new RuntimeException(e);

0 commit comments

Comments
 (0)