Skip to content
Snippets Groups Projects
Commit b5560947 authored by Michael Eischer's avatar Michael Eischer
Browse files

format ping times as required

parent 8ae9dd33
No related branches found
No related tags found
No related merge requests found
......@@ -23,14 +23,15 @@ class PingLogParser(Parser):
if parts[0] == "===":
started = True
who = (parts[3], parts[5])
who = (parts[3], parts[5], parts[7], parts[8])
elif parts[0] == "rtt":
if who is None:
raise FatalLogIssue("Broken logfile " + path)
times = parts[3].split("/")
ld.add_data(timestamp, src=who[0], dst=who[1], ping=float(times[1]), variance=float(times[3]))
ld.add_data(timestamp, src=who[0], dst=who[1], srcIdx=int(who[2]), dstIdx=int(who[3]),
ping=float(times[1]), variance=float(times[3]))
if float(times[3]) > 5:
ld.add_warning(timestamp, "High variance between {}".format(who))
......
......@@ -15,4 +15,9 @@ class OutputPingTransformer(Transformer):
if "ping" in e:
f.write("PING_TIME_MAP['{}']['{}'] = {}\n".format(e["src"], e["dst"], e["ping"]))
with open("ping-locs-{}.txt".format(log.scenario), "w") as f:
for e in log.entries():
if "ping" in e:
f.write("latency_{}_{} = {}\n".format(e["srcIdx"], e["dstIdx"], round(e["ping"] / 2)))
return logs
......@@ -22,11 +22,11 @@ class MeasureServerPings(GenericTestRun):
# Nothing to do for this test
return True
def _ping(self, src, dst) -> Tuple[str, int]:
def _ping(self, src, dst, srcIdx, dstIdx) -> Tuple[str, int]:
ssh = self.start_ssh(self.config["remote.user"], src, "ping", "-c", str(self.duration), dst,
stdout=subprocess.PIPE)
(output, _) = ssh.communicate()
log = "=== Ping from {} to {} ===".format(src, dst)
log = "=== Ping from {} to {} idx {} {} ===".format(src, dst, srcIdx, dstIdx)
if ssh.returncode != 0:
log += "\nMeasurement error {}".format(ssh.returncode)
return log, ssh.returncode
......@@ -38,14 +38,14 @@ class MeasureServerPings(GenericTestRun):
return log, 0
def stage_bench(self) -> bool:
servers = self.get_servers(("client.network.addresses", "replica.network.addresses"))
servers = self.get_servers(("replica.network.addresses",))
with ThreadPoolExecutor(max_workers=30) as executor:
results = []
for (i, dst) in enumerate(servers):
for (i, src) in enumerate(servers):
for j in range(i + 1, len(servers)):
src = servers[j]
res = executor.submit(self._ping, src, dst)
dst = servers[j]
res = executor.submit(self._ping, src, dst, i, j)
results.append(res)
for res in results:
r = res.result()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment