From 026ffb91cccf1edbad6f95b645b33dcbf7fd3604 Mon Sep 17 00:00:00 2001 From: Sergey Korotkov Date: Thu, 20 Jul 2023 15:04:36 +0700 Subject: [PATCH] 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(+) create mode 100644 modules/ducktests/tests/ignitetest/tests/control_utility/perf_stat_test.py 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 1e4563fa296f6..e414c21e82bb4 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 taskClass() { return PerformanceStatisticsTask.class; } + + /** {@inheritDoc} */ + @Override public void printResult(IgniteDataTransferObject arg, String res, Consumer 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 75aefb356f507..58e839fca6eec 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 taskClass() { return PerformanceStatisticsTask.class; } + + /** {@inheritDoc} */ + @Override public void printResult(IgniteDataTransferObject arg, String res, Consumer 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 a65c1825014ca..3a5724ff4c72c 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 taskClass() { return PerformanceStatisticsTask.class; } + + /** {@inheritDoc} */ + @Override public void printResult(IgniteDataTransferObject arg, String res, Consumer 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 ff6674727b7c8..a1676d5887abe 100644 --- a/modules/ducktests/tests/ignitetest/services/utils/path.py +++ b/modules/ducktests/tests/ignitetest/services/utils/path.py @@ -203,6 +203,13 @@ def database_dir(self): """ 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 0000000000000..94eb56de10cbc --- /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])