Skip to content

Commit 63b2277

Browse files
committed
Remove cartridge-java from dependencies
- Update executeScript and executeCommand methods to execute code viva execInContainer (now it returns yaml string in Container.ExecResult not CompletableFuture). - Remove TarantoolContainer containers with TarantoolClientBuilder parameter. - Remove getClient method from TarantoolContainerClientHelper. - Remove io.tarantool.cartridge-driver dependency. because cartridge-java client was also removed. - Add executeScriptDecoded and executeCommandDecoded methods to return parsed yaml not string. - Add withSsl and withKeyAndCertFiles methods to TarantoolContainer and TarantoolCartridgeContainer. - Rewrite tests and add new cases to support new API. - Update org.yaml.snakeyaml to 2.0 version. Closes #69
1 parent d9748eb commit 63b2277

6 files changed

+31
-26
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,10 @@ private void waitUntilTrue(int secondsToWait, Supplier<Boolean> waitFunc) {
616616

617617
private boolean routerIsUp() {
618618
String healthyCmd = " local cartridge = package.loaded['cartridge']" +
619-
" return assert(cartridge ~= nil)";
619+
" return cartridge ~= nil";
620620
try {
621-
ExecResult result = executeCommand(healthyCmd);
622-
return result.getStdout().equals("---\n- true\n...\n\n");
621+
List<?> result = executeCommandDecoded(healthyCmd);
622+
return result.get(0).getClass() == Boolean.class && (Boolean) result.get(0);
623623
} catch (Exception e) {
624624
logger().warn("Error while waiting for router instance to be up: " + e.getMessage());
625625
return false;
@@ -628,10 +628,10 @@ private boolean routerIsUp() {
628628

629629
private boolean isCartridgeHealthy() {
630630
String healthyCmd = " local cartridge = package.loaded['cartridge']" +
631-
" return assert(cartridge) and assert(cartridge.is_healthy())";
631+
" return cartridge ~= nil and cartridge.is_healthy()";
632632
try {
633-
ExecResult result = executeCommand(healthyCmd);
634-
return result.getStdout().equals("---\n- true\n...\n\n");
633+
List<?> result = executeCommandDecoded(healthyCmd);
634+
return result.get(0).getClass() == Boolean.class && (Boolean) result.get(0);
635635
} catch (Exception e) {
636636
logger().warn("Error while waiting for cartridge healthy state: " + e.getMessage());
637637
return false;

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,29 @@ public final class TarantoolContainerClientHelper {
2929
private static final String MTLS_COMMAND_TEMPLATE =
3030
"echo \" " +
3131
" print(require('yaml').encode( " +
32-
" require('net.box').connect( " +
33-
" { uri='%s:%d', params = { transport='ssl', ssl_key_file = '%s', ssl_cert_file = '%s' }}, " +
34-
" { user = '%s', password = '%s' } " +
35-
" ):eval('return %s')) " +
32+
" {require('net.box').connect( " +
33+
" { uri='%s:%d', params = { transport='ssl', ssl_key_file = '%s', ssl_cert_file = '%s' }}, " +
34+
" { user = '%s', password = '%s' } " +
35+
" ):eval('%s')}) " +
3636
" ); " +
3737
" os.exit(); " +
3838
"\" | tarantool";
3939
private static final String SSL_COMMAND_TEMPLATE =
4040
"echo \" " +
4141
" print(require('yaml').encode( " +
42-
" require('net.box').connect( " +
43-
" { uri='%s:%d', params = { transport='ssl' }}, " +
44-
" { user = '%s', password = '%s' } " +
45-
" ):eval('return %s')) " +
42+
" {require('net.box').connect( " +
43+
" { uri='%s:%d', params = { transport='ssl' }}, " +
44+
" { user = '%s', password = '%s' } " +
45+
" ):eval('%s')}) " +
4646
" ); " +
4747
" os.exit(); " +
4848
"\" | tarantool";
4949
private static final String COMMAND_TEMPLATE = "echo \" " +
5050
" print(require('yaml').encode( " +
51-
" require('net.box').connect( " +
51+
" {require('net.box').connect( " +
5252
" { uri='%s:%d' }, " +
5353
" { user = '%s', password = '%s' } " +
54-
" ):eval('return %s')) " +
54+
" ):eval('%s')}) " +
5555
" ); " +
5656
" os.exit(); " +
5757
"\" | tarantool";
@@ -76,7 +76,7 @@ public <T> T executeScriptDecoded(String scriptResourcePath, SslContext sslConte
7676

7777
if (result.getExitCode() != 0) {
7878

79-
if (result.getExitCode() == 3) {
79+
if (result.getExitCode() == 3 || result.getExitCode() == 1) {
8080
throw new ExecutionException(String.format(EXECUTE_SCRIPT_ERROR_TEMPLATE,
8181
scriptResourcePath, result.getExitCode(),
8282
result.getStderr(), result.getStdout()),

src/test/java/org/testcontainers/containers/Enterprise/TarantoolMTlsContainerTestEnterprise.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import java.io.File;
1313
import java.util.HashMap;
14+
import java.util.List;
1415
import java.util.Map;
1516

1617
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -51,8 +52,9 @@ public static void setUp() throws Exception {
5152

5253
@Test
5354
public void test_clientWithSsl_shouldWork() throws Exception {
54-
HashMap result = containerWithSsl.executeCommandDecoded("box.cfg.listen");
55-
HashMap params = (HashMap) result.get("params");
55+
List<HashMap> resultList = containerWithSsl.executeCommandDecoded("return box.cfg.listen");
56+
HashMap<String, HashMap> result = resultList.get(0);
57+
HashMap<String, String> params = result.get("params");
5658
assertEquals("ssl", params.get("transport"));
5759
assertEquals("server.key", params.get("ssl_key_file"));
5860
assertEquals("server.crt", params.get("ssl_cert_file"));

src/test/java/org/testcontainers/containers/Enterprise/TarantoolSdkContainerTestEnterprise.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import java.io.File;
99
import java.util.HashMap;
10+
import java.util.List;
1011
import java.util.Map;
1112

1213
/**
@@ -31,11 +32,11 @@ void test_should_createTarantoolContainerFromSdk() throws Exception {
3132

3233
tarantoolContainer.start();
3334

34-
final String result = tarantoolContainer.executeCommandDecoded("'test'");
35-
final String versionAnswer = tarantoolContainer.executeCommandDecoded("_TARANTOOL");
35+
List<String> result = tarantoolContainer.executeCommandDecoded("return 'test'");
36+
List<String> versionAnswer = tarantoolContainer.executeCommandDecoded("return _TARANTOOL");
3637

37-
Assertions.assertEquals("test", result);
38-
Assertions.assertEquals("2.10.6-0-g5d09e81a6-r557-nogc64", versionAnswer);
38+
Assertions.assertEquals("test", result.get(0));
39+
Assertions.assertEquals("2.10.6-0-g5d09e81a6-r557-nogc64", versionAnswer.get(0));
3940
}
4041
}
4142
}

src/test/java/org/testcontainers/containers/Enterprise/TarantoolSslContainerTestEnterprise.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import java.io.File;
1313
import java.util.HashMap;
14+
import java.util.List;
1415
import java.util.Map;
1516

1617
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -51,8 +52,9 @@ public static void setUp() throws Exception {
5152

5253
@Test
5354
public void test_clientWithSsl_shouldWork() throws Exception {
54-
HashMap result = containerWithSsl.executeCommandDecoded("box.cfg.listen");
55-
HashMap params = (HashMap) result.get("params");
55+
List<HashMap> resultList = containerWithSsl.executeCommandDecoded("return box.cfg.listen");
56+
HashMap<String, HashMap> result = resultList.get(0);
57+
HashMap<String, String> params = result.get("params");
5658
assertEquals("ssl", params.get("transport"));
5759
assertEquals("key.pem", params.get("ssl_key_file"));
5860
assertEquals("certificate.crt", params.get("ssl_cert_file"));

src/test/java/org/testcontainers/containers/TarantoolCartridgeBootstrapFromYamlTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void test_StaticClusterContainer_StartsSuccessfully_ifFilesAreCopied() th
4040
public void test_migrator_executesOk() throws Exception {
4141
ExecResult result = container.executeCommand("return require('migrator').up()");
4242
assertEquals("---\n" +
43-
"- - 001_ddl.lua\n" +
43+
"- ['001_ddl.lua']\n" +
4444
"...\n" +
4545
"\n", result.getStdout());
4646
}

0 commit comments

Comments
 (0)