mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #28184 from ClickHouse/trying_to_fix_fetches_test
Better detection of the default interface in replicated fetches tests
This commit is contained in:
commit
68f6ecec62
@ -240,15 +240,27 @@ class _NetworkManager:
|
||||
|
||||
# Approximately mesure network I/O speed for interface
|
||||
class NetThroughput(object):
|
||||
def __init__(self, node, interface="eth0"):
|
||||
self.interface = interface
|
||||
def __init__(self, node):
|
||||
self.node = node
|
||||
# trying to get default interface and check it in /proc/net/dev
|
||||
self.interface = self.node.exec_in_container(["bash", "-c", "awk '{print $1 \" \" $2}' /proc/net/route | grep 00000000 | awk '{print $1}'"]).strip()
|
||||
check = self.node.exec_in_container(["bash", "-c", f'grep "^ *{self.interface}:" /proc/net/dev']).strip()
|
||||
if not check: # if check is not successful just try eth{1-10}
|
||||
for i in range(10):
|
||||
try:
|
||||
self.interface = self.node.exec_in_container(["bash", "-c", f"awk '{{print $1}}' /proc/net/route | grep 'eth{i}'"]).strip()
|
||||
break
|
||||
except Exception as ex:
|
||||
print(f"No interface eth{i}")
|
||||
else:
|
||||
raise Exception("No interface eth{1-10} and default interface not specified in /proc/net/route, maybe some special network configuration")
|
||||
|
||||
try:
|
||||
check = subprocess.check_output(f'grep "^ *{self.interface}:" /proc/net/dev', shell=True)
|
||||
check = self.node.exec_in_container(["bash", "-c", f'grep "^ *{self.interface}:" /proc/net/dev']).strip()
|
||||
if not check:
|
||||
raise Exception(f"No such interface {self.interface} found in /proc/net/dev")
|
||||
except:
|
||||
logging.error("All available interfaces %s", subprocess.check_output("cat /proc/net/dev", shell=True))
|
||||
logging.error("All available interfaces %s", self.node.exec_in_container(["bash", "-c", "cat /proc/net/dev"]))
|
||||
raise Exception(f"No such interface {self.interface} found in /proc/net/dev")
|
||||
|
||||
self.current_in = self._get_in_bytes()
|
||||
|
Loading…
Reference in New Issue
Block a user