Skip to content

Commit

Permalink
Update testcontainers-java-tarantool dependency
Browse files Browse the repository at this point in the history
- Update `testcontainers-java-tarantool` dependency from 0.5.4 to 1.0.1 version.
- Fix tests for using with testcontainers-java-tarantool 1.0.1.

Closes #400.
  • Loading branch information
nickkkccc authored and akudiyar committed Oct 3, 2023
1 parent a393cd3 commit c425687
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 34 deletions.
10 changes: 4 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

## [Unreleased]

### API changes

- Add `"mode"` option for select operation ([#107](https://github.com/tarantool/cartridge-java/issues/107))
- Change using of proxy client parameters (`mode`, `rollback_on_error`, `stop_on_error`) with enum classes ([#419](https://github.com/tarantool/cartridge-java/issues/419))

### Bugfixes

- Fix Instant converter to parse 8 bytes datetime ([#408](https://github.com/tarantool/cartridge-java/issues/408))

### Internal changes
### Internal and API changes

- Bump testcontainers-java-tarantool to 1.0.1 ([#400](https://github.com/tarantool/cartridge-java/issues/400))
- Add `"mode"` option for select operation ([#107](https://github.com/tarantool/cartridge-java/issues/107))
- Change using of proxy client parameters (`mode`, `rollback_on_error`, `stop_on_error`) with enum classes ([#419](https://github.com/tarantool/cartridge-java/issues/419))
- Change using of option names with the String type in the internal API to using with the ProxyOption enum class ([#420](https://github.com/tarantool/cartridge-java/issues/420))

## [0.12.1] - 2023-08-04
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
<dependency>
<groupId>io.tarantool</groupId>
<artifactId>testcontainers-java-tarantool</artifactId>
<version>0.5.4</version>
<version>1.0.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/io/tarantool/driver/integration/ConnectionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.tarantool.driver.exceptions.TarantoolClientException;
import io.tarantool.driver.exceptions.TarantoolConnectionException;
import io.tarantool.driver.exceptions.TarantoolInternalException;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
Expand Down Expand Up @@ -324,14 +323,15 @@ public void testIncorrectPassword_shouldCloseConnection() throws Exception {
container.getUsername(), "incorrect");
TarantoolServerAddress serverAddress = new TarantoolServerAddress(
container.getHost(), container.getPort());
ClusterTarantoolTupleClient client = new ClusterTarantoolTupleClient(credentials, serverAddress);
for (int i = 0; i < 100; i++) {
assertThrows(TarantoolClientException.class, () -> {
client.getVersion();
});
try (ClusterTarantoolTupleClient client = new ClusterTarantoolTupleClient(credentials, serverAddress)) {
for (int i = 0; i < 100; i++) {
assertThrows(TarantoolClientException.class, client::getVersion);
}
}
Map netStat = (Map) container.executeCommand("return box.stat.net()").join().get(0);
Map connections = (Map) netStat.get("CONNECTIONS");

List<?> result = container.executeCommandDecoded("return box.stat.net()");
Map<?, ?> netStat = (Map<?, ?>) result.get(0);
Map<?, ?> connections = (Map<?, ?>) netStat.get("CONNECTIONS");
assertTrue((Integer) connections.get("current") <= 2); // one for container one for static test client
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.tarantool.driver.api.tuple.DefaultTarantoolTupleFactory;
import io.tarantool.driver.api.tuple.TarantoolTuple;
import io.tarantool.driver.api.tuple.TarantoolTupleFactory;
import io.tarantool.driver.mappers.DefaultMessagePackMapperFactory;
import io.tarantool.driver.mappers.factories.DefaultMessagePackMapperFactory;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,35 @@ public class SslClientITEnterprise {

private static TarantoolContainer containerWithSsl;
private static TarantoolContainer containerWithoutSsl;
private static final String RESOURCE_PATH = "org/testcontainers/containers/enterprise/";

@BeforeAll
public static void setUp() throws URISyntaxException, SSLException {
final File dockerfile = new File(
SslClientITEnterprise.class.getClassLoader()
.getResource("org/testcontainers/containers/enterprise/Dockerfile").toURI()
.getResource(RESOURCE_PATH + "Dockerfile").toURI()
);
final Map<String, String> buildArgs = new HashMap<>();
buildArgs.put("DOWNLOAD_SDK_URI", System.getenv("DOWNLOAD_SDK_URI"));
buildArgs.put("SDK_VERSION", System.getenv("SDK_VERSION"));

final TarantoolClientBuilder tarantoolClientBuilder = TarantoolClientFactory.createClient()
.withSslContext(getSslContext());

containerWithSsl = new TarantoolContainer(
new TarantoolImageParams("tarantool-enterprise", dockerfile, buildArgs), tarantoolClientBuilder)
new TarantoolImageParams("tarantool-enterprise", dockerfile, buildArgs))
.withScriptFileName("ssl_server.lua")
.withUsername("test_user")
.withPassword("test_password")
.withMemtxMemory(256 * 1024 * 1024)
.withDirectoryBinding("org/testcontainers/containers/enterprise/ssl")
.withLogConsumer(new Slf4jLogConsumer(log));
.withDirectoryBinding(RESOURCE_PATH + "ssl")
.withLogConsumer(new Slf4jLogConsumer(log))
.withSslContext(org.testcontainers.containers.SslContext.getSslContext());

containerWithoutSsl = new TarantoolContainer(
new TarantoolImageParams("tarantool-enterprise", dockerfile, buildArgs))
.withScriptFileName("server.lua")
.withUsername("test_user")
.withPassword("test_password")
.withMemtxMemory(256 * 1024 * 1024)
.withDirectoryBinding("org/testcontainers/containers/enterprise")
.withDirectoryBinding(RESOURCE_PATH)
.withLogConsumer(new Slf4jLogConsumer(log));

if (!containerWithSsl.isRunning()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class SslClientMTlsITEnterprise {
private static final Logger log = LoggerFactory.getLogger(SslClientMTlsITEnterprise.class);

private static TarantoolContainer containerWithSsl;
private static final String RESOURCE_PATH = "org/testcontainers/containers/enterprise/ssl/mtls/";

@BeforeAll
public static void setUp() throws Exception {
Expand All @@ -50,18 +51,17 @@ public static void setUp() throws Exception {
buildArgs.put("DOWNLOAD_SDK_URI", System.getenv("DOWNLOAD_SDK_URI"));
buildArgs.put("SDK_VERSION", System.getenv("SDK_VERSION"));

final TarantoolClientBuilder tarantoolClientBuilder = TarantoolClientFactory.createClient()
.withSslContext(getSslContextWithCA())
.withConnectTimeout(5000);

containerWithSsl = new TarantoolContainer(
new TarantoolImageParams("tarantool-enterprise", dockerfile, buildArgs), tarantoolClientBuilder)
new TarantoolImageParams("tarantool-enterprise", dockerfile, buildArgs))
.withScriptFileName("mtls_server.lua")
.withUsername("test_user")
.withPassword("test_password")
.withMemtxMemory(256 * 1024 * 1024)
.withDirectoryBinding("org/testcontainers/containers/enterprise/ssl/mtls")
.withLogConsumer(new Slf4jLogConsumer(log));
.withDirectoryBinding(RESOURCE_PATH)
.withLogConsumer(new Slf4jLogConsumer(log))
.withSslContext(org.testcontainers.containers.SslContext.getSslContext(
RESOURCE_PATH + "ca.key",
RESOURCE_PATH + "ca.crt"));

if (!containerWithSsl.isRunning()) {
containerWithSsl.start();
Expand Down Expand Up @@ -106,15 +106,15 @@ public void test_clientWithoutCA_shouldThrowException_ifServerWithMTLS() throws
private static SslContext getSslContextWithCA() throws Exception {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
final File keyCertChainFile = new File(classloader
.getResource("org/testcontainers/containers/enterprise/ssl/mtls/ca.crt").toURI());
.getResource(RESOURCE_PATH + "ca.crt").toURI());
final File keyFile = new File(classloader
.getResource("org/testcontainers/containers/enterprise/ssl/mtls/ca.key").toURI());
.getResource(RESOURCE_PATH + "ca.key").toURI());

String keyStoreFilePassword = "12345678";
KeyStore keyStore = KeyStore.getInstance("PKCS12");

InputStream trustStore = classloader
.getResourceAsStream("org/testcontainers/containers/enterprise/ssl/mtls/trustStoreFile");
.getResourceAsStream(RESOURCE_PATH + "trustStoreFile");
keyStore.load(trustStore, keyStoreFilePassword.toCharArray());

TrustManagerFactory trustManagerFactory = TrustManagerFactory
Expand Down

0 comments on commit c425687

Please sign in to comment.