Skip to content

Commit 62d2cc7

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: #164
1 parent 7cdb58c commit 62d2cc7

6 files changed

+183
-89
lines changed

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,10 @@ protected List<?> consoleDelete(String spaceName, Object key) {
235235

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

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

246244
/**

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,10 @@ protected static TarantoolConsole openConsole(String instance) {
131131

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

137136
protected static void startTarantool(String instance) {
138-
control.start(instance);
139-
control.waitStarted("jdk-testing");
137+
control.stop(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,9 +60,10 @@ public static void tearDownEnv() {
5960

6061
@Test
6162
public void testRoundRobinReconnect() {
62-
control.start(SRV1);
63-
control.start(SRV2);
64-
control.start(SRV3);
63+
// start instances simultaneously to sync up them
64+
control.start(SRV1, false);
65+
control.start(SRV2, false);
66+
control.start(SRV3, false);
6567

6668
control.waitStarted(SRV1);
6769
control.waitStarted(SRV2);

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

+40
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
import static org.junit.jupiter.api.Assertions.assertThrows;
77
import static org.junit.jupiter.api.Assertions.assertTrue;
88
import static org.junit.jupiter.api.Assertions.fail;
9+
import static org.tarantool.TestUtils.makeInstanceEnv;
910

1011
import org.junit.jupiter.api.AfterAll;
1112
import org.junit.jupiter.api.AfterEach;
13+
import org.junit.jupiter.api.DisplayName;
1214
import org.junit.jupiter.api.Test;
1315
import org.junit.jupiter.api.function.Executable;
1416

1517
import java.nio.channels.SocketChannel;
18+
import java.util.ArrayList;
1619
import java.util.Collections;
1720
import java.util.List;
1821
import java.util.Random;
@@ -213,6 +216,43 @@ public void run() {
213216
});
214217
}
215218

219+
@Test
220+
@DisplayName("follow up the issue #164")
221+
void testStartStopTarantoolInstance() throws InterruptedException {
222+
int numberOfParallelInstances = 4;
223+
CountDownLatch finished = new CountDownLatch(numberOfParallelInstances);
224+
List<String> instancesNames = new ArrayList<>(numberOfParallelInstances);
225+
226+
for (int i = 0; i < numberOfParallelInstances; i++) {
227+
String instance = "startStop" + (i + 1);
228+
instancesNames.add(instance);
229+
control.createInstance(
230+
instancesNames.get(i),
231+
LUA_FILE,
232+
makeInstanceEnv(3301 + i + 1, 3321 + i + 1)
233+
);
234+
startTarantool(instancesNames.get(i));
235+
new Thread(() -> {
236+
for (int j = 0; j < 100; j++) {
237+
stopTarantool(instance);
238+
startTarantool(instance);
239+
if (j % 10 == 0) {
240+
System.out.println(
241+
Thread.currentThread().getName() + ": " + j + "% completed"
242+
);
243+
}
244+
}
245+
finished.countDown();
246+
}, "Thread" + i).start();
247+
}
248+
249+
for (int i = 0; i < numberOfParallelInstances; i++) {
250+
stopTarantool(instancesNames.get(i));
251+
}
252+
253+
assertTrue(finished.await(2, TimeUnit.MINUTES));
254+
}
255+
216256
/**
217257
* Test concurrent operations, reconnects and close.
218258
*

0 commit comments

Comments
 (0)