diff --git a/ydb/tests/stability/ydb/test_stability.py b/ydb/tests/stability/ydb/test_stability.py index 643e2ba9c833..ed45bb93e9ac 100644 --- a/ydb/tests/stability/ydb/test_stability.py +++ b/ydb/tests/stability/ydb/test_stability.py @@ -141,16 +141,19 @@ def test_olap_workload(self): def test_statistics_workload(self): self._start_nemesis() - duration = 90*60 + + log_file = "/Berkanavt/nemesis/log/statistics_workload.log" + test_path = "/Berkanavt/nemesis/bin/statistics_workload" for node_id, node in enumerate(self.kikimr_cluster.nodes.values()): node.ssh_command( - f'screen -d -m bash -c "sudo /Berkanavt/nemesis/bin/statistics_workload --database /Root/db1 --duration {duration} --log_file /Berkanavt/nemesis/log/statistics_workload.log"', + f'screen -d -m bash -c "while true; do sudo {test_path} --database /Root/db1 --log_file {log_file} ; done"', raise_on_error=True ) + sleep_time_min = 90 - logger.info('Sleeping for {} minute(s)'.format(duration)) - time.sleep(duration) + logger.info('Sleeping for {} minute(s)'.format(sleep_time_min)) + time.sleep(sleep_time_min*60) self._stop_nemesis() diff --git a/ydb/tools/statistics_workload/__main__.py b/ydb/tools/statistics_workload/__main__.py index 9dee5dde51d2..399120167094 100644 --- a/ydb/tools/statistics_workload/__main__.py +++ b/ydb/tools/statistics_workload/__main__.py @@ -3,6 +3,7 @@ import ydb import logging import time +import os import random import string @@ -13,6 +14,14 @@ logger = logging.getLogger("StatisticsWorkload") +def timestamp(): + return int(1000 * time.time()) + + +def table_name_with_timestamp(table_prefix): + return os.path.join(table_prefix + "_" + str(timestamp())) + + def random_string(length): letters = string.ascii_lowercase return bytes(''.join(random.choice(letters) for i in range(length)), encoding='utf8') @@ -140,7 +149,8 @@ def callee(session): self.run_query_ignore_errors(callee) def execute(self): - table_name = "test_table" + table_prefix = "test_table" + table_name = table_name_with_timestamp(table_prefix) table_statistics = ".metadata/_statistics" try: @@ -153,7 +163,7 @@ def execute(self): logger.error(f"table '{table_statistics}' is not empty") return - self.drop_all_tables_with_prefix(table_name) + self.drop_all_tables_with_prefix(table_prefix) self.create_table(table_name) self.add_data(table_name) @@ -177,14 +187,10 @@ def execute(self): def run(self): started_at = time.time() - sleep_time = 20 while time.time() - started_at < self.duration: self.execute() - logger.info(f"sleeping for {sleep_time} seconds") - time.sleep(sleep_time) - if __name__ == '__main__': parser = argparse.ArgumentParser( @@ -194,7 +200,7 @@ def run(self): parser.add_argument('--database', default=None, required=True, help='A database to connect') parser.add_argument('--duration', default=120, type=lambda x: int(x), help='A duration of workload in seconds') parser.add_argument('--batch_size', default=1000, help='Batch size for bulk insert') - parser.add_argument('--batch_count', default=10, help='The number of butches to be inserted') + parser.add_argument('--batch_count', default=3, help='The number of butches to be inserted') parser.add_argument('--log_file', default='', help='Append log into specified file') args = parser.parse_args()