|
26 | 26 | import java.util.concurrent.locks.LockSupport;
|
27 | 27 |
|
28 | 28 | public class ClientReconnectIT extends AbstractTarantoolConnectorIT {
|
| 29 | + |
29 | 30 | private static final String INSTANCE_NAME = "jdk-testing";
|
30 | 31 | private TarantoolClient client;
|
31 | 32 |
|
@@ -99,7 +100,7 @@ public SocketChannel get(int retryNumber, Throwable lastError) {
|
99 | 100 | client.syncOps().ping();
|
100 | 101 |
|
101 | 102 | // The park() will return inside connector thread.
|
102 |
| - LockSupport.unpark(((TarantoolClientImpl)client).connector); |
| 103 | + LockSupport.unpark(((TarantoolClientImpl) client).connector); |
103 | 104 |
|
104 | 105 | // Wait on latch as a proof that reconnect did not happen.
|
105 | 106 | // In case of a failure, latch will reach 0 before timeout occurs.
|
@@ -213,11 +214,54 @@ public void run() {
|
213 | 214 | });
|
214 | 215 | }
|
215 | 216 |
|
| 217 | + // DO NOT REMOVE THIS TEST |
| 218 | + // Motivation: this test checks start/stop correctness |
| 219 | + // of TarantoolControl class which is used by other tests. |
| 220 | + // This test is commented out because the class is used |
| 221 | + // for internal purposes only and isn't related to |
| 222 | + // the connector testing. |
| 223 | +// @Test |
| 224 | +// @DisplayName("follow up the issue #164") |
| 225 | +// void testStartStopTarantoolInstance() throws InterruptedException { |
| 226 | +// int numberOfParallelInstances = 4; |
| 227 | +// CountDownLatch finished = new CountDownLatch(numberOfParallelInstances); |
| 228 | +// List<String> instancesNames = new ArrayList<>(numberOfParallelInstances); |
| 229 | +// |
| 230 | +// for (int i = 0; i < numberOfParallelInstances; i++) { |
| 231 | +// String instance = "startStop" + (i + 1); |
| 232 | +// instancesNames.add(instance); |
| 233 | +// control.createInstance( |
| 234 | +// instancesNames.get(i), |
| 235 | +// LUA_FILE, |
| 236 | +// makeInstanceEnv(3401 + i + 1, 3501 + i + 1) |
| 237 | +// ); |
| 238 | +// startTarantool(instancesNames.get(i)); |
| 239 | +// new Thread(() -> { |
| 240 | +// for (int j = 0; j < 100; j++) { |
| 241 | +// stopTarantool(instance); |
| 242 | +// startTarantool(instance); |
| 243 | +// if (j % 10 == 0) { |
| 244 | +// System.out.println( |
| 245 | +// Thread.currentThread().getName() + ": " + j + "% completed" |
| 246 | +// ); |
| 247 | +// } |
| 248 | +// } |
| 249 | +// finished.countDown(); |
| 250 | +// }, "Thread" + (i + 1)).start(); |
| 251 | +// } |
| 252 | +// |
| 253 | +// assertTrue(finished.await(2, TimeUnit.MINUTES)); |
| 254 | +// |
| 255 | +// for (int i = 0; i < numberOfParallelInstances; i++) { |
| 256 | +// stopTarantool(instancesNames.get(i)); |
| 257 | +// } |
| 258 | +// } |
| 259 | + |
216 | 260 | /**
|
217 | 261 | * Test concurrent operations, reconnects and close.
|
218 |
| - * |
| 262 | + * <p> |
219 | 263 | * Expected situation is nothing gets stuck.
|
220 |
| - * |
| 264 | + * <p> |
221 | 265 | * The test sets SO_LINGER to 0 for outgoing connections to avoid producing
|
222 | 266 | * many TIME_WAIT sockets, because an available port range can be
|
223 | 267 | * exhausted.
|
@@ -316,7 +360,7 @@ public void run() {
|
316 | 360 | * Verify that we don't exceed a file descriptor limit (and so likely don't
|
317 | 361 | * leak file descriptors) when trying to connect to an existing node with
|
318 | 362 | * wrong authentification credentials.
|
319 |
| - * |
| 363 | + * <p> |
320 | 364 | * The test sets SO_LINGER to 0 for outgoing connections to avoid producing
|
321 | 365 | * many TIME_WAIT sockets, because an available port range can be
|
322 | 366 | * exhausted.
|
@@ -354,4 +398,5 @@ public void execute() throws Throwable {
|
354 | 398 | client.syncOps().ping();
|
355 | 399 | client.close();
|
356 | 400 | }
|
| 401 | + |
357 | 402 | }
|
0 commit comments