Skip to content

Commit 3c1cc7b

Browse files
committed
Improve awaiting Tarantool start/stop processes
Add await-versions of start/stop commands for TarantoolControl class. Improve the waiting process with an extra monitoring PID of a running Tarantool-instance using terminal ps-command. Fixes: tarantool#164
1 parent 7cdb58c commit 3c1cc7b

6 files changed

+174
-91
lines changed

src/test/java/org/tarantool/AbstractTarantoolConnectorIT.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,11 @@ protected List<?> consoleDelete(String spaceName, Object key) {
234234
}
235235

236236
protected static void stopTarantool(String instance) {
237-
control.stop(instance);
238-
control.waitStopped("jdk-testing");
237+
control.stopAndAwait(instance);
239238
}
240239

241240
protected static void startTarantool(String instance) {
242-
control.start(instance);
243-
control.waitStarted("jdk-testing");
241+
control.startAndAwait(instance);
244242
}
245243

246244
/**

src/test/java/org/tarantool/AbstractTarantoolSQLConnectorIT.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,11 @@ protected static TarantoolConsole openConsole(String instance) {
130130
}
131131

132132
protected static void stopTarantool(String instance) {
133-
control.stop(instance);
134-
control.waitStopped("jdk-testing");
133+
control.stopAndAwait(instance);
135134
}
136135

137136
protected static void startTarantool(String instance) {
138-
control.start(instance);
139-
control.waitStarted("jdk-testing");
137+
control.startAndAwait(instance);
140138
}
141139

142140
}

src/test/java/org/tarantool/ClientReconnectClusterIT.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public class ClientReconnectClusterIT {
2929
AbstractTarantoolConnectorIT.password,
3030
"localhost:" + PORTS[0],
3131
"localhost:" + PORTS[1],
32-
"localhost:" + PORTS[2]);
32+
"localhost:" + PORTS[2]
33+
);
3334

3435
// Resume replication faster in case of temporary failure to fit TIMEOUT.
3536
private static double REPLICATION_TIMEOUT = 0.1;
@@ -59,6 +60,7 @@ public static void tearDownEnv() {
5960

6061
@Test
6162
public void testRoundRobinReconnect() {
63+
// start instances simultaneously to sync up them
6264
control.start(SRV1);
6365
control.start(SRV2);
6466
control.start(SRV3);
@@ -89,17 +91,17 @@ public void testRoundRobinReconnect() {
8991
List<?> res = client.syncOps().select(spaceId, pkId, key, 0, 1, Iterator.EQ);
9092
assertEquals(res.get(0), tuple);
9193

92-
control.stop(SRV1);
94+
control.stopAndAwait(SRV1);
9395

9496
res = client.syncOps().select(spaceId, pkId, key, 0, 1, Iterator.EQ);
9597
assertEquals(res.get(0), Arrays.asList(1, 1));
9698

97-
control.stop(SRV2);
99+
control.stopAndAwait(SRV2);
98100

99101
res = client.syncOps().select(spaceId, pkId, key, 0, 1, Iterator.EQ);
100102
assertEquals(res.get(0), Arrays.asList(1, 1));
101103

102-
control.stop(SRV3);
104+
control.stopAndAwait(SRV3);
103105

104106
CommunicationException e = assertThrows(CommunicationException.class, new Executable() {
105107
@Override

src/test/java/org/tarantool/ClientReconnectIT.java

+19
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
import static org.junit.jupiter.api.Assertions.assertFalse;
55
import static org.junit.jupiter.api.Assertions.assertNotNull;
66
import static org.junit.jupiter.api.Assertions.assertThrows;
7+
import static org.junit.jupiter.api.Assertions.assertTimeout;
78
import static org.junit.jupiter.api.Assertions.assertTrue;
89
import static org.junit.jupiter.api.Assertions.fail;
910

1011
import org.junit.jupiter.api.AfterAll;
1112
import org.junit.jupiter.api.AfterEach;
13+
import org.junit.jupiter.api.Disabled;
14+
import org.junit.jupiter.api.DisplayName;
1215
import org.junit.jupiter.api.Test;
1316
import org.junit.jupiter.api.function.Executable;
1417

1518
import java.nio.channels.SocketChannel;
19+
import java.time.Duration;
1620
import java.util.Collections;
1721
import java.util.List;
1822
import java.util.Random;
@@ -213,6 +217,21 @@ public void run() {
213217
});
214218
}
215219

220+
@Test
221+
@Disabled
222+
@DisplayName("follow up the issue #164")
223+
void testStartStopTarantoolInstance() {
224+
assertTimeout(Duration.ofSeconds(30), () -> {
225+
for (int i = 0; i < 100; i++) {
226+
stopTarantool(INSTANCE_NAME);
227+
startTarantool(INSTANCE_NAME);
228+
if (i % 10 == 0) {
229+
System.out.println(i + "% completed");
230+
}
231+
}
232+
});
233+
}
234+
216235
/**
217236
* Test concurrent operations, reconnects and close.
218237
*

0 commit comments

Comments
 (0)