You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by al...@apache.org on 2021/02/10 07:36:55 UTC
[ignite] branch master updated: IGNITE-14136 Fix flaky
ServicesTest.testServiceTimeout - Fixes #8765.
This is an automated email from the ASF dual-hosted git repository.
alexpl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 4c412a8 IGNITE-14136 Fix flaky ServicesTest.testServiceTimeout - Fixes #8765.
4c412a8 is described below
commit 4c412a8a921dd278f7e09162fbe025bda0299d59
Author: Aleksey Plekhanov <pl...@gmail.com>
AuthorDate: Wed Feb 10 10:29:22 2021 +0300
IGNITE-14136 Fix flaky ServicesTest.testServiceTimeout - Fixes #8765.
Signed-off-by: Aleksey Plekhanov <pl...@gmail.com>
---
.../ignite/internal/client/thin/ServicesTest.java | 29 +++++++++++++---------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ServicesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ServicesTest.java
index 9f0641a..31e83c3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ServicesTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ServicesTest.java
@@ -22,14 +22,14 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import org.apache.ignite.Ignite;
import org.apache.ignite.client.ClientClusterGroup;
import org.apache.ignite.client.ClientException;
import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.client.Person;
-import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.services.Service;
import org.apache.ignite.services.ServiceContext;
@@ -255,9 +255,15 @@ public class ServicesTest extends AbstractThinClientTest {
TestServiceInterface svc = client.services().serviceProxy(CLUSTER_SINGLTON_SERVICE_NAME,
TestServiceInterface.class, timeout);
- IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() -> svc.sleep(timeout * 2));
+ TestService.latch = new CountDownLatch(1);
- GridTestUtils.assertThrowsAnyCause(log, fut::get, ClientException.class, "timed out");
+ GridTestUtils.assertThrowsAnyCause(log, svc::waitLatch, ClientException.class, "timed out");
+ }
+ finally {
+ if (TestService.latch != null) {
+ TestService.latch.countDown();
+ TestService.latch = null;
+ }
}
}
@@ -294,13 +300,16 @@ public class ServicesTest extends AbstractThinClientTest {
public Object testException();
/** */
- public void sleep(long millis);
+ public boolean waitLatch() throws Exception;
}
/**
* Implementation of TestServiceInterface.
*/
public static class TestService implements Service, TestServiceInterface {
+ /** Latch. */
+ public static CountDownLatch latch;
+
/** {@inheritDoc} */
@Override public void cancel(ServiceContext ctx) {
// No-op.
@@ -367,14 +376,10 @@ public class ServicesTest extends AbstractThinClientTest {
}
/** {@inheritDoc} */
- @Override public void sleep(long millis) {
- long ts = U.currentTimeMillis();
-
- doSleep(millis);
+ @Override public boolean waitLatch() throws Exception {
+ latch.await(10L, TimeUnit.SECONDS);
- // Make sure cached timestamp updated.
- while (ts + millis >= U.currentTimeMillis())
- doSleep(100L);
+ return true;
}
}