Skip to content

Commit 8923143

Browse files
committed
test: remove testcontainers-java-tarantool-lib
1 parent 16a1b23 commit 8923143

File tree

63 files changed

+2528
-635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2528
-635
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
strategy:
6969
fail-fast: false
7070
matrix:
71-
tarantool-version: [ "2.11.8-ubuntu20.04", "3.0.1-old" ]
71+
tarantool-version: [ "2.11.8-ubuntu20.04", "3.5.0" ]
7272
timeout-minutes: 40
7373
steps:
7474
- uses: actions/checkout@v6
@@ -127,7 +127,7 @@ jobs:
127127
strategy:
128128
fail-fast: false
129129
matrix:
130-
tarantool-version: [ "2.11.8-ubuntu20.04", "3.0.1-old" ]
130+
tarantool-version: [ "2.11.8-ubuntu20.04", "3.5.0" ]
131131
timeout-minutes: 40
132132
steps:
133133
- uses: actions/checkout@v6

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## [Unreleased]
44

5+
### Testcontainers
6+
7+
- Remove dependency on `testcontainers-java-tarantool` library
8+
- Update all integration tests to use new container implementation
9+
510
### Bug fixes
611

712
- Fix a memory leak due to the use of a local thread pool

pom.xml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -377,18 +377,6 @@
377377
<version>${testcontainers.version}</version>
378378
<scope>test</scope>
379379
</dependency>
380-
<dependency>
381-
<groupId>io.tarantool</groupId>
382-
<artifactId>testcontainers-java-tarantool</artifactId>
383-
<version>v1.5.0</version>
384-
<scope>test</scope>
385-
<exclusions>
386-
<exclusion>
387-
<groupId>io.netty</groupId>
388-
<artifactId>netty-all</artifactId>
389-
</exclusion>
390-
</exclusions>
391-
</dependency>
392380
<dependency>
393381
<groupId>org.apache.commons</groupId>
394382
<artifactId>commons-lang3</artifactId>
@@ -509,6 +497,9 @@
509497
<include>**/integration/**/*Crud*Test.java</include>
510498
<include>**/crud/**/*Test.java</include>
511499
</includes>
500+
<excludes>
501+
<exclude>**/io/tarantool/spring/data*/integration/**/*Test.java</exclude>
502+
</excludes>
512503
<argLine>@{argLine} -Xmx1024m</argLine>
513504
</configuration>
514505
</plugin>

tarantool-balancer/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
<artifactId>tarantool-pooling</artifactId>
3131
</dependency>
3232
<!-- Test -->
33-
<dependency>
34-
<groupId>io.tarantool</groupId>
35-
<artifactId>testcontainers-java-tarantool</artifactId>
36-
</dependency>
3733
<dependency>
3834
<groupId>ch.qos.logback</groupId>
3935
<artifactId>logback-classic</artifactId>
@@ -46,6 +42,10 @@
4642
<groupId>org.junit.jupiter</groupId>
4743
<artifactId>junit-jupiter</artifactId>
4844
</dependency>
45+
<dependency>
46+
<groupId>io.tarantool</groupId>
47+
<artifactId>testcontainers</artifactId>
48+
</dependency>
4949
<!-- End test -->
5050
</dependencies>
5151
</project>

