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

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


The following commit(s) were added to refs/heads/main by this push:
     new 8442bf9787 IGNITE-22982 Use cached client in compute tests (#4230)
8442bf9787 is described below

commit 8442bf9787b47e00042c5fe925533ecd441b6b2d
Author: Vadim Pakhnushev <[email protected]>
AuthorDate: Wed Aug 14 14:18:04 2024 +0300

    IGNITE-22982 Use cached client in compute tests (#4230)
---
 .../client/ItThinClientComputeMarshallingTest.java | 48 +++++-----------------
 ...tThinClientComputeTypeCheckMarshallingTest.java | 43 ++++---------------
 2 files changed, 20 insertions(+), 71 deletions(-)

diff --git 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeMarshallingTest.java
 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeMarshallingTest.java
index ed005eed42..a5835951dc 100644
--- 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeMarshallingTest.java
+++ 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeMarshallingTest.java
@@ -26,11 +26,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
-import org.apache.ignite.Ignite;
 import org.apache.ignite.catalog.ColumnType;
 import org.apache.ignite.catalog.definitions.TableDefinition;
-import org.apache.ignite.client.IgniteClient;
-import org.apache.ignite.compute.IgniteCompute;
 import org.apache.ignite.compute.JobDescriptor;
 import org.apache.ignite.compute.JobTarget;
 import org.apache.ignite.compute.TaskDescriptor;
@@ -74,13 +71,11 @@ public class ItThinClientComputeMarshallingTest extends 
ItAbstractThinClientTest
     @ParameterizedTest
     @ValueSource(ints = {0, 1})
     void customArgMarshaller(int targetNodeIdx) {
-        // Given entry node for client.
-        var node = server(0);
-        // And.
+        // Given target node.
         var targetNode = node(targetNodeIdx);
 
         // When run job with custom marshaller for string argument.
-        String result = computeClientOn(node).execute(
+        String result = client().compute().execute(
                 JobTarget.node(targetNode),
                 // Accepts string argument and defines marshaller for it.
                 JobDescriptor.builder(ArgMarshallingJob.class)
@@ -102,13 +97,11 @@ public class ItThinClientComputeMarshallingTest extends 
ItAbstractThinClientTest
     @ParameterizedTest
     @ValueSource(ints = {0, 1})
     void customResultMarshaller(int targetNodeIdx) {
-        // Given entry node for client.
-        var node = server(0);
-        // And.
+        // Given target node.
         var targetNode = node(targetNodeIdx);
 
         // When run job with custom marshaller for string result.
-        String result = computeClientOn(node).execute(
+        String result = client().compute().execute(
                 JobTarget.node(targetNode),
                 // Returns string result and defines marshaller for it.
                 JobDescriptor.builder(ResultMarshallingJob.class)
@@ -130,13 +123,11 @@ public class ItThinClientComputeMarshallingTest extends 
ItAbstractThinClientTest
     @ParameterizedTest
     @ValueSource(ints = {0, 1})
     void customResultAndArgumentMarshallerExecutedOnSameNode(int 
targetNodeIdx) {
-        // Given entry node for client.
-        var node = server(0);
-        // And.
+        // Given target node.
         var targetNode = node(targetNodeIdx);
 
         // When run job with custom marshaller for string result.
-        String result = computeClientOn(node).execute(
+        String result = client().compute().execute(
                 JobTarget.node(targetNode),
                 // The job defines custom marshaller for both argument and 
result.
                 JobDescriptor.builder(ArgumentAndResultMarshallingJob.class)
@@ -161,13 +152,11 @@ public class ItThinClientComputeMarshallingTest extends 
ItAbstractThinClientTest
     @ParameterizedTest
     @ValueSource(ints = {0, 1})
     void pojoJobWithMarshallers(int targetNodeIdx) {
-        // Given entry node for client.
-        var node = server(0);
-        // And.
+        // Given target node.
         var targetNode = node(targetNodeIdx);
 
         // When run job with custom marshaller for pojo argument and result.
-        PojoResult result = computeClientOn(node).execute(
+        PojoResult result = client().compute().execute(
                 JobTarget.node(targetNode),
                 // The job accepts PojoArg and returns PojoResult and defines 
marshaller for both.
                 JobDescriptor.builder(PojoJob.class)
@@ -184,11 +173,8 @@ public class ItThinClientComputeMarshallingTest extends 
ItAbstractThinClientTest
 
     @Test
     void broadcast() {
-        // Given entry node.
-        var node = server(0);
-
         // When.
-        Map<ClusterNode, String> result = 
computeClientOn(node).executeBroadcast(
+        Map<ClusterNode, String> result = client().compute().executeBroadcast(
                 Set.of(node(0), node(1)),
                 JobDescriptor.builder(ArgumentAndResultMarshallingJob.class)
                         .argumentMarshaller(new ArgumentStringMarshaller())
@@ -224,8 +210,7 @@ public class ItThinClientComputeMarshallingTest extends 
ItAbstractThinClientTest
         // When run job with custom marshaller for string argument.
         var tup = Tuple.create().set("key", 1);
 
-        var compute = computeClientOn(node);
-        String result = compute.execute(
+        String result = client().compute().execute(
                 JobTarget.colocated(tableName, tup),
                 JobDescriptor.builder(ArgMarshallingJob.class)
                         .argumentMarshaller(new ArgumentStringMarshaller())
@@ -245,12 +230,8 @@ public class ItThinClientComputeMarshallingTest extends 
ItAbstractThinClientTest
     @Test
     @Disabled("https://issues.apache.org/jira/browse/IGNITE-22787";)
     void mapReduce() {
-        // Given entry node.
-        var node = server(0);
-
         // When run job with custom marshaller for string argument.
-        var compute = computeClientOn(node);
-        String result = compute.executeMapReduce(
+        String result = client().compute().executeMapReduce(
                 TaskDescriptor.builder(MapReduce.class).build(),
                 List.of("Input_0", "Input_1"));
 
@@ -263,13 +244,6 @@ public class ItThinClientComputeMarshallingTest extends 
ItAbstractThinClientTest
         );
     }
 
-    private static IgniteCompute computeClientOn(Ignite node) {
-        return IgniteClient.builder()
-                .addresses(getClientAddresses(List.of(node)).toArray(new 
String[0]))
-                .build()
-                .compute();
-    }
-
     private ClusterNode node(int idx) {
         return sortedNodes().get(idx);
     }
diff --git 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeTypeCheckMarshallingTest.java
 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeTypeCheckMarshallingTest.java
index 9fa684bce2..017063c709 100644
--- 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeTypeCheckMarshallingTest.java
+++ 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeTypeCheckMarshallingTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.runner.app.client;
 
 import static java.util.concurrent.CompletableFuture.completedFuture;
+import static org.awaitility.Awaitility.await;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.instanceOf;
@@ -33,11 +34,8 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.client.IgniteClient;
 import org.apache.ignite.compute.ComputeException;
 import org.apache.ignite.compute.ComputeJob;
-import org.apache.ignite.compute.IgniteCompute;
 import org.apache.ignite.compute.JobDescriptor;
 import org.apache.ignite.compute.JobExecution;
 import org.apache.ignite.compute.JobExecutionContext;
@@ -60,37 +58,29 @@ import org.junit.jupiter.api.Test;
 public class ItThinClientComputeTypeCheckMarshallingTest extends 
ItAbstractThinClientTest {
     @Test
     void argumentMarshallerDefinedOnlyInJob() {
-        // Given.
-        var node = server(0);
-
         // When submit job with custom marshaller that is defined in job but
         // client JobDescriptor does not declare the argument marshaller.
-        var compute = computeClientOn(node);
-        JobExecution<String> result = compute.submit(
+        JobExecution<String> result = client().compute().submit(
                 JobTarget.node(node(1)),
                 JobDescriptor.builder(ArgMarshallingJob.class).build(),
                 "Input"
         );
 
-        assertStatusFailed(result);
+        await().untilAsserted(() -> assertStatusFailed(result));
         assertResultFailsWithErr(Compute.MARSHALLING_TYPE_MISMATCH_ERR, 
result);
     }
 
     @Test
     void resultMarshallerDefinedOnlyInJob() {
-        // Given.
-        var node = server(0);
-
         // When submit job with custom marshaller that is defined in job but
         // client JobDescriptor does not declare the result marshaller.
-        var compute = computeClientOn(node);
-        JobExecution<String> result = compute.submit(
+        JobExecution<String> result = client().compute().submit(
                 JobTarget.node(node(1)),
                 JobDescriptor.builder(ResultMarshallingJob.class).build(),
                 "Input"
         );
 
-        assertStatusCompleted(result);
+        await().untilAsserted(() -> assertStatusCompleted(result));
         assertThrows(ClassCastException.class, () -> {
             String str = getSafe(result.resultAsync());
         });
@@ -98,13 +88,9 @@ public class ItThinClientComputeTypeCheckMarshallingTest 
extends ItAbstractThinC
 
     @Test
     void argumentMarshallerDoesNotMatch() {
-        // Given.
-        var node = server(0);
-
         // When submit job with custom marshaller that is defined in job but
         // client JobDescriptor does not declare the result marshaller.
-        var compute = computeClientOn(node);
-        JobExecution<Integer> result = compute.submit(
+        JobExecution<Integer> result = client().compute().submit(
                 JobTarget.node(node(1)),
                 // The descriptor does not match actual job arguments.
                 JobDescriptor.<Integer, 
Integer>builder(ArgumentTypeCheckingmarshallingJob.class.getName())
@@ -113,19 +99,15 @@ public class ItThinClientComputeTypeCheckMarshallingTest 
extends ItAbstractThinC
                 1
         );
 
-        assertStatusFailed(result);
+        await().untilAsserted(() -> assertStatusFailed(result));
         assertResultFailsWithErr(Compute.MARSHALLING_TYPE_MISMATCH_ERR, 
result);
     }
 
     @Test
     void resultMarshallerDoesNotMatch() {
-        // Given.
-        var node = server(0);
-
         // When submit job with custom marshaller that is defined in job but
         // client JobDescriptor does not declare the result marshaller.
-        var compute = computeClientOn(node);
-        JobExecution<Integer> result = compute.submit(
+        JobExecution<Integer> result = client().compute().submit(
                 JobTarget.node(node(1)),
                 // The descriptor does not match actual result.
                 JobDescriptor.<String, 
Integer>builder(ResultMarshallingJob.class.getName())
@@ -134,7 +116,7 @@ public class ItThinClientComputeTypeCheckMarshallingTest 
extends ItAbstractThinC
                 "Input"
         );
 
-        assertStatusCompleted(result);
+        await().untilAsserted(() -> assertStatusCompleted(result));
         assertThrows(ClassCastException.class, () -> {
             Integer i = getSafe(result.resultAsync());
         });
@@ -214,13 +196,6 @@ public class ItThinClientComputeTypeCheckMarshallingTest 
extends ItAbstractThinC
         }
     }
 
-    private IgniteCompute computeClientOn(Ignite node) {
-        return IgniteClient.builder()
-                .addresses(getClientAddresses(List.of(node)).toArray(new 
String[0]))
-                .build()
-                .compute();
-    }
-
     private ClusterNode node(int idx) {
         return sortedNodes().get(idx);
     }

Reply via email to