Replace print() with logging.debug() in integration tests

This commit is contained in:
Vitaly Baranov 2021-07-06 13:48:13 +03:00
parent 87f59ba670
commit b0a3a7180f

View File

@ -1,3 +1,4 @@
import logging
import random
import threading
import time
@ -90,7 +91,7 @@ class Runner:
i += 1
try:
print('thread {}: insert for {}: {}'.format(thread_num, date_str, ','.join(str(x) for x in xs)))
logging.debug(f"thread {thread_num}: insert for {date_str}: {xs}")
random.choice(self.nodes).query("INSERT INTO test_mutations FORMAT TSV", payload)
with self.mtx:
@ -100,7 +101,7 @@ class Runner:
self.total_inserted_rows += len(xs)
except Exception as e:
print('Exception while inserting,', e)
logging.debug(f"Exception while inserting: {e}")
self.exceptions.append(e)
finally:
with self.mtx:
@ -128,7 +129,7 @@ class Runner:
continue
try:
print('thread {}: delete {} * {}'.format(thread_num, to_delete_count, x))
logging.debug(f"thread {thread_num}: delete {to_delete_count} * {x}")
random.choice(self.nodes).query("ALTER TABLE test_mutations DELETE WHERE x = {}".format(x))
with self.mtx:
@ -138,7 +139,7 @@ class Runner:
self.total_deleted_rows += to_delete_count
except Exception as e:
print('Exception while deleting,', e)
logging.debug(f"Exception while deleting: {e}")
finally:
with self.mtx:
self.currently_deleting_xs.remove(x)
@ -185,10 +186,9 @@ def test_mutations(started_cluster):
assert runner.total_mutations > 0
all_done = wait_for_mutations(nodes, runner.total_mutations)
print("Total mutations: ", runner.total_mutations)
logging.debug(f"Total mutations: {runner.total_mutations}")
for node in nodes:
print(node.query(
logging.debug(node.query(
"SELECT mutation_id, command, parts_to_do, is_done FROM system.mutations WHERE table = 'test_mutations' FORMAT TSVWithNames"))
assert all_done
@ -233,9 +233,9 @@ def test_mutations_dont_prevent_merges(started_cluster, nodes):
t.join()
for node in nodes:
print(node.query(
logging.debug(node.query(
"SELECT mutation_id, command, parts_to_do, is_done FROM system.mutations WHERE table = 'test_mutations' FORMAT TSVWithNames"))
print(node.query(
logging.debug(node.query(
"SELECT partition, count(name), sum(active), sum(active*rows) FROM system.parts WHERE table ='test_mutations' GROUP BY partition FORMAT TSVWithNames"))
assert all_done