Merge pull request #32163 from azat/clickhouse-test-random

clickhouse-test: do not use random generator with shared state
This commit is contained in:
alexey-milovidov 2021-12-03 06:53:57 +03:00 committed by GitHub
commit b7fb21e6f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -371,9 +371,10 @@ class TestCase:
else:
# If --database is not specified, we will create temporary database with unique name
# And we will recreate and drop it for each test
def random_str(length=8):
def random_str(length=6):
alphabet = string.ascii_lowercase + string.digits
return ''.join(random.choice(alphabet) for _ in range(length))
# NOTE: it is important not to use default random generator, since it shares state.
return ''.join(random.SystemRandom().choice(alphabet) for _ in range(length))
database = 'test_{suffix}'.format(suffix=random_str())