Skip to content

Commit

Permalink
Prober
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed Oct 24, 2023
1 parent 4683b34 commit 9df3206
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/tools/interop/idt/capture/ecosystem/play_services/prober.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from capture.utils.shell import Bash
from capture.utils import log

logger = log.get_logger(__file__)


Expand All @@ -28,26 +29,29 @@ def __init__(self, platform):
self.platform = platform
self.artifact_dir = self.platform.artifact_dir
self.logger = logger
self.probe_artifact = os.path.join(self.artifact_dir, "net_probes.txt")
self.command_suffix = f" 2>&1 | tee -a {self.probe_artifact}"
self.target = "googlehomefoyer-pa.googleapis.com"

async def _probe_tracert_icmp_foyer(self) -> None:
Bash(f"sudo traceroute {self.target} {self.command_suffix}", sync=True).start_command()

async def _probe_tracert_udp_foyer(self) -> None:
Bash(f"sudo traceroute -U -p 443 {self.target} {self.command_suffix}", sync=True).start_command()

async def _probe_tracert_tcp_foyer(self) -> None:
Bash(f"sudo traceroute -T -p 443 {self.target} {self.command_suffix}", sync=True).start_command()

async def _probe_ping_foyer(self) -> None:
Bash(f"ping -c 4 {self.target} {self.command_suffix}", sync=True).start_command()

async def _probe_dns_foyer(self) -> None:
Bash(f"dig {self.target} {self.command_suffix}", sync=True).start_command()

async def _probe_foyer(self) -> None:
self.logger.info("probing remote services")
tgt = "googlehomefoyer-pa.googleapis.com"
probe_artifact = os.path.join(self.artifact_dir, "net_probes.txt")
command_suffix = f" 2>&1 | tee -a {probe_artifact}"
ping_cmd = f"ping -c 4 {tgt} {command_suffix}"
Bash(ping_cmd, sync=True).start_command()
trace_cmd_i = f"sudo traceroute {tgt} {command_suffix}"
Bash(trace_cmd_i, sync=True).start_command()
trace_cmd_t = f"sudo traceroute -T -p 443 {tgt} {command_suffix}"
Bash(trace_cmd_t, sync=True).start_command()
trace_cmd_u = f"sudo traceroute -U -p 443 {tgt} {command_suffix}"
Bash(trace_cmd_u, sync=True).start_command()
dig_cmd = f"dig {tgt} {command_suffix}"
Bash(dig_cmd, sync=True).start_command()
self.logger.info("probing from phone")
ping_from_phone = f"shell {ping_cmd} {command_suffix}"
self.platform.run_adb_command(ping_from_phone)
async def _probe_from_phone_ping_foyer(self) -> None:
self.platform.run_adb_command(f"shell ping -c 4 {self.target} {self.command_suffix}")

async def probe_services(self) -> None:
for probe_func in filter(lambda s: s.startswith('_probe'), dir(self)):
self.logger.info(f"Probing {self.target}")
for probe_func in [s for s in dir(self) if s.startswith('_probe')]:
await getattr(self, probe_func)()

0 comments on commit 9df3206

Please sign in to comment.