Skip to content

Commit f8a630a

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

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-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>

tarantool-jackson-mapping/src/main/java/io/tarantool/mapping/crud/CrudResponse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public List<Field> getMetadata() throws CrudException {
6969
if (error != null) {
7070
throw new CrudException(error);
7171
}
72+
if (response == null) {
73+
return null;
74+
}
7275
return response.getMetadata();
7376
}
7477

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

Lines changed: 19 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,20 @@ 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 =
673+
String.format(COMMAND_TEMPLATE, routerPort, routerUsername, routerPassword, command);
674+
} else {
675+
bashCommand =
676+
String.format(
677+
ECHO_COMMAND_TEMPLATE,
678+
command,
679+
TT_COMMAND,
680+
routerUsername,
681+
routerPassword,
682+
routerPort);
683+
}
667684
return execInContainer("sh", "-c", bashCommand);
668685
} catch (IOException | InterruptedException e) {
669686
throw new RuntimeException(e);

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

Lines changed: 13 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 =
58+
TARANTOOL_VERSION.startsWith("2.") ? "tarantoolctl" : "tt";
59+
private static final String ECHO_COMMAND_TEMPLATE = "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,13 @@ 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,
384+
command,
385+
TT_COMMAND,
386+
routerUsername,
387+
routerPassword,
388+
routerPort);
378389
return execInContainer("/bin/sh", "-c", bashCommand);
379390
} catch (IOException | InterruptedException e) {
380391
throw new RuntimeException(e);

0 commit comments

Comments
 (0)