This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-16771
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/ignite-16771 by this push:
     new 5a35aaf26 wip 
testClientSendsComputeJobToTargetNodeWhenDirectConnectionExists
5a35aaf26 is described below

commit 5a35aaf26c1cae6141a89b4872c01247a8d91eeb
Author: Pavel Tupitsyn <ptupit...@apache.org>
AuthorDate: Thu Apr 14 18:33:55 2022 +0300

    wip testClientSendsComputeJobToTargetNodeWhenDirectConnectionExists
---
 .../test/java/org/apache/ignite/client/ClientComputeTest.java |  8 ++++++--
 .../org/apache/ignite/client/TestClientHandlerModule.java     | 11 ++++++++---
 .../src/test/java/org/apache/ignite/client/TestServer.java    |  9 +++++++--
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git 
a/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java 
b/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java
index 976a3367c..bf9504028 100644
--- 
a/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java
+++ 
b/modules/client/src/test/java/org/apache/ignite/client/ClientComputeTest.java
@@ -48,9 +48,13 @@ public class ClientComputeTest {
         initServers(reqId -> false);
 
         try (var client = getClient()) {
-            String res = 
client.compute().<String>execute(getClusterNodes("s1"), "job").join();
+            String res1 = 
client.compute().<String>execute(getClusterNodes("s1"), "job").join();
+            String res2 = 
client.compute().<String>execute(getClusterNodes("s2"), "job").join();
+            String res3 = 
client.compute().<String>execute(getClusterNodes("s3"), "job").join();
 
-            assertEquals("x", res);
+            assertEquals("s1", res1);
+            assertEquals("s2", res2);
+            assertEquals("s3", res3);
         }
     }
 
diff --git 
a/modules/client/src/test/java/org/apache/ignite/client/TestClientHandlerModule.java
 
b/modules/client/src/test/java/org/apache/ignite/client/TestClientHandlerModule.java
index 5c94e6882..cd9c9b813 100644
--- 
a/modules/client/src/test/java/org/apache/ignite/client/TestClientHandlerModule.java
+++ 
b/modules/client/src/test/java/org/apache/ignite/client/TestClientHandlerModule.java
@@ -43,7 +43,6 @@ import org.apache.ignite.lang.IgniteException;
 import org.apache.ignite.network.ClusterService;
 import org.apache.ignite.network.NettyBootstrapFactory;
 import org.jetbrains.annotations.Nullable;
-import org.mockito.Mockito;
 
 /**
  * Client handler module for tests.
@@ -61,6 +60,9 @@ public class TestClientHandlerModule implements 
IgniteComponent {
     /** Cluster service. */
     private final ClusterService clusterService;
 
+    /** Compute. */
+    private final IgniteCompute compute;
+
     /** Netty channel. */
     private volatile Channel channel;
 
@@ -74,13 +76,15 @@ public class TestClientHandlerModule implements 
IgniteComponent {
      * @param bootstrapFactory     Bootstrap factory.
      * @param shouldDropConnection Connection drop condition.
      * @param clusterService       Cluster service.
+     * @param compute              Compute.
      */
     public TestClientHandlerModule(
             Ignite ignite,
             ConfigurationRegistry registry,
             NettyBootstrapFactory bootstrapFactory,
             Function<Integer, Boolean> shouldDropConnection,
-            ClusterService clusterService) {
+            ClusterService clusterService,
+            IgniteCompute compute) {
         assert ignite != null;
         assert registry != null;
         assert bootstrapFactory != null;
@@ -90,6 +94,7 @@ public class TestClientHandlerModule implements 
IgniteComponent {
         this.bootstrapFactory = bootstrapFactory;
         this.shouldDropConnection = shouldDropConnection;
         this.clusterService = clusterService;
+        this.compute = compute;
     }
 
     /** {@inheritDoc} */
@@ -156,7 +161,7 @@ public class TestClientHandlerModule implements 
IgniteComponent {
                                         ignite.transactions(),
                                         mock(QueryProcessor.class),
                                         configuration,
-                                        mock(IgniteCompute.class),
+                                        compute,
                                         clusterService));
                     }
                 })
diff --git 
a/modules/client/src/test/java/org/apache/ignite/client/TestServer.java 
b/modules/client/src/test/java/org/apache/ignite/client/TestServer.java
index ed7d407a4..458c7d497 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/TestServer.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/TestServer.java
@@ -19,6 +19,7 @@ package org.apache.ignite.client;
 
 import static 
org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL;
 import static org.mockito.Answers.RETURNS_DEEP_STUBS;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.mock;
 
@@ -27,6 +28,7 @@ import java.net.SocketAddress;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
 import java.util.function.Function;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.client.fakes.FakeIgnite;
@@ -117,14 +119,17 @@ public class TestServer implements AutoCloseable {
         
Mockito.when(clusterService.topologyService().getByConsistentId(anyString())).thenAnswer(
                 i -> getClusterNode(i.getArgument(0, String.class)));
 
+        IgniteCompute compute = mock(IgniteCompute.class);
+        Mockito.when(compute.execute(any(), anyString(), 
any())).thenReturn(CompletableFuture.completedFuture(nodeName));
+
         module = shouldDropConnection != null
-                ? new TestClientHandlerModule(ignite, cfg, bootstrapFactory, 
shouldDropConnection, clusterService)
+                ? new TestClientHandlerModule(ignite, cfg, bootstrapFactory, 
shouldDropConnection, clusterService, compute)
                 : new ClientHandlerModule(
                         ((FakeIgnite) ignite).queryEngine(),
                         ignite.tables(),
                         ignite.transactions(),
                         cfg,
-                        mock(IgniteCompute.class),
+                        compute,
                         clusterService,
                         bootstrapFactory
                 );

Reply via email to