This is an automated email from the ASF dual-hosted git repository.
mpochatkin 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 352da58f2e8 IGNITE-26114 Extract common thin client testing
functionality (#6360)
352da58f2e8 is described below
commit 352da58f2e8494adcad9d424c30f2e1e7b1cf838
Author: Vadim Pakhnushev <[email protected]>
AuthorDate: Mon Aug 4 16:41:05 2025 +0300
IGNITE-26114 Extract common thin client testing functionality (#6360)
---
.../internal/compute/ItComputeTestClient.java | 22 +++-----------
.../compute/ItThinClientComputeErrorsTest.java | 22 ++++----------
.../compute/ItThinClientWorkerShutdownTest.java | 20 ++++---------
.../Clients.java} | 35 ++++++++++++++--------
4 files changed, 37 insertions(+), 62 deletions(-)
diff --git
a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItComputeTestClient.java
b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItComputeTestClient.java
index 199539ac4b1..df96f7eb69a 100644
---
a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItComputeTestClient.java
+++
b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItComputeTestClient.java
@@ -17,39 +17,25 @@
package org.apache.ignite.internal.compute;
-import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
-
-import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.compute.IgniteCompute;
-import org.apache.ignite.internal.ConfigOverride;
+import org.apache.ignite.internal.compute.utils.Clients;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
/**
* Integration tests for Compute functionality using thin client API.
*/
@SuppressWarnings("NewClassNamingConvention")
-@ConfigOverride(name = "ignite.compute.threadPoolSize", value = "1")
public class ItComputeTestClient extends ItComputeTestEmbedded {
- private IgniteClient client;
-
- @BeforeEach
- void startClient() {
- int port = unwrapIgniteImpl(node(0)).clientAddress().port();
-
- client = IgniteClient.builder()
- .addresses("localhost:" + port)
- .build();
- }
+ private final Clients clients = new Clients();
@AfterEach
void stopClient() {
- client.close();
+ clients.cleanup();
}
@Override
protected IgniteCompute compute() {
- return client.compute();
+ return clients.compute(node(0));
}
@Override
diff --git
a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItThinClientComputeErrorsTest.java
b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItThinClientComputeErrorsTest.java
index e5c5b936534..9e07444d27b 100644
---
a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItThinClientComputeErrorsTest.java
+++
b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItThinClientComputeErrorsTest.java
@@ -17,30 +17,20 @@
package org.apache.ignite.internal.compute;
-import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.compute.IgniteCompute;
-import org.junit.jupiter.api.AfterEach;
+import org.apache.ignite.internal.compute.utils.Clients;
+import org.junit.jupiter.api.AfterAll;
class ItThinClientComputeErrorsTest extends ItComputeErrorsBaseTest {
- private final Map<String, IgniteClient> clients = new HashMap<>();
+ private final Clients clients = new Clients();
- @AfterEach
+ @AfterAll
void cleanup() {
- for (IgniteClient igniteClient : clients.values()) {
- igniteClient.close();
- }
- clients.clear();
+ clients.cleanup();
}
@Override
protected IgniteCompute compute() {
- String address = "127.0.0.1:" +
unwrapIgniteImpl(CLUSTER.node(0)).clientAddress().port();
- IgniteClient client =
IgniteClient.builder().addresses(address).build();
- clients.put(address, client);
- return client.compute();
+ return clients.compute(node(0));
}
}
diff --git
a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItThinClientWorkerShutdownTest.java
b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItThinClientWorkerShutdownTest.java
index de805bab3f7..e33ee0e1a32 100644
---
a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItThinClientWorkerShutdownTest.java
+++
b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItThinClientWorkerShutdownTest.java
@@ -17,31 +17,21 @@
package org.apache.ignite.internal.compute;
-import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
-
-import java.util.HashMap;
-import java.util.Map;
import org.apache.ignite.Ignite;
-import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.compute.IgniteCompute;
+import org.apache.ignite.internal.compute.utils.Clients;
import org.junit.jupiter.api.AfterEach;
class ItThinClientWorkerShutdownTest extends ItWorkerShutdownTest {
- private final Map<String, IgniteClient> clients = new HashMap<>();
+ private final Clients clients = new Clients();
@AfterEach
void cleanup() {
- for (IgniteClient igniteClient : clients.values()) {
- igniteClient.close();
- }
- clients.clear();
+ clients.cleanup();
}
@Override
- IgniteCompute compute(Ignite entryNode) {
- String address = "127.0.0.1:" +
unwrapIgniteImpl(entryNode).clientAddress().port();
- IgniteClient client =
IgniteClient.builder().addresses(address).build();
- clients.put(address, client);
- return client.compute();
+ protected IgniteCompute compute(Ignite entryNode) {
+ return clients.compute(entryNode);
}
}
diff --git
a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItThinClientWorkerShutdownTest.java
b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/utils/Clients.java
similarity index 65%
copy from
modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItThinClientWorkerShutdownTest.java
copy to
modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/utils/Clients.java
index de805bab3f7..dd889a5e402 100644
---
a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItThinClientWorkerShutdownTest.java
+++
b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/utils/Clients.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.ignite.internal.compute;
+package org.apache.ignite.internal.compute.utils;
import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
@@ -24,24 +24,33 @@ import java.util.Map;
import org.apache.ignite.Ignite;
import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.compute.IgniteCompute;
-import org.junit.jupiter.api.AfterEach;
-class ItThinClientWorkerShutdownTest extends ItWorkerShutdownTest {
+/**
+ * Utility class for keeping the list of thin clients in tests.
+ */
+public class Clients {
private final Map<String, IgniteClient> clients = new HashMap<>();
- @AfterEach
- void cleanup() {
+ /**
+ * Gets compute API for the thin client referenced by the embedded node.
+ *
+ * @param node Node to get the client for.
+ * @return Compute API.
+ */
+ public IgniteCompute compute(Ignite node) {
+ String address = "127.0.0.1:" +
unwrapIgniteImpl(node).clientAddress().port();
+ //noinspection resource
+ IgniteClient client = clients.computeIfAbsent(address, addr ->
IgniteClient.builder().addresses(addr).build());
+ return client.compute();
+ }
+
+ /**
+ * Cleans clients list.
+ */
+ public void cleanup() {
for (IgniteClient igniteClient : clients.values()) {
igniteClient.close();
}
clients.clear();
}
-
- @Override
- IgniteCompute compute(Ignite entryNode) {
- String address = "127.0.0.1:" +
unwrapIgniteImpl(entryNode).clientAddress().port();
- IgniteClient client =
IgniteClient.builder().addresses(address).build();
- clients.put(address, client);
- return client.compute();
- }
}