ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [30/46] ignite git commit: ClusterNodeMetricsSelfTest::testAllocatedMemory was fixed according to latest changes in memory management - Fixes #1812.
Date Tue, 18 Apr 2017 15:04:29 GMT
ClusterNodeMetricsSelfTest::testAllocatedMemory was fixed according to latest changes in memory
management - Fixes #1812.

Signed-off-by: Alexey Goncharuk <alexey.goncharuk@gmail.com>


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

Branch: refs/heads/ignite-1561-1
Commit: 6e12daa13fe5725ed4995c8e00bb38f597876a96
Parents: feba953
Author: Sergey Chugunov <sergey.chugunov@gmail.com>
Authored: Tue Apr 18 12:52:58 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Tue Apr 18 12:57:03 2017 +0300

----------------------------------------------------------------------
 .../internal/ClusterNodeMetricsSelfTest.java    | 37 ++++++++++++--------
 1 file changed, 22 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6e12daa1/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
index 2cb36f9..dafc41f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
@@ -23,6 +23,8 @@ import java.util.concurrent.CountDownLatch;
 import org.apache.ignite.GridTestTask;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.MemoryMetrics;
 import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy;
 import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -105,31 +107,36 @@ public class ClusterNodeMetricsSelfTest extends GridCommonAbstractTest
{
      * @throws Exception If failed.
      */
     public void testAllocatedMemory() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-4536");
-
-        Ignite ignite = grid();
+        IgniteEx ignite = grid();
 
         final IgniteCache cache = ignite.getOrCreateCache(CACHE_NAME);
 
-        long prevTieredOffHeapSize = cache.metrics().getOffHeapAllocatedSize();
+        MemoryMetrics memMetrics = getDefaultMemoryPolicyMetrics(ignite);
 
-        assertEquals(0, prevTieredOffHeapSize);
+        memMetrics.enableMetrics();
 
-        long prevClusterNonHeapMemoryUsed = ignite.cluster().metrics().getNonHeapMemoryUsed();
+        int pageSize = getPageSize(ignite);
 
-        fillCache(cache);
+        assertEquals(0, memMetrics.getTotalAllocatedPages());
 
-        assertTrue(cache.metrics().getOffHeapAllocatedSize() > (MAX_VALS_AMOUNT - 5)
-            * VAL_SIZE + prevTieredOffHeapSize);
+        fillCache(cache);
 
-        assertTrue(prevClusterNonHeapMemoryUsed < ignite.cluster().metrics().getNonHeapMemoryUsed());
+        assertTrue(memMetrics.getTotalAllocatedPages() * pageSize > MAX_VALS_AMOUNT
+            * VAL_SIZE);
+    }
 
-        prevClusterNonHeapMemoryUsed = ignite.cluster().metrics().getNonHeapMemoryUsed();
-        prevTieredOffHeapSize = cache.metrics().getOffHeapAllocatedSize();
+    /**
+     * @param ignite Ignite instance.
+     */
+    private MemoryMetrics getDefaultMemoryPolicyMetrics(IgniteEx ignite) throws IgniteCheckedException
{
+        return ignite.context().cache().context().database().memoryPolicy(null).memoryMetrics();
+    }
 
-        assertEquals(prevTieredOffHeapSize, cache.metrics().getOffHeapAllocatedSize());
-        assertTrue((MAX_VALS_AMOUNT - 5) * VAL_SIZE + prevClusterNonHeapMemoryUsed <
-            ignite.cluster().metrics().getNonHeapMemoryUsed());
+    /**
+     * @param ignite Ignite instance.
+     */
+    private int getPageSize(IgniteEx ignite) {
+        return ignite.context().cache().context().database().pageSize();
     }
 
     /**


Mime
View raw message