You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ni...@apache.org on 2023/07/20 08:04:44 UTC

[ignite] branch master updated: IGNITE-19746 Print result of the control.sh performance statistics subcommands (#10847)

This is an automated email from the ASF dual-hosted git repository.

nizhikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 026ffb91ccc IGNITE-19746 Print result of the control.sh performance statistics subcommands (#10847)
026ffb91ccc is described below

commit 026ffb91cccf1edbad6f95b645b33dcbf7fd3604
Author: Sergey Korotkov <se...@gmail.com>
AuthorDate: Thu Jul 20 15:04:36 2023 +0700

    IGNITE-19746 Print result of the control.sh performance statistics subcommands (#10847)
---
 .../PerformanceStatisticsRotateCommand.java        |  6 ++
 .../PerformanceStatisticsStartCommand.java         |  6 ++
 .../PerformanceStatisticsStopCommand.java          |  6 ++
 .../tests/ignitetest/services/utils/path.py        |  7 ++
 .../tests/control_utility/perf_stat_test.py        | 92 ++++++++++++++++++++++
 5 files changed, 117 insertions(+)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsRotateCommand.java b/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsRotateCommand.java
index 1e4563fa296..e414c21e82b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsRotateCommand.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsRotateCommand.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.management.performancestatistics;
 
+import java.util.function.Consumer;
 import org.apache.ignite.internal.dto.IgniteDataTransferObject;
 import org.apache.ignite.internal.management.api.ComputeCommand;
 import org.apache.ignite.internal.management.performancestatistics.PerformanceStatisticsCommand.PerformanceStatisticsRotateCommandArg;
@@ -37,4 +38,9 @@ public class PerformanceStatisticsRotateCommand implements ComputeCommand<Ignite
     @Override public Class<PerformanceStatisticsTask> taskClass() {
         return PerformanceStatisticsTask.class;
     }
+
+    /** {@inheritDoc} */
+    @Override public void printResult(IgniteDataTransferObject arg, String res, Consumer<String> printer) {
+        printer.accept(res);
+    }
 }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsStartCommand.java b/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsStartCommand.java
index 75aefb356f5..58e839fca6e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsStartCommand.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsStartCommand.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.management.performancestatistics;
 
+import java.util.function.Consumer;
 import org.apache.ignite.internal.dto.IgniteDataTransferObject;
 import org.apache.ignite.internal.management.api.ComputeCommand;
 import org.apache.ignite.internal.management.performancestatistics.PerformanceStatisticsCommand.PerformanceStatisticsStartCommandArg;
@@ -37,4 +38,9 @@ public class PerformanceStatisticsStartCommand implements ComputeCommand<IgniteD
     @Override public Class<PerformanceStatisticsTask> taskClass() {
         return PerformanceStatisticsTask.class;
     }
+
+    /** {@inheritDoc} */
+    @Override public void printResult(IgniteDataTransferObject arg, String res, Consumer<String> printer) {
+        printer.accept(res);
+    }
 }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsStopCommand.java b/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsStopCommand.java
index a65c1825014..3a5724ff4c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsStopCommand.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/management/performancestatistics/PerformanceStatisticsStopCommand.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.management.performancestatistics;
 
+import java.util.function.Consumer;
 import org.apache.ignite.internal.dto.IgniteDataTransferObject;
 import org.apache.ignite.internal.management.api.ComputeCommand;
 import org.apache.ignite.internal.management.performancestatistics.PerformanceStatisticsCommand.PerformanceStatisticsStopCommandArg;
@@ -37,4 +38,9 @@ public class PerformanceStatisticsStopCommand implements ComputeCommand<IgniteDa
     @Override public Class<PerformanceStatisticsTask> taskClass() {
         return PerformanceStatisticsTask.class;
     }
+
+    /** {@inheritDoc} */
+    @Override public void printResult(IgniteDataTransferObject arg, String res, Consumer<String> printer) {
+        printer.accept(res);
+    }
 }
diff --git a/modules/ducktests/tests/ignitetest/services/utils/path.py b/modules/ducktests/tests/ignitetest/services/utils/path.py
index ff6674727b7..a1676d5887a 100644
--- a/modules/ducktests/tests/ignitetest/services/utils/path.py
+++ b/modules/ducktests/tests/ignitetest/services/utils/path.py
@@ -203,6 +203,13 @@ class IgnitePathAware(PathAware, metaclass=ABCMeta):
         """
         return os.path.join(self.work_dir, "db")
 
+    @property
+    def perf_stat_dir(self):
+        """
+        :return: path to performance statistics directory
+        """
+        return os.path.join(self.work_dir, "perf_stat")
+
     @property
     def wal_dir(self):
         """
diff --git a/modules/ducktests/tests/ignitetest/tests/control_utility/perf_stat_test.py b/modules/ducktests/tests/ignitetest/tests/control_utility/perf_stat_test.py
new file mode 100644
index 00000000000..94eb56de10c
--- /dev/null
+++ b/modules/ducktests/tests/ignitetest/tests/control_utility/perf_stat_test.py
@@ -0,0 +1,92 @@
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+This module contains performance statistics manipulation test through control utility.
+"""
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.services.utils.control_utility import ControlUtility
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
+from ignitetest.utils import cluster, ignite_versions
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import DEV_BRANCH, IgniteVersion
+
+
+class PerfStatTest(IgniteTest):
+    @cluster(num_nodes=2)
+    @ignite_versions(str(DEV_BRANCH))
+    def test_perf_stat(self, ignite_version):
+        """
+        Test that performance statistics collecting can be started and stopped, current status can be requested
+        and performance log files can be rotated both on server and client nodes.
+        """
+        server = IgniteService(
+            self.test_context,
+            IgniteConfiguration(version=IgniteVersion(ignite_version)),
+            num_nodes=1
+        )
+
+        client = IgniteApplicationService(
+            self.test_context,
+            server.config._replace(client_mode=True),
+            java_class_name="org.apache.ignite.internal.ducktest.tests.ContinuousDataLoadApplication",
+            params={
+                "cacheName": "test-cache",
+                "range": 200_000,
+                "warmUpRange":  100_000,
+                "transactional": False
+            }
+        )
+
+        server.start()
+
+        control_sh = ControlUtility(server)
+
+        assert not control_sh.is_performance_statistics_enabled()
+
+        control_sh.start_performance_statistics()
+
+        assert control_sh.is_performance_statistics_enabled()
+
+        client.start()
+
+        control_sh.rotate_performance_statistics()
+
+        client.stop()
+
+        assert control_sh.is_performance_statistics_enabled()
+
+        control_sh.stop_performance_statistics()
+
+        assert not control_sh.is_performance_statistics_enabled()
+
+        server.stop()
+
+        self.check_prf_files_are_created_on(server)
+
+        self.check_prf_files_are_created_on(client)
+
+    def check_prf_files_are_created_on(self, service):
+        for n in service.nodes:
+            files = n.account.sftp_client.listdir(service.perf_stat_dir)
+
+            self.logger.debug(files)
+
+            assert len(files) == 2
+
+            assert all([filename.endswith(".prf") for filename in files])