Skip to content

Commit

Permalink
fix review remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewstalin committed Sep 10, 2024
1 parent 11b8fd7 commit 5b2a610
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
11 changes: 7 additions & 4 deletions ydb/tests/stability/ydb/test_stability.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
20 changes: 13 additions & 7 deletions ydb/tools/statistics_workload/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ydb
import logging
import time
import os
import random
import string

Expand All @@ -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')
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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(
Expand All @@ -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()
Expand Down

0 comments on commit 5b2a610

Please sign in to comment.