tarantool-balancer/src/test/java/io/tarantool/balancer/integration/BaseTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public abstract class BaseTest {
6666
protected static final int INVALID_PINGS = 2;
6767
protected static final long INVALIDATION_TIMEOUT =
6868
((long) (INVALID_PINGS + 1) * (PING_INTERVAL + TIMER_ERROR_MS));
69+
70+
/** Longer wait for invalidation (e.g. Tarantool 3 with more connections). */
71+
protected static final long EXTENDED_INVALIDATION_TIMEOUT = INVALIDATION_TIMEOUT * 3;
72+
6973
protected static final long RESTORE_TIMEOUT =
7074
(WINDOW_SIZE + 1) * (PING_INTERVAL + TIMER_ERROR_MS);
7175
protected static final ArrayValue emptyArgs = ValueFactory.emptyArray();

tarantool-balancer/src/test/java/io/tarantool/balancer/integration/DistributingRoundRobinBalancerTest.java

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@
1515
import static org.junit.jupiter.api.Assertions.assertEquals;
1616
import static org.junit.jupiter.api.Assertions.assertThrows;
1717
import static org.junit.jupiter.api.Assertions.assertTrue;
18+
import static org.testcontainers.containers.utils.TarantoolContainerClientHelper.createTarantoolContainer;
19+
import static org.testcontainers.containers.utils.TarantoolContainerClientHelper.execInitScript;
20+
import static org.testcontainers.containers.utils.TarantoolContainerClientHelper.executeCommandDecoded;
1821
import io.micrometer.core.instrument.MeterRegistry;
1922
import io.netty.util.HashedWheelTimer;
2023
import io.netty.util.Timer;
24+
import org.junit.jupiter.api.AfterEach;
2125
import org.junit.jupiter.api.BeforeEach;
2226
import org.junit.jupiter.api.Test;
2327
import org.junit.jupiter.api.Timeout;
2428
import org.slf4j.Logger;
2529
import org.slf4j.LoggerFactory;
26-
import org.testcontainers.containers.TarantoolContainer;
27-
import org.testcontainers.containers.output.Slf4jLogConsumer;
28-
import org.testcontainers.junit.jupiter.Container;
29-
import org.testcontainers.junit.jupiter.Testcontainers;
30+
import org.testcontainers.containers.tarantool.TarantoolContainer;
3031

3132
import static io.tarantool.core.protocol.requests.IProtoConstant.IPROTO_DATA;
3233
import io.tarantool.balancer.TarantoolBalancer;
@@ -40,35 +41,37 @@
4041
import io.tarantool.pool.IProtoClientPoolImpl;
4142
import io.tarantool.pool.InstanceConnectionGroup;
4243

43-
@Timeout(value = 15)
44-
@Testcontainers
44+
@Timeout(value = 25)
4545
public class DistributingRoundRobinBalancerTest extends BaseTest {
4646

4747
private static final Logger log =
4848
LoggerFactory.getLogger(DistributingRoundRobinBalancerTest.class);
4949

50-
@Container
51-
private final TarantoolContainer tt1 =
52-
new TarantoolContainer()
53-
.withEnv(ENV_MAP)
54-
.withExposedPort(3305)
55-
.withLogConsumer(new Slf4jLogConsumer(log));
56-
57-
@Container
58-
private final TarantoolContainer tt2 =
59-
new TarantoolContainer()
60-
.withEnv(ENV_MAP)
61-
.withExposedPort(3305)
62-
.withLogConsumer(new Slf4jLogConsumer(log));
50+
private static TarantoolContainer<?> tt1;
51+
private static TarantoolContainer<?> tt2;
6352

6453
@BeforeEach
6554
public void setUp() {
55+
tt1 = createTarantoolContainer().withEnv(ENV_MAP).withExposedPorts(3305);
56+
tt2 = createTarantoolContainer().withEnv(ENV_MAP).withExposedPorts(3305);
57+
58+
tt1.start();
59+
tt2.start();
60+
61+
execInitScript(tt1);
62+
execInitScript(tt2);
6663
do {
6764
count1 = ThreadLocalRandom.current().nextInt(MIN_CONNECTION_COUNT, MAX_CONNECTION_COUNT + 1);
6865
count2 = ThreadLocalRandom.current().nextInt(MIN_CONNECTION_COUNT, MAX_CONNECTION_COUNT + 1);
6966
} while (count1 == count2);
7067
}
7168

69+
@AfterEach
70+
void tearDown() {
71+
tt1.stop();
72+
tt2.stop();
73+
}
74+
7275
private static IProtoClientPool createClientPool(
7376
boolean gracefulShutdown, HeartbeatOpts heartbeatOpts, MeterRegistry metricsRegistry) {
7477
ManagedResource<Timer> timerResource =
@@ -78,25 +81,28 @@ private static IProtoClientPool createClientPool(
7881
factory, timerResource, gracefulShutdown, heartbeatOpts, null, metricsRegistry);
7982
}
8083

81-
private int getSessionCounter(TarantoolContainer tt) throws Exception {
82-
List<?> result = tt.executeCommandDecoded("return get_session_counter()");
84+
private int getSessionCounter(TarantoolContainer<?> tt) throws Exception {
85+
List<?> result = executeCommandDecoded(tt, "return get_session_counter()");
8386
return (Integer) result.get(0);
8487
}
8588

86-
private int getCallCounter(TarantoolContainer tt) throws Exception {
87-
List<?> result = tt.executeCommandDecoded("return get_call_counter()");
89+
private int getCallCounter(TarantoolContainer<?> tt) throws Exception {
90+
List<?> result = executeCommandDecoded(tt, "return get_call_counter()");
8891
return (Integer) result.get(0);
8992
}
9093

91-
private void execLua(TarantoolContainer container, String command) {
94+
private void execLua(TarantoolContainer<?> container, String command) {
9295
try {
93-
container.executeCommandDecoded(command);
96+
executeCommandDecoded(container, command);
9497
} catch (Exception e) {
9598
}
9699
}
97100

98101
private void wakeUpAllConnects(
99-
TarantoolBalancer rrBalancer, int nodeVisits, TarantoolContainer tt1, TarantoolContainer tt2)
102+
TarantoolBalancer rrBalancer,
103+
int nodeVisits,
104+
TarantoolContainer<?> tt1,
105+
TarantoolContainer<?> tt2)
100106
throws Exception {
101107
walkAndJoin(rrBalancer, nodeVisits * 2);
102108
assertEquals(count1, getSessionCounter(tt1));
@@ -130,13 +136,13 @@ public void testDistributingRoundRobin() throws Exception {
130136
Arrays.asList(
131137
InstanceConnectionGroup.builder()
132138
.withHost(tt1.getHost())
133-
.withPort(tt1.getPort())
139+
.withPort(tt1.getFirstMappedPort())
134140
.withSize(count1)
135141
.withTag("node-a-00")
136142
.build(),
137143
InstanceConnectionGroup.builder()
138144
.withHost(tt2.getHost())
139-
.withPort(tt2.getPort())
145+
.withPort(tt2.getFirstMappedPort())
140146
.withSize(count2)
141147
.withTag("node-b-00")
142148
.build()));
@@ -160,7 +166,7 @@ public void testDistributingRoundRobinWithUnavailableNodeA() throws Exception {
160166
.build(),
161167
InstanceConnectionGroup.builder()
162168
.withHost(tt2.getHost())
163-
.withPort(tt2.getPort())
169+
.withPort(tt2.getFirstMappedPort())
164170
.withSize(count2)
165171
.withTag("node-b-01")
166172
.build()));
@@ -176,8 +182,10 @@ public void testDistributingRoundRobinWithUnavailableNodeA() throws Exception {
176182
execLua(tt2, "reset_call_counter()");
177183

178184
log.info("waiting for invalidation");
179-
Thread.sleep(INVALIDATION_TIMEOUT);
185+
Thread.sleep(EXTENDED_INVALIDATION_TIMEOUT);
180186

187+
execLua(tt1, "reset_call_counter()");
188+
execLua(tt2, "reset_call_counter()");
181189
log.info("walk on node B only");
182190
walkAndJoin(rrBalancer, nodeVisits * 2);
183191
assertEquals(0, getCallCounter(tt1));
@@ -217,7 +225,7 @@ public void testDistributingRoundRobinWithUnavailableNodeANoUnlock() throws Exce
217225
.build(),
218226
InstanceConnectionGroup.builder()
219227
.withHost(tt2.getHost())
220-
.withPort(tt2.getPort())
228+
.withPort(tt2.getFirstMappedPort())
221229
.withSize(count2)
222230
.withTag("node-b-02")
223231
.build()));
@@ -233,8 +241,10 @@ public void testDistributingRoundRobinWithUnavailableNodeANoUnlock() throws Exce
233241
execLua(tt2, "reset_call_counter()");
234242

235243
log.info("waiting for invalidation");
236-
Thread.sleep(INVALIDATION_TIMEOUT);
244+
Thread.sleep(EXTENDED_INVALIDATION_TIMEOUT);
237245

246+
execLua(tt1, "reset_call_counter()");
247+
execLua(tt2, "reset_call_counter()");
238248
log.info("walk on node B only");
239249
walkAndJoin(rrBalancer, nodeVisits * 2);
240250
assertEquals(0, getCallCounter(tt1));
@@ -288,7 +298,7 @@ public void testDistributingRoundRobinNoAvailableClients() throws Exception {
288298
execLua(tt2, "lock_pipe(true); reset_call_counter()");
289299

290300
log.info("waiting for invalidation");
291-
Thread.sleep(INVALIDATION_TIMEOUT);
301+
Thread.sleep(EXTENDED_INVALIDATION_TIMEOUT);
292302

293303
Throwable exc = assertThrows(ExecutionException.class, () -> rrBalancer.getNext().get());
294304
assertEquals(NoAvailableClientsException.class, exc.getCause().getClass());
@@ -323,12 +333,12 @@ public void testDistributingRoundRobinStartWithStuckNodeA() throws Exception {
323333
Arrays.asList(
324334
InstanceConnectionGroup.builder()
325335
.withHost(tt1.getHost())
326-
.withPort(tt1.getPort())
336+
.withPort(tt1.getFirstMappedPort())
327337
.withTag("node-a-01")
328338
.build(),
329339
InstanceConnectionGroup.builder()
330340
.withHost(tt2.getHost())
331-
.withPort(tt2.getPort())
341+
.withPort(tt2.getFirstMappedPort())
332342
.withTag("node-b-01")
333343
.build()));
334344
pool.setConnectTimeout(3_000);

tarantool-balancer/src/test/java/io/tarantool/balancer/integration/RoundRobinBalancerTest.java

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
import java.util.concurrent.ThreadLocalRandom;
1111

1212
import static org.junit.jupiter.api.Assertions.assertEquals;
13+
import static org.testcontainers.containers.utils.TarantoolContainerClientHelper.createTarantoolContainer;
14+
import static org.testcontainers.containers.utils.TarantoolContainerClientHelper.execInitScript;
15+
import static org.testcontainers.containers.utils.TarantoolContainerClientHelper.executeCommandDecoded;
16+
import org.junit.jupiter.api.AfterAll;
1317
import org.junit.jupiter.api.BeforeAll;
1418
import org.junit.jupiter.api.Test;
1519
import org.junit.jupiter.api.Timeout;
1620
import org.msgpack.value.ValueFactory;
17-
import org.testcontainers.containers.TarantoolContainer;
18-
import org.testcontainers.junit.jupiter.Container;
19-
import org.testcontainers.junit.jupiter.Testcontainers;
21+
import org.testcontainers.containers.tarantool.TarantoolContainer;
2022

2123
import io.tarantool.balancer.TarantoolBalancer;
2224
import io.tarantool.balancer.TarantoolRoundRobinBalancer;
@@ -26,28 +28,39 @@
2628
import io.tarantool.pool.InstanceConnectionGroup;
2729

2830
@Timeout(value = 5)
29-
@Testcontainers
3031
public class RoundRobinBalancerTest extends BaseTest {
3132

32-
@Container
33-
private static final TarantoolContainer tt1 = new TarantoolContainer().withEnv(ENV_MAP);
34-
35-
@Container
36-
private static final TarantoolContainer tt2 = new TarantoolContainer().withEnv(ENV_MAP);
33+
private static TarantoolContainer<?> tt1;
34+
private static TarantoolContainer<?> tt2;
3735

3836
@BeforeAll
3937
public static void setUp() {
38+
tt1 = createTarantoolContainer();
39+
tt2 = createTarantoolContainer();
40+
41+
tt1.start();
42+
tt2.start();
43+
44+
execInitScript(tt1);
45+
execInitScript(tt2);
46+
4047
count1 = ThreadLocalRandom.current().nextInt(MIN_CONNECTION_COUNT, MAX_CONNECTION_COUNT + 1);
4148
count2 = ThreadLocalRandom.current().nextInt(MIN_CONNECTION_COUNT, MAX_CONNECTION_COUNT + 1);
4249
}
4350

44-
private int getSessionCounter(TarantoolContainer tt) throws Exception {
45-
List<?> result = tt.executeCommandDecoded("return get_session_counter()");
51+
@AfterAll
52+
static void tearDown() {
53+
tt1.stop();
54+
tt2.stop();
55+
}
56+
57+
private int getSessionCounter(TarantoolContainer<?> tt) throws Exception {
58+
List<?> result = executeCommandDecoded(tt, "return get_session_counter()");
4659
return (Integer) result.get(0);
4760
}
4861

49-
private int getCallCounter(TarantoolContainer tt) throws Exception {
50-
List<?> result = tt.executeCommandDecoded("return get_call_counter()");
62+
private int getCallCounter(TarantoolContainer<?> tt) throws Exception {
63+
List<?> result = executeCommandDecoded(tt, "return get_call_counter()");
5164
return (Integer) result.get(0);
5265
}
5366

@@ -58,13 +71,13 @@ public void testRoundRobin() throws Exception {
5871
Arrays.asList(
5972
InstanceConnectionGroup.builder()
6073
.withHost(tt1.getHost())
61-
.withPort(tt1.getPort())
74+
.withPort(tt1.getFirstMappedPort())
6275
.withSize(count1)
6376
.withTag("node-a")
6477
.build(),
6578
InstanceConnectionGroup.builder()
6679
.withHost(tt2.getHost())
67-
.withPort(tt2.getPort())
80+
.withPort(tt2.getFirstMappedPort())
6881
.withSize(count2)
6982
.withTag("node-b")
7083
.build()));

tarantool-client/src/main/java/io/tarantool/client/crud/TarantoolCrudClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
public interface TarantoolCrudClient extends TarantoolClient {
1919

2020
/** Default username for CRUD clients. */
21-
String DEFAULT_CRUD_USERNAME = "admin";
21+
String DEFAULT_CRUD_USERNAME = "api_user";
2222

2323
/** Default password for CRUD admin username. */
24-
String DEFAULT_CRUD_PASSWORD = "secret-cluster-cookie";
24+
String DEFAULT_CRUD_PASSWORD = "secret";
2525

2626
/**
2727
* Function returns {@link TarantoolCrudSpace space} with the name specified as the input

0 commit comments

Comments
 (0)