oleg-vlsk commented on code in PR #12544:
URL: https://github.com/apache/ignite/pull/12544#discussion_r2579122995


##########
modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlQueryHistorySelfTest.java:
##########
@@ -253,6 +254,39 @@ public void testSqlFieldsQueryHistoryWithInitiatorId() {
         assertEquals(testId1, history.initiatorId());
     }
 
+    /**
+     * Test total duration of SQL queries.
+     */
+    @Test
+    public void testSqlFieldsQueryTotalDuration() {
+        SqlFieldsQuery qry = new SqlFieldsQuery("select * from A.String where 
_key=sleep_func(?, ?)").setArgs(500, 1);
+
+        IgniteCache<Integer, String> cache = 
queryNode().context().cache().jcache("A");
+
+        long[] totalTimeArr = new long[2];
+
+        for (int i = 0; i < totalTimeArr.length; i++) {
+            cache.query(qry).getAll();
+
+            Collection<QueryHistory> historyCol = 
queryNode().context().query().runningQueryManager()
+                .queryHistoryMetrics().values();
+
+            assertFalse(F.isEmpty(historyCol));
+            assertEquals(1, historyCol.size());
+
+            QueryHistory history = first(historyCol);
+
+            assertNotNull(history);
+
+            totalTimeArr[i] = history.totalTime();
+        }
+
+        long expTotalTime = totalTimeArr[0] * totalTimeArr.length;
+        long actTotalTime = totalTimeArr[1];
+
+        assertEquals(expTotalTime, actTotalTime, expTotalTime * 0.2);

Review Comment:
   Changed to the sleep time check.



##########
modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlQueryHistorySelfTest.java:
##########
@@ -669,6 +703,21 @@ public static class Functions {
         public static int fail() {
             throw new IgniteSQLException("SQL function fail for test 
purpuses");
         }
+
+        /**
+         *
+         */
+        @QuerySqlFunction
+        public static int sleep_func(int sleep, int val) {

Review Comment:
   Done.



-- 
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