From d2e7f310637118d34af0cbb8da08986beb74b602 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Fri, 28 Aug 2020 12:27:25 +0200 Subject: [PATCH 1/3] specify port range for the testing ignite instance so that unit tests can be run in parallel without interfering with each other --- oshdb-api/src/test/resources/ignite-config.xml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/oshdb-api/src/test/resources/ignite-config.xml b/oshdb-api/src/test/resources/ignite-config.xml index 7f5925615..a30f11e0f 100644 --- a/oshdb-api/src/test/resources/ignite-config.xml +++ b/oshdb-api/src/test/resources/ignite-config.xml @@ -30,16 +30,13 @@ nodes. --> - + + - - - 127.0.0.1:47577 + 127.0.0.1:47577..47599 From fbf77a4eeff5d6baa51fafa70246ea43b762f3c7 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Tue, 27 Oct 2020 11:12:01 +0100 Subject: [PATCH 2/3] set random port for each test run --- .../api/tests/TestMapReduceOSHDB_Ignite.java | 33 +++++++++++-- .../src/test/resources/ignite-config.xml | 47 ------------------- 2 files changed, 28 insertions(+), 52 deletions(-) delete mode 100644 oshdb-api/src/test/resources/ignite-config.xml diff --git a/oshdb-api/src/test/java/org/heigit/bigspatialdata/oshdb/api/tests/TestMapReduceOSHDB_Ignite.java b/oshdb-api/src/test/java/org/heigit/bigspatialdata/oshdb/api/tests/TestMapReduceOSHDB_Ignite.java index 808c22bfb..5e7606405 100644 --- a/oshdb-api/src/test/java/org/heigit/bigspatialdata/oshdb/api/tests/TestMapReduceOSHDB_Ignite.java +++ b/oshdb-api/src/test/java/org/heigit/bigspatialdata/oshdb/api/tests/TestMapReduceOSHDB_Ignite.java @@ -1,28 +1,51 @@ package org.heigit.bigspatialdata.oshdb.api.tests; -import java.io.File; +import static org.junit.Assert.fail; + import java.io.IOException; import java.io.ObjectInputStream; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.List; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.Ignition; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cluster.ClusterState; +import org.apache.ignite.configuration.BinaryConfiguration; import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.logger.slf4j.Slf4jLogger; +import org.apache.ignite.marshaller.jdk.JdkMarshaller; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.heigit.bigspatialdata.oshdb.api.db.OSHDBH2; import org.heigit.bigspatialdata.oshdb.api.db.OSHDBIgnite; import org.heigit.bigspatialdata.oshdb.grid.GridOSHNodes; import org.heigit.bigspatialdata.oshdb.util.CellId; import org.heigit.bigspatialdata.oshdb.util.TableNames; -import static org.junit.Assert.fail; abstract class TestMapReduceOSHDB_Ignite extends TestMapReduce { - final static Ignite ignite = - Ignition.start(new File("./src/test/resources/ignite-config.xml").toString()); + final static Ignite ignite; + static { + int rndPort = 47577 + (int) (Math.random() * 1000); + IgniteConfiguration cfg = new IgniteConfiguration(); + cfg.setPeerClassLoadingEnabled(true); + cfg.setIgniteInstanceName("OSHDB-Unit-Tests_" + rndPort); + cfg.setBinaryConfiguration((new BinaryConfiguration()).setCompactFooter(false)); + cfg.setMarshaller(new JdkMarshaller()); + cfg.setGridLogger(new Slf4jLogger()); + cfg.setWorkDirectory("/tmp"); + cfg.setDiscoverySpi((new TcpDiscoverySpi()) + .setLocalPort(rndPort) + .setLocalPortRange(0) + .setIpFinder((new TcpDiscoveryVmIpFinder()).setAddresses(List.of("127.0.0.1:" + rndPort))) + ); + ignite = Ignition.start(cfg); + } public TestMapReduceOSHDB_Ignite(OSHDBIgnite oshdb) throws Exception { super(oshdb); @@ -34,7 +57,7 @@ public TestMapReduceOSHDB_Ignite(OSHDBIgnite oshdb) throws Exception { this.keytables = oshdb_h2; Ignite ignite = ((OSHDBIgnite) this.oshdb).getIgnite(); - ignite.cluster().active(true); + ignite.cluster().state(ClusterState.ACTIVE); CacheConfiguration cacheCfg = new CacheConfiguration<>(TableNames.T_NODES.toString(prefix)); diff --git a/oshdb-api/src/test/resources/ignite-config.xml b/oshdb-api/src/test/resources/ignite-config.xml deleted file mode 100644 index a30f11e0f..000000000 --- a/oshdb-api/src/test/resources/ignite-config.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 127.0.0.1:47577..47599 - - - - - - - - \ No newline at end of file From f9faf08701bb2214d5282d645c9f618213e4b1b4 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Tue, 27 Oct 2020 11:29:14 +0100 Subject: [PATCH 3/3] rewrite/drop deprecated ignite statements --- .../org/heigit/bigspatialdata/oshdb/api/db/OSHDBIgnite.java | 6 +++--- .../oshdb/api/tests/TestMapReduceOSHDB_Ignite.java | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/oshdb-api/src/main/java/org/heigit/bigspatialdata/oshdb/api/db/OSHDBIgnite.java b/oshdb-api/src/main/java/org/heigit/bigspatialdata/oshdb/api/db/OSHDBIgnite.java index ef7cdb3c9..7b2475fd3 100644 --- a/oshdb-api/src/main/java/org/heigit/bigspatialdata/oshdb/api/db/OSHDBIgnite.java +++ b/oshdb-api/src/main/java/org/heigit/bigspatialdata/oshdb/api/db/OSHDBIgnite.java @@ -8,6 +8,7 @@ import java.util.stream.Stream; import org.apache.ignite.Ignite; import org.apache.ignite.Ignition; +import org.apache.ignite.cluster.ClusterState; import org.apache.ignite.lang.IgniteRunnable; import org.heigit.bigspatialdata.oshdb.api.mapreducer.MapReducer; import org.heigit.bigspatialdata.oshdb.api.mapreducer.backend.MapReducerIgniteAffinityCall; @@ -39,7 +40,7 @@ public OSHDBIgnite() { public OSHDBIgnite(Ignite ignite) { this.ignite = ignite; - this.ignite.cluster().active(true); + this.ignite.cluster().state(ClusterState.ACTIVE_READ_ONLY); } public OSHDBIgnite(String igniteConfigFilePath) { @@ -53,9 +54,8 @@ public OSHDBIgnite(String igniteConfigFilePath) { */ public OSHDBIgnite(File igniteConfig) { Ignition.setClientMode(true); - this.ignite = Ignition.start(igniteConfig.toString()); - this.ignite.cluster().active(true); + this.ignite.cluster().state(ClusterState.ACTIVE_READ_ONLY); } @Override diff --git a/oshdb-api/src/test/java/org/heigit/bigspatialdata/oshdb/api/tests/TestMapReduceOSHDB_Ignite.java b/oshdb-api/src/test/java/org/heigit/bigspatialdata/oshdb/api/tests/TestMapReduceOSHDB_Ignite.java index 5e7606405..1ffa8a2cc 100644 --- a/oshdb-api/src/test/java/org/heigit/bigspatialdata/oshdb/api/tests/TestMapReduceOSHDB_Ignite.java +++ b/oshdb-api/src/test/java/org/heigit/bigspatialdata/oshdb/api/tests/TestMapReduceOSHDB_Ignite.java @@ -36,7 +36,6 @@ abstract class TestMapReduceOSHDB_Ignite extends TestMapReduce { cfg.setPeerClassLoadingEnabled(true); cfg.setIgniteInstanceName("OSHDB-Unit-Tests_" + rndPort); cfg.setBinaryConfiguration((new BinaryConfiguration()).setCompactFooter(false)); - cfg.setMarshaller(new JdkMarshaller()); cfg.setGridLogger(new Slf4jLogger()); cfg.setWorkDirectory("/tmp"); cfg.setDiscoverySpi((new TcpDiscoverySpi())