dant3 commented on code in PR #7387:
URL: https://github.com/apache/ignite-3/pull/7387#discussion_r2811838557


##########
modules/page-memory/src/test/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStoreIoTest.java:
##########
@@ -113,6 +124,40 @@ void testCheckHeader() throws Exception {
         }
     }
 
+    @Test
+    void testIoMetricsRecordedDuringActualFileOperations() throws Exception {
+        Path testFilePath = workDir.resolve("test");
+
+        CollectionMetricSource ioMetricSource = new 
CollectionMetricSource("testPageStoreIo", "storage", "Page memory I/O metrics");
+        PageMemoryIoMetrics ioMetrics = new 
PageMemoryIoMetrics(ioMetricSource);
+        MetricSet metricSet = ioMetricSource.enable();
+
+        long pageId = pageId(0, FLAG_DATA, 0);
+
+        try (FilePageStoreIo filePageStoreIo = 
createFilePageStoreIo(testFilePath, ioMetrics)) {
+            // Verify metrics start at zero
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_READ, 
 0L);
+            assertMetricValue(metricSet, 
PageMemoryIoMetrics.TOTAL_BYTES_WRITTEN,  0L);
+
+            // Perform write operation
+            ByteBuffer writeBuffer = createPageByteBuffer(pageId, PAGE_SIZE);
+            filePageStoreIo.write(pageId, writeBuffer);

Review Comment:
   FilePageStoreIo doesn't have readFully/wrtieFully. However it's write/read 
methods utilize writeFully/readFully of the underlying FileIo which we test 
here.



##########
modules/page-memory/src/test/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStoreIoTest.java:
##########
@@ -113,6 +124,40 @@ void testCheckHeader() throws Exception {
         }
     }
 
+    @Test
+    void testIoMetricsRecordedDuringActualFileOperations() throws Exception {
+        Path testFilePath = workDir.resolve("test");
+
+        CollectionMetricSource ioMetricSource = new 
CollectionMetricSource("testPageStoreIo", "storage", "Page memory I/O metrics");
+        PageMemoryIoMetrics ioMetrics = new 
PageMemoryIoMetrics(ioMetricSource);
+        MetricSet metricSet = ioMetricSource.enable();
+
+        long pageId = pageId(0, FLAG_DATA, 0);
+
+        try (FilePageStoreIo filePageStoreIo = 
createFilePageStoreIo(testFilePath, ioMetrics)) {
+            // Verify metrics start at zero
+            assertMetricValue(metricSet, PageMemoryIoMetrics.TOTAL_BYTES_READ, 
 0L);
+            assertMetricValue(metricSet, 
PageMemoryIoMetrics.TOTAL_BYTES_WRITTEN,  0L);
+
+            // Perform write operation
+            ByteBuffer writeBuffer = createPageByteBuffer(pageId, PAGE_SIZE);
+            filePageStoreIo.write(pageId, writeBuffer);
+
+            // Verify write metrics were recorded - 1 write of header + 1 
write of page
+            assertMetricValue(metricSet, 
PageMemoryIoMetrics.TOTAL_BYTES_WRITTEN,  PAGE_SIZE * 2);
+            assertDistributionMetricRecordsCount(metricSet, 
PageMemoryIoMetrics.WRITES_TIME, 2L);
+
+            // Perform read operation
+            long pageOff = filePageStoreIo.pageOffset(pageId);
+            ByteBuffer readBuffer = 
ByteBuffer.allocateDirect(PAGE_SIZE).order(java.nio.ByteOrder.nativeOrder());
+            filePageStoreIo.read(pageId, pageOff, readBuffer, false);

Review Comment:
   FilePageStoreIo doesn't have readFully/wrtieFully. However it's write/read 
methods utilize writeFully/readFully of the underlying FileIo which we test 
here.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to