ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-4741: Improved JdbcStreamingSelfTest reliability. This closes #1568.
Date Wed, 22 Feb 2017 12:30:52 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1.9 658b4ad5a -> 19d6c31a2


IGNITE-4741: Improved JdbcStreamingSelfTest reliability. This closes #1568.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/19d6c31a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/19d6c31a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/19d6c31a

Branch: refs/heads/ignite-1.9
Commit: 19d6c31a24a1dc86aeec203a758d1d0d7387d1ed
Parents: 658b4ad
Author: Alexander Paschenko <alexander.a.paschenko@gmail.com>
Authored: Wed Feb 22 15:30:43 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Wed Feb 22 15:30:43 2017 +0300

----------------------------------------------------------------------
 modules/clients/src/test/config/jdbc-config.xml |  2 +-
 .../internal/jdbc2/JdbcStreamingSelfTest.java   | 58 ++++++++++----------
 2 files changed, 29 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/19d6c31a/modules/clients/src/test/config/jdbc-config.xml
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/config/jdbc-config.xml b/modules/clients/src/test/config/jdbc-config.xml
index 5e6e12c..27d2617 100644
--- a/modules/clients/src/test/config/jdbc-config.xml
+++ b/modules/clients/src/test/config/jdbc-config.xml
@@ -43,7 +43,7 @@
                     <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                         <property name="addresses">
                             <list>
-                                <value>127.0.0.1:47500..47549</value>
+                                <value>127.0.0.1:47500..47501</value>
                             </list>
                         </property>
                     </bean>

http://git-wip-us.apache.org/repos/asf/ignite/blob/19d6c31a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
index 5e206ee..6837a41 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.jdbc2;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
+import java.util.Collections;
 import java.util.Properties;
 import org.apache.ignite.IgniteJdbcDriver;
 import org.apache.ignite.IgniteLogger;
@@ -28,7 +29,6 @@ import org.apache.ignite.configuration.ConnectorConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
@@ -40,9 +40,6 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
  * Data streaming test.
  */
 public class JdbcStreamingSelfTest extends GridCommonAbstractTest {
-    /** IP finder. */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
     /** JDBC URL. */
     private static final String BASE_URL = CFG_URL_PREFIX + "modules/clients/src/test/config/jdbc-config.xml";
 
@@ -75,10 +72,14 @@ public class JdbcStreamingSelfTest extends GridCommonAbstractTest {
         );
 
         cfg.setCacheConfiguration(cache);
+        cfg.setLocalHost("127.0.0.1");
 
         TcpDiscoverySpi disco = new TcpDiscoverySpi();
 
-        disco.setIpFinder(IP_FINDER);
+        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+        ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500..47501"));
+
+        disco.setIpFinder(ipFinder);
 
         cfg.setDiscoverySpi(disco);
 
@@ -89,7 +90,7 @@ public class JdbcStreamingSelfTest extends GridCommonAbstractTest {
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
-        startGridsMultiThreaded(3);
+        startGrids(2);
 
         Class.forName("org.apache.ignite.IgniteJdbcDriver");
     }
@@ -131,29 +132,29 @@ public class JdbcStreamingSelfTest extends GridCommonAbstractTest {
     public void testStreamedInsert() throws Exception {
         conn = createConnection(false);
 
-        ignite(0).cache(null).put(5, 500);
+        for (int i = 10; i <= 100; i += 10)
+            ignite(0).cache(null).put(i, i * 100);
 
         PreparedStatement stmt = conn.prepareStatement("insert into Integer(_key, _val) values
(?, ?)");
 
-        for (int i = 1; i <= 100000; i++) {
+        for (int i = 1; i <= 100; i++) {
             stmt.setInt(1, i);
             stmt.setInt(2, i);
 
             stmt.executeUpdate();
         }
 
-        // Data is not there yet.
-        assertNull(grid(0).cache(null).get(100000));
-
-        // Let the stream flush.
-        U.sleep(1500);
+        // Closing connection makes it wait for streamer close
+        // and thus for data load completion as well
+        conn.close();
 
         // Now let's check it's all there.
-        assertEquals(1, grid(0).cache(null).get(1));
-        assertEquals(100000, grid(0).cache(null).get(100000));
-
-        // 5 should still point to 500.
-        assertEquals(500, grid(0).cache(null).get(5));
+        for (int i = 1; i <= 100; i++) {
+            if (i % 10 != 0)
+                assertEquals(i, grid(0).cache(null).get(i));
+            else // All that divides by 10 evenly should point to numbers 100 times greater
- see above
+                assertEquals(i * 100, grid(0).cache(null).get(i));
+        }
     }
 
     /**
@@ -162,28 +163,25 @@ public class JdbcStreamingSelfTest extends GridCommonAbstractTest {
     public void testStreamedInsertWithOverwritesAllowed() throws Exception {
         conn = createConnection(true);
 
-        ignite(0).cache(null).put(5, 500);
+        for (int i = 10; i <= 100; i += 10)
+            ignite(0).cache(null).put(i, i * 100);
 
         PreparedStatement stmt = conn.prepareStatement("insert into Integer(_key, _val) values
(?, ?)");
 
-        for (int i = 1; i <= 100000; i++) {
+        for (int i = 1; i <= 100; i++) {
             stmt.setInt(1, i);
             stmt.setInt(2, i);
 
             stmt.executeUpdate();
         }
 
-        // Data is not there yet.
-        assertNull(grid(0).cache(null).get(100000));
-
-        // Let the stream flush.
-        U.sleep(1500);
+        // Closing connection makes it wait for streamer close
+        // and thus for data load completion as well
+        conn.close();
 
         // Now let's check it's all there.
-        assertEquals(1, grid(0).cache(null).get(1));
-        assertEquals(100000, grid(0).cache(null).get(100000));
-
-        // 5 should now point to 5 as we've turned overwriting on.
-        assertEquals(5, grid(0).cache(null).get(5));
+        // i should point to i at all times as we've turned overwrites on above.
+        for (int i = 1; i <= 100; i++)
+            assertEquals(i, grid(0).cache(null).get(i));
     }
 }


Mime
View raw message