Skip to content

Commit 3603395

Browse files
authored
Fix performance test (#131)
1 parent 2e2c9b9 commit 3603395

5 files changed

Lines changed: 39 additions & 7 deletions

File tree

cmake/common.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ function(add_perf_test)
635635

636636
add_test(
637637
NAME ${PARSED_ARGS_NAME}
638-
COMMAND ${PYTHON} ${PARSED_ARGS_PYTHON_SCRIPT}
638+
COMMAND python3 ${PARSED_ARGS_PYTHON_SCRIPT}
639639
-b .
640640
--label ${PARSED_ARGS_NAME}
641641
-c ${PARSED_ARGS_CLIENT_BIN}

tests/infra/rates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from loguru import logger as LOG
99

10-
COMMIT_COUNT_CUTTOF = 20
10+
COMMIT_COUNT_CUTTOF = 10
1111

1212

1313
class TxRates:

tests/infra/remote.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,17 @@ def _cmd(self):
237237
def _dbg(self):
238238
return "cd {} && {} --args ./{}".format(self.root, DBG, " ".join(self.cmd))
239239

240-
def wait_for_stdout_line(self, line, timeout):
240+
def _connect_new(self):
241241
client = paramiko.SSHClient()
242242
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
243243
client.connect(self.hostname)
244+
return client
245+
246+
def wait_for_stdout_line(self, line, timeout):
247+
client = self._connect_new()
244248
try:
245249
for _ in range(timeout):
246-
_, stdout, _ = self.client.exec_command(
247-
"grep -F '{}' {}/out".format(line, self.root)
248-
)
250+
_, stdout, _ = client.exec_command(f"grep -F '{line}' {self.root}/out")
249251
if stdout.channel.recv_exit_status() == 0:
250252
return
251253
time.sleep(1)
@@ -255,6 +257,19 @@ def wait_for_stdout_line(self, line, timeout):
255257
finally:
256258
client.close()
257259

260+
def print_result(self, lines):
261+
client = self._connect_new()
262+
LOG.error("print_result remote")
263+
try:
264+
_, stdout, _ = client.exec_command(f"tail -{lines} {self.root}/out")
265+
if stdout.channel.recv_exit_status() == 0:
266+
LOG.success(f"Result for {self.name}:")
267+
for line in stdout.read().splitlines():
268+
LOG.debug(line.decode())
269+
return
270+
finally:
271+
client.close()
272+
258273

259274
@contextmanager
260275
def ssh_remote(name, hostname, files, cmd):
@@ -286,6 +301,7 @@ def __init__(
286301
self.stdout = None
287302
self.stderr = None
288303
self.env = env
304+
self.name = name
289305

290306
def _rc(self, cmd):
291307
LOG.info("[{}] {}".format(self.hostname, cmd))
@@ -392,6 +408,14 @@ def wait_for_stdout_line(self, line, timeout):
392408
"{} not found in stdout after {} seconds".format(line, timeout)
393409
)
394410

411+
def print_result(self, line):
412+
with open(os.path.join(self.root, "out"), "rb") as out:
413+
lines = out.read().splitlines()
414+
result = lines[-line:]
415+
LOG.success(f"Result for {self.name}:")
416+
for line in result:
417+
LOG.debug(line.decode())
418+
395419

396420
CCF_TO_OE_LOG_LEVEL = {
397421
"trace": "VERBOSE",
@@ -582,6 +606,9 @@ def stop(self):
582606
def wait_for_stdout_line(self, line, timeout=5):
583607
return self.remote.wait_for_stdout_line(line, timeout)
584608

609+
def print_result(self, lines):
610+
self.remote.print_result(lines)
611+
585612
def set_recovery(self):
586613
self.remote.set_recovery()
587614

tests/infra/remote_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
class CCFRemoteClient(object):
1818
BIN = "cchost"
1919
DEPS = []
20+
LINES_RESULT_FROM_END = 6
2021

2122
def __init__(
2223
self,
@@ -60,7 +61,7 @@ def __init__(
6061
] + command_args
6162

6263
self.remote = remote_class(
63-
name, host, [self.BIN] + self.DEPS, [], cmd, workspace, label
64+
name, host, [self.BIN], self.DEPS, cmd, workspace, label
6465
)
6566

6667
def setup(self):
@@ -104,3 +105,6 @@ def wait(self):
104105
except Exception:
105106
LOG.exception("Failed to wait on client {}".format(self.name))
106107
raise
108+
109+
def print_result(self):
110+
self.remote.print_result(self.LINES_RESULT_FROM_END)

tests/infra/runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def run(build_directory, get_command, args):
130130
if not tx_rates.process_next():
131131
for i, remote_client in enumerate(clients):
132132
remote_client.wait()
133+
remote_client.print_result()
133134
# TODO: For now, only retrieve perf csv for the first client
134135
# as all files have the same name on all clients
135136
remote_client.stop(i == 0)

0 commit comments

Comments
 (0)