Skip to content

Commit ecbd7ec

Browse files
authored
test: remove testcontainers-java-tarantool-lib (#52)
* test: remove testcontainers-java-tarantool-lib * test: fix imports
1 parent 16a1b23 commit ecbd7ec

File tree

63 files changed

+2586
-636
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

+2586
-636
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: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
import io.micrometer.core.instrument.MeterRegistry;
1919
import io.netty.util.HashedWheelTimer;
2020
import io.netty.util.Timer;
21+
import org.junit.jupiter.api.AfterEach;
2122
import org.junit.jupiter.api.BeforeEach;
2223
import org.junit.jupiter.api.Test;
2324
import org.junit.jupiter.api.Timeout;
2425
import org.slf4j.Logger;
2526
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;
27+
import org.testcontainers.containers.tarantool.TarantoolContainer;
28+
import org.testcontainers.containers.utils.TarantoolContainerClientHelper;
3029

3130
import static io.tarantool.core.protocol.requests.IProtoConstant.IPROTO_DATA;
3231
import io.tarantool.balancer.TarantoolBalancer;
@@ -40,35 +39,43 @@
4039
import io.tarantool.pool.IProtoClientPoolImpl;
4140
import io.tarantool.pool.InstanceConnectionGroup;
4241

43-
@Timeout(value = 15)
44-
@Testcontainers
42+
@Timeout(value = 25)
4543
public class DistributingRoundRobinBalancerTest extends BaseTest {
4644

4745
private static final Logger log =
4846
LoggerFactory.getLogger(DistributingRoundRobinBalancerTest.class);
4947

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));
48+
private static TarantoolContainer<?> tt1;
49+
private static TarantoolContainer<?> tt2;
6350

6451
@BeforeEach
6552
public void setUp() {
53+
tt1 =
54+
TarantoolContainerClientHelper.createTarantoolContainer()
55+
.withEnv(ENV_MAP)
56+
.withExposedPorts(3305);
57+
tt2 =
58+
TarantoolContainerClientHelper.createTarantoolContainer()
59+
.withEnv(ENV_MAP)
60+
.withExposedPorts(3305);
61+
62+
tt1.start();
63+
tt2.start();
64+
65+
TarantoolContainerClientHelper.execInitScript(tt1);
66+
TarantoolContainerClientHelper.execInitScript(tt2);
6667
do {
6768
count1 = ThreadLocalRandom.current().nextInt(MIN_CONNECTION_COUNT, MAX_CONNECTION_COUNT + 1);
6869
count2 = ThreadLocalRandom.current().nextInt(MIN_CONNECTION_COUNT, MAX_CONNECTION_COUNT + 1);
6970
} while (count1 == count2);
7071
}
7172

73+
@AfterEach
74+
void tearDown() {
75+
tt1.stop();
76+
tt2.stop();
77+
}
78+
7279
private static IProtoClientPool createClientPool(
7380
boolean gracefulShutdown, HeartbeatOpts heartbeatOpts, MeterRegistry metricsRegistry) {
7481
ManagedResource<Timer> timerResource =
@@ -78,25 +85,30 @@ private static IProtoClientPool createClientPool(
7885
factory, timerResource, gracefulShutdown, heartbeatOpts, null, metricsRegistry);
7986
}
8087

