alex-plekhanov commented on code in PR #13501:
URL: https://github.com/apache/ignite/pull/13501#discussion_r3822573937
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessorSelfTest.java:
##########
@@ -133,6 +134,65 @@ public void testTimeouts() throws Exception {
}
}
+ /**
+ * Tests that non-blocking cancellation doesn't wait for a running task
holding the task monitor and prevents
+ * subsequent executions.
+ *
+ * @throws Exception If test failed.
+ */
+ @Test
+ public void testNonBlockingCancel() throws Exception {
+ ReentrantLock sslLock = new ReentrantLock();
+ CountDownLatch lockAcquired = new CountDownLatch(1);
+ CountDownLatch taskStarted = new CountDownLatch(1);
+ AtomicInteger taskCallCnt = new AtomicInteger();
+
+ GridTimeoutProcessor.CancelableTask task = ctx.timeout().schedule(()
-> {
+ taskCallCnt.incrementAndGet();
+
+ taskStarted.countDown();
+
+ sslLock.lock();
+
+ try {
+ // No-op.
+ }
+ finally {
+ sslLock.unlock();
+ }
+ }, 60_000, 1_000);
+
+ IgniteInternalFuture<?> cancelFut = GridTestUtils.runAsync(() -> {
+ // Emulates the NIO worker cancelling the handshake timeout under
the SSL handler lock.
+ sslLock.lock();
+
+ try {
+ lockAcquired.countDown();
+
+ taskStarted.await();
+
+ task.cancel();
+ }
+ finally {
+ sslLock.unlock();
+ }
+ }, "test-cancel-thread");
+
+ assertTrue(lockAcquired.await(10_000, MILLISECONDS));
+
+ IgniteInternalFuture<?> timeoutFut =
GridTestUtils.runAsync(task::onTimeout, "test-timeout-thread");
Review Comment:
Why do we start onTimeout manually? Why can't we rely on timeout object
processor?
IMO we can insert `lockAcquired.await()` to timeout object before
`taskStarted.countDown()` and set delay to 0. The logic will remain the same,
but with regular workflow.
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessorSelfTest.java:
##########
@@ -133,6 +134,65 @@ public void testTimeouts() throws Exception {
}
}
+ /**
+ * Tests that non-blocking cancellation doesn't wait for a running task
holding the task monitor and prevents
+ * subsequent executions.
+ *
+ * @throws Exception If test failed.
+ */
+ @Test
+ public void testNonBlockingCancel() throws Exception {
+ ReentrantLock sslLock = new ReentrantLock();
Review Comment:
Lock in test is not related to SSL somehow
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]