You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "NSAmelchev (via GitHub)" <gi...@apache.org> on 2026/06/19 14:52:26 UTC

Re: [PR] IGNITE-28668 Keep snapshot creation metrics on each node [ignite]

NSAmelchev commented on code in PR #13119:
URL: https://github.com/apache/ignite/pull/13119#discussion_r3443206374


##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotSelfTest.java:
##########
@@ -849,81 +849,70 @@ public void testClusterSnapshotWithExplicitPathError() throws Exception {
     /** @throws Exception If fails. */
     @Test
     public void testClusterSnapshotMetrics() throws Exception {
-        String newSnapshotName = SNAPSHOT_NAME + "_new";
         CountDownLatch deltaApply = new CountDownLatch(1);
         CountDownLatch deltaBlock = new CountDownLatch(1);
         IgniteEx ignite = startGridsWithCache(2, dfltCacheCfg, CACHE_KEYS_RANGE);
 
-        MetricRegistry mreg0 = ignite.context().metric().registry(SNAPSHOT_METRICS);
-
-        LongMetric startTime = mreg0.findMetric("LastSnapshotStartTime");
-        LongMetric endTime = mreg0.findMetric("LastSnapshotEndTime");
-        ObjectGauge<String> snpName = mreg0.findMetric("LastSnapshotName");
-        ObjectGauge<String> errMsg = mreg0.findMetric("LastSnapshotErrorMessage");
-        ObjectGauge<List<String>> snpList = mreg0.findMetric("LocalSnapshotNames");
-
         // Snapshot process will be blocked when delta partition files processing starts.
         snp(ignite).localSnapshotSenderFactory(
             blockingLocalSnapshotSender(ignite, deltaApply, deltaBlock));
 
-        assertEquals("Snapshot start time must be undefined prior to snapshot operation started.",
-            0, startTime.value());
-        assertEquals("Snapshot end time must be undefined to snapshot operation started.",
-            0, endTime.value());
-        assertTrue("Snapshot name must not exist prior to snapshot operation started.", snpName.value().isEmpty());
-        assertTrue("Snapshot error message must null prior to snapshot operation started.", errMsg.value().isEmpty());
-        assertTrue("Snapshots on local node must not exist", snpList.value().isEmpty());
+        for (Ignite g : G.allGrids()) {
+            MetricRegistry mreg = ((IgniteEx)g).context().metric().registry(SNAPSHOT_METRICS);
+
+            LongMetric startTime = mreg.findMetric("LastSnapshotStartTime");
+            LongMetric endTime = mreg.findMetric("LastSnapshotEndTime");
+            ObjectGauge<String> snpName = mreg.findMetric("LastSnapshotName");
+            ObjectGauge<String> errMsg = mreg.findMetric("LastSnapshotErrorMessage");
+            ObjectGauge<List<String>> snpList = mreg.findMetric("LocalSnapshotNames");
+
+            assertEquals("Snapshot start time must be undefined prior to snapshot operation started.",
+                0, startTime.value());
+            assertEquals("Snapshot end time must be undefined to snapshot operation started.",
+                0, endTime.value());
+            assertTrue("Snapshot name must not exist prior to snapshot operation started.", snpName.value().isEmpty());
+            assertTrue("Snapshot error message must null prior to snapshot operation started.", errMsg.value().isEmpty());
+            assertTrue("Snapshots on local node must not exist", snpList.value().isEmpty());
+        }
 
         long cutoffStartTime = U.currentTimeMillis();
 
-        IgniteFuture<Void> fut0 = snp(ignite).createSnapshot(SNAPSHOT_NAME, null, false, onlyPrimary);
+        IgniteFuture<Void> fut = snp(ignite).createSnapshot(SNAPSHOT_NAME, null, false, onlyPrimary);
 
         U.await(deltaApply);
 
-        assertTrue("Snapshot start time must be set prior to snapshot operation started " +
-            "[startTime=" + startTime.value() + ", cutoffTime=" + cutoffStartTime + ']',
-            startTime.value() >= cutoffStartTime);
-        assertEquals("Snapshot end time must be zero prior to snapshot operation started.",
-            0, endTime.value());
-        assertEquals("Snapshot name must be set prior to snapshot operation started.",
-            SNAPSHOT_NAME, snpName.value());
-        assertTrue("Snapshot error message must null prior to snapshot operation started.",
-            errMsg.value().isEmpty());
-
-        IgniteFuture<Void> fut1 = snp(grid(1)).createSnapshot(newSnapshotName, null, false, onlyPrimary);
-
-        assertThrowsWithCause((Callable<Object>)fut1::get, IgniteException.class);
+        for (Ignite g : G.allGrids()) {
+            MetricRegistry mreg = ((IgniteEx)g).context().metric().registry(SNAPSHOT_METRICS);
+
+            LongMetric startTime = mreg.findMetric("LastSnapshotStartTime");
+            LongMetric endTime = mreg.findMetric("LastSnapshotEndTime");
+            ObjectGauge<String> snpName = mreg.findMetric("LastSnapshotName");
+            ObjectGauge<String> errMsg = mreg.findMetric("LastSnapshotErrorMessage");
+
+            assertTrue("Snapshot start time must be set prior to snapshot operation started " +
+                    "[startTime=" + startTime.value() + ", cutoffTime=" + cutoffStartTime + ']',
+                startTime.value() >= cutoffStartTime);
+            assertEquals("Snapshot end time must be zero prior to snapshot operation started.",
+                0, endTime.value());
+            assertEquals("Snapshot name must be set prior to snapshot operation started.",
+                SNAPSHOT_NAME, snpName.value());
+            assertTrue("Snapshot error message must null prior to snapshot operation started.",
+                errMsg.value().isEmpty());
+        }
 
-        MetricRegistry mreg1 = grid(1).context().metric().registry(SNAPSHOT_METRICS);
+        deltaBlock.countDown();
 
-        LongMetric startTime1 = mreg1.findMetric("LastSnapshotStartTime");
-        LongMetric endTime1 = mreg1.findMetric("LastSnapshotEndTime");
-        ObjectGauge<String> snpName1 = mreg1.findMetric("LastSnapshotName");
-        ObjectGauge<String> errMsg1 = mreg1.findMetric("LastSnapshotErrorMessage");
+        fut.get();
 
-        assertTrue("Snapshot start time must be greater than zero for finished snapshot.",
-            startTime1.value() > 0);
-        assertEquals("Snapshot end time must zero for failed on start snapshots.",
-            0, endTime1.value());
-        assertEquals("Snapshot name must be set when snapshot operation already finished.",
-            newSnapshotName, snpName1.value());
-        assertNotNull("Concurrent snapshot operation must failed.",
-            errMsg1.value());
+        for (Ignite g : G.allGrids()) {
+            MetricRegistry mreg = ((IgniteEx)g).context().metric().registry(SNAPSHOT_METRICS);
 
-        deltaBlock.countDown();
+            LongMetric startTime = mreg.findMetric("LastSnapshotStartTime");
+            LongMetric endTime = mreg.findMetric("LastSnapshotEndTime");
 
-        fut0.get();
-
-        assertTrue("Snapshot start time must be greater than zero for finished snapshot.",
-            startTime.value() > 0);
-        assertTrue("Snapshot end time must be greater than zero for finished snapshot.",
-            endTime.value() > 0);
-        assertEquals("Snapshot name must be set when snapshot operation already finished.",
-            SNAPSHOT_NAME, snpName.value());
-        assertTrue("Concurrent snapshot operation must finished successfully.",
-            errMsg.value().isEmpty());
-        assertEquals("Only the first snapshot must be created and stored on disk.",
-            Collections.singletonList(SNAPSHOT_NAME), snpList.value());
+            waitForCondition(() -> endTime.value() != 0L && startTime.value() != 0 && endTime.value() > startTime.value(),

Review Comment:
   Ignored result of `waitForCondition`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org