mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #21111 from filimonov/better-kafka-tests
Better kafka tests
This commit is contained in:
commit
5ecd9a9577
@ -13,6 +13,7 @@ import subprocess
|
||||
import time
|
||||
import traceback
|
||||
import urllib.parse
|
||||
import shlex
|
||||
|
||||
import cassandra.cluster
|
||||
import docker
|
||||
@ -573,7 +574,7 @@ class ClickHouseCluster:
|
||||
raise Exception("Can't wait Minio to start")
|
||||
|
||||
def wait_schema_registry_to_start(self, timeout=10):
|
||||
sr_client = CachedSchemaRegistryClient('http://localhost:8081')
|
||||
sr_client = CachedSchemaRegistryClient({"url":'http://localhost:8081'})
|
||||
start = time.time()
|
||||
while time.time() - start < timeout:
|
||||
try:
|
||||
@ -868,6 +869,8 @@ services:
|
||||
cap_add:
|
||||
- SYS_PTRACE
|
||||
- NET_ADMIN
|
||||
- IPC_LOCK
|
||||
- SYS_NICE
|
||||
depends_on: {depends_on}
|
||||
user: '{user}'
|
||||
env_file:
|
||||
@ -1079,6 +1082,23 @@ class ClickHouseInstance:
|
||||
["bash", "-c", 'grep "{}" /var/log/clickhouse-server/clickhouse-server.log || true'.format(substring)])
|
||||
return len(result) > 0
|
||||
|
||||
def wait_for_log_line(self, regexp, filename='/var/log/clickhouse-server/clickhouse-server.log', timeout=30, repetitions=1, look_behind_lines=100):
|
||||
start_time = time.time()
|
||||
result = self.exec_in_container(
|
||||
["bash", "-c", 'timeout {} tail -Fn{} "{}" | grep -Em {} {}'.format(timeout, look_behind_lines, filename, repetitions, shlex.quote(regexp))])
|
||||
|
||||
# if repetitions>1 grep will return success even if not enough lines were collected,
|
||||
if repetitions>1 and len(result.splitlines()) < repetitions:
|
||||
print("wait_for_log_line: those lines were found during {} seconds:".format(timeout))
|
||||
print(result)
|
||||
raise Exception("wait_for_log_line: Not enough repetitions: {} found, while {} expected".format(len(result.splitlines()), repetitions))
|
||||
|
||||
wait_duration = time.time() - start_time
|
||||
|
||||
print('{} log line matching "{}" appeared in a {} seconds'.format(repetitions, regexp, wait_duration))
|
||||
return wait_duration
|
||||
|
||||
|
||||
def file_exists(self, path):
|
||||
return self.exec_in_container(
|
||||
["bash", "-c", "echo $(if [ -e '{}' ]; then echo 'yes'; else echo 'no'; fi)".format(path)]) == 'yes\n'
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user