You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2021/11/22 19:29:05 UTC
[ignite-3] branch ignite-15307 updated: Build fixed
This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch ignite-15307
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/ignite-15307 by this push:
new efd050b Build fixed
efd050b is described below
commit efd050b8bce88476f73404e00ad8a97afeb2d499
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Mon Nov 22 22:28:57 2021 +0300
Build fixed
---
.../apache/ignite/client/AbstractClientTest.java | 42 ++--------
.../org/apache/ignite/client/ReconnectTest.java | 14 ++--
.../java/org/apache/ignite/client/TestServer.java | 89 ++++++++++++++++++++++
3 files changed, 100 insertions(+), 45 deletions(-)
diff --git a/modules/client/src/test/java/org/apache/ignite/client/AbstractClientTest.java b/modules/client/src/test/java/org/apache/ignite/client/AbstractClientTest.java
index fbb41ed..5764560 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/AbstractClientTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/AbstractClientTest.java
@@ -17,22 +17,15 @@
package org.apache.ignite.client;
-import static org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import io.netty.util.ResourceLeakDetector;
import java.net.InetSocketAddress;
-import java.util.List;
-import java.util.Map;
import java.util.Objects;
import org.apache.ignite.Ignite;
import org.apache.ignite.client.fakes.FakeIgnite;
import org.apache.ignite.client.handler.ClientHandlerModule;
-import org.apache.ignite.configuration.schemas.clientconnector.ClientConnectorConfiguration;
-import org.apache.ignite.internal.configuration.ConfigurationRegistry;
-import org.apache.ignite.internal.configuration.storage.TestConfigurationStorage;
-import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.table.Tuple;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
@@ -44,9 +37,7 @@ import org.junit.jupiter.api.BeforeEach;
public abstract class AbstractClientTest {
protected static final String DEFAULT_TABLE = "default_test_table";
- protected static ConfigurationRegistry configurationRegistry;
-
- protected static ClientHandlerModule clientHandlerModule;
+ protected static TestServer testServer;
protected static Ignite server;
@@ -63,12 +54,9 @@ public abstract class AbstractClientTest {
server = new FakeIgnite();
- IgniteBiTuple<ClientHandlerModule, ConfigurationRegistry> srv = startServer(10800, 10, server);
-
- clientHandlerModule = srv.get1();
- configurationRegistry = srv.get2();
+ testServer = startServer(10800, 10, server);
- serverPort = getPort(clientHandlerModule);
+ serverPort = getPort(testServer.module());
client = startClient();
}
@@ -79,8 +67,7 @@ public abstract class AbstractClientTest {
@AfterAll
public static void afterAll() throws Exception {
client.close();
- clientHandlerModule.stop();
- configurationRegistry.stop();
+ testServer.close();
}
/**
@@ -117,29 +104,12 @@ public abstract class AbstractClientTest {
* @param ignite Ignite.
* @return Server.
*/
- public static IgniteBiTuple<ClientHandlerModule, ConfigurationRegistry> startServer(
+ public static TestServer startServer(
int port,
int portRange,
Ignite ignite
) {
- var cfg = new ConfigurationRegistry(
- List.of(ClientConnectorConfiguration.KEY),
- Map.of(),
- new TestConfigurationStorage(LOCAL),
- List.of(),
- List.of()
- );
-
- cfg.start();
-
- cfg.getConfiguration(ClientConnectorConfiguration.KEY).change(
- local -> local.changePort(port).changePortRange(portRange)
- ).join();
-
- var module = new ClientHandlerModule(((FakeIgnite) ignite).queryEngine(), ignite.tables(), cfg);
- module.start();
-
- return new IgniteBiTuple<>(module, cfg);
+ return new TestServer(port, portRange, ignite);
}
/**
diff --git a/modules/client/src/test/java/org/apache/ignite/client/ReconnectTest.java b/modules/client/src/test/java/org/apache/ignite/client/ReconnectTest.java
index ab3ebb5..754244a 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/ReconnectTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/ReconnectTest.java
@@ -22,9 +22,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.concurrent.CompletionException;
import org.apache.ignite.client.fakes.FakeIgnite;
-import org.apache.ignite.client.handler.ClientHandlerModule;
-import org.apache.ignite.internal.configuration.ConfigurationRegistry;
-import org.apache.ignite.lang.IgniteBiTuple;
import org.junit.jupiter.api.Test;
/**
@@ -33,8 +30,8 @@ import org.junit.jupiter.api.Test;
public class ReconnectTest {
@Test
public void clientReconnectsToAnotherAddressOnNodeFail() throws Exception {
- IgniteBiTuple<ClientHandlerModule, ConfigurationRegistry> srv = null;
- IgniteBiTuple<ClientHandlerModule, ConfigurationRegistry> srv2 = null;
+ TestServer srv = null;
+ TestServer srv2 = null;
try {
FakeIgnite ignite1 = new FakeIgnite();
@@ -71,7 +68,7 @@ public class ReconnectTest {
@Test
public void testOperationFailsWhenAllServersFail() throws Exception {
- IgniteBiTuple<ClientHandlerModule, ConfigurationRegistry> srv = null;
+ TestServer srv = null;
try {
FakeIgnite ignite1 = new FakeIgnite();
@@ -98,12 +95,11 @@ public class ReconnectTest {
}
}
- private void stop(IgniteBiTuple<ClientHandlerModule, ConfigurationRegistry> srv) throws Exception {
+ private void stop(AutoCloseable srv) throws Exception {
if (srv == null) {
return;
}
- srv.get1().stop();
- srv.get2().stop();
+ srv.close();
}
}
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
new file mode 100644
index 0000000..943914e
--- /dev/null
+++ b/modules/client/src/test/java/org/apache/ignite/client/TestServer.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.client;
+
+import static org.apache.ignite.configuration.annotation.ConfigurationType.LOCAL;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.client.fakes.FakeIgnite;
+import org.apache.ignite.client.handler.ClientHandlerModule;
+import org.apache.ignite.configuration.schemas.clientconnector.ClientConnectorConfiguration;
+import org.apache.ignite.configuration.schemas.network.NetworkConfiguration;
+import org.apache.ignite.internal.configuration.ConfigurationRegistry;
+import org.apache.ignite.internal.configuration.storage.TestConfigurationStorage;
+import org.apache.ignite.network.NettyBootstrapFactory;
+
+/**
+ * Test server.
+ */
+public class TestServer implements AutoCloseable {
+ private final ConfigurationRegistry cfg;
+
+ private final ClientHandlerModule module;
+
+ private final NettyBootstrapFactory bootstrapFactory;
+
+ public TestServer(
+ int port,
+ int portRange,
+ Ignite ignite
+ ) {
+ cfg = new ConfigurationRegistry(
+ List.of(ClientConnectorConfiguration.KEY, NetworkConfiguration.KEY),
+ Map.of(),
+ new TestConfigurationStorage(LOCAL),
+ List.of(),
+ List.of()
+ );
+
+ cfg.start();
+
+ cfg.getConfiguration(ClientConnectorConfiguration.KEY).change(
+ local -> local.changePort(port).changePortRange(portRange)
+ ).join();
+
+ bootstrapFactory = new NettyBootstrapFactory(cfg.getConfiguration(NetworkConfiguration.KEY), "TestServer-");
+
+ bootstrapFactory.start();
+
+ module = new ClientHandlerModule(((FakeIgnite) ignite).queryEngine(), ignite.tables(), cfg, bootstrapFactory);
+
+ module.start();
+ }
+
+ public ConfigurationRegistry configurationRegistry() {
+ return cfg;
+ }
+
+ public ClientHandlerModule module() {
+ return module;
+ }
+
+ public NettyBootstrapFactory bootstrapFactory() {
+ return bootstrapFactory;
+ }
+
+ @Override
+ public void close() throws Exception {
+ module.stop();
+ bootstrapFactory.stop();
+ cfg.stop();
+ }
+}