81-
private int getSessionCounter(TarantoolContainer tt) throws Exception {
82-
List<?> result = tt.executeCommandDecoded("return get_session_counter()");
88+
private int getSessionCounter(TarantoolContainer<?> tt) throws Exception {
89+
List<?> result =
90+
TarantoolContainerClientHelper.executeCommandDecoded(tt, "return get_session_counter()");
8391
return (Integer) result.get(0);
8492
}
8593

86-
private int getCallCounter(TarantoolContainer tt) throws Exception {
87-
List<?> result = tt.executeCommandDecoded("return get_call_counter()");
94+
private int getCallCounter(TarantoolContainer<?> tt) throws Exception {
95+
List<?> result =
96+
TarantoolContainerClientHelper.executeCommandDecoded(tt, "return get_call_counter()");
8897
return (Integer) result.get(0);
8998
}
9099

91-
private void execLua(TarantoolContainer container, String command) {
100+
private void execLua(TarantoolContainer<?> container, String command) {
92101
try {
93-
container.executeCommandDecoded(command);
94-
} catch (Exception e) {
102+
TarantoolContainerClientHelper.executeCommandDecoded(container, command);
103+
} catch (Exception ignored) {
95104
}
96105
}
97106

98107
private void wakeUpAllConnects(
99-
TarantoolBalancer rrBalancer, int nodeVisits, TarantoolContainer tt1, TarantoolContainer tt2)
108+
TarantoolBalancer rrBalancer,
109+
int nodeVisits,
110+
TarantoolContainer<?> tt1,
111+
TarantoolContainer<?> tt2)
100112
throws Exception {
101113
walkAndJoin(rrBalancer, nodeVisits * 2);
102114
assertEquals(count1, getSessionCounter(tt1));
@@ -130,13 +142,13 @@ public void testDistributingRoundRobin() throws Exception {
130142
Arrays.asList(
131143
InstanceConnectionGroup.builder()
132144
.withHost(tt1.getHost())
133-
.withPort(tt1.getPort())
145+
.withPort(tt1.getFirstMappedPort())
134146
.withSize(count1)
135147
.withTag("node-a-00")
136148
.build(),
137149
InstanceConnectionGroup.builder()
138150
.withHost(tt2.getHost())
139-
.withPort(tt2.getPort())
151+
.withPort(tt2.getFirstMappedPort())
140152
.withSize(count2)
141153
.withTag("node-b-00")
142154
.build()));
@@ -160,7 +172,7 @@ public void testDistributingRoundRobinWithUnavailableNodeA() throws Exception {
160172
.build(),
161173
InstanceConnectionGroup.builder()
162174
.withHost(tt2.getHost())
163-
.withPort(tt2.getPort())
175+
.withPort(tt2.getFirstMappedPort())
164176
.withSize(count2)
165177
.withTag("node-b-01")
166178
.build()));
@@ -176,8 +188,10 @@ public void testDistributingRoundRobinWithUnavailableNodeA() throws Exception {
176188
execLua(tt2, "reset_call_counter()");
177189

178190
log.info("waiting for invalidation");
179-
Thread.sleep(INVALIDATION_TIMEOUT);
191+
Thread.sleep(EXTENDED_INVALIDATION_TIMEOUT);
180192

193+
execLua(tt1, "reset_call_counter()");
194+
execLua(tt2, "reset_call_counter()");
181195
log.info("walk on node B only");
182196
walkAndJoin(rrBalancer, nodeVisits * 2);
183197
assertEquals(0, getCallCounter(tt1));
@@ -217,7 +231,7 @@ public void testDistributingRoundRobinWithUnavailableNodeANoUnlock() throws Exce
217231
.build(),
218232
InstanceConnectionGroup.builder()
219233
.withHost(tt2.getHost())
220-
.withPort(tt2.getPort())
234+
.withPort(tt2.getFirstMappedPort())
221235
.withSize(count2)
222236
.withTag("node-b-02")
223237
.build()));
@@ -233,8 +247,10 @@ public void testDistributingRoundRobinWithUnavailableNodeANoUnlock() throws Exce
233247
execLua(tt2, "reset_call_counter()");
234248

235249
log.info("waiting for invalidation");
236-
Thread.sleep(INVALIDATION_TIMEOUT);
250+
Thread.sleep(EXTENDED_INVALIDATION_TIMEOUT);
237251

252+
execLua(tt1, "reset_call_counter()");
253+
execLua(tt2, "reset_call_counter()");
238254
log.info("walk on node B only");
239255
walkAndJoin(rrBalancer, nodeVisits * 2);
240256
assertEquals(0, getCallCounter(tt1));
@@ -288,7 +304,7 @@ public void testDistributingRoundRobinNoAvailableClients() throws Exception {
288304
execLua(tt2, "lock_pipe(true); reset_call_counter()");
289305

290306
log.info("waiting for invalidation");
291-
Thread.sleep(INVALIDATION_TIMEOUT);
307+
Thread.sleep(EXTENDED_INVALIDATION_TIMEOUT);
292308

293309
Throwable exc = assertThrows(ExecutionException.class, () -> rrBalancer.getNext().get());
294310
assertEquals(NoAvailableClientsException.class, exc.getCause().getClass());
@@ -323,12 +339,12 @@ public void testDistributingRoundRobinStartWithStuckNodeA() throws Exception {
323339
Arrays.asList(
324340
InstanceConnectionGroup.builder()
325341
.withHost(tt1.getHost())
326-
.withPort(tt1.getPort())
342+
.withPort(tt1.getFirstMappedPort())
327343
.withTag("node-a-01")
328344
.build(),
329345
InstanceConnectionGroup.builder()
330346
.withHost(tt2.getHost())
331-
.withPort(tt2.getPort())
347+
.withPort(tt2.getFirstMappedPort())
332348
.withTag("node-b-01")
333349
.build()));
334350
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,13 @@
1010
import java.util.concurrent.ThreadLocalRandom;
1111

1212
import static org.junit.jupiter.api.Assertions.assertEquals;
13+
import org.junit.jupiter.api.AfterAll;
1314
import org.junit.jupiter.api.BeforeAll;
1415
import org.junit.jupiter.api.Test;
1516
import org.junit.jupiter.api.Timeout;
1617
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;
18+
import org.testcontainers.containers.tarantool.TarantoolContainer;
19+
import org.testcontainers.containers.utils.TarantoolContainerClientHelper;
2020

2121
import io.tarantool.balancer.TarantoolBalancer;
2222
import io.tarantool.balancer.TarantoolRoundRobinBalancer;
@@ -26,28 +26,41 @@
2626
import io.tarantool.pool.InstanceConnectionGroup;
2727

2828
@Timeout(value = 5)
29-
@Testcontainers
3029
public class RoundRobinBalancerTest extends BaseTest {
3130

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);
31+
private static TarantoolContainer<?> tt1;
32+
private static TarantoolContainer<?> tt2;
3733

3834
@BeforeAll
3935
public static void setUp() {
36+
tt1 = TarantoolContainerClientHelper.createTarantoolContainer();
37+
tt2 = TarantoolContainerClientHelper.createTarantoolContainer();
38+
39+
tt1.start();
40+
tt2.start();
41+
42+
TarantoolContainerClientHelper.execInitScript(tt1);
43+
TarantoolContainerClientHelper.execInitScript(tt2);
44+
4045
count1 = ThreadLocalRandom.current().nextInt(MIN_CONNECTION_COUNT, MAX_CONNECTION_COUNT + 1);
4146
count2 = ThreadLocalRandom.current().nextInt(MIN_CONNECTION_COUNT, MAX_CONNECTION_COUNT + 1);
4247
}
4348

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

49-
private int getCallCounter(TarantoolContainer tt) throws Exception {
50-
List<?> result = tt.executeCommandDecoded("return get_call_counter()");
61+
private int getCallCounter(TarantoolContainer<?> tt) throws Exception {
62+
List<?> result =
63+
TarantoolContainerClientHelper.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)