Skip to content

Commit 906d076

Browse files
committed
ci(macrobenchmark): Probe every region when the device catalog is empty
An empty catalog answers 200 exactly like a populated one, so the first probe reported the API as reachable while there was in fact nothing to run on. Report device availability and the other regions' catalogs too, so an unentitled account is distinguishable from a misconfigured region.
1 parent cd34ab6 commit 906d076

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎scripts/macrobenchmark-sauce.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
# region suffix (Google_Pixel_9_Pro_XL_15_real_sjc1).
6060
DEFAULT_DEVICE = "Google_Pixel_9_Pro_XL"
6161

62+
ALL_REGIONS = ("us-west-1", "eu-central-1", "us-east-4")
63+
6264

6365
class SauceError(Exception):
6466
pass
@@ -103,6 +105,13 @@ def device_catalog(self):
103105
)
104106
return response.json()
105107

108+
def device_statuses(self):
109+
"""Device availability, which is a separate endpoint from the catalog."""
110+
response = requests.get(f"{self.rda}/devices/status", auth=self.auth, timeout=60)
111+
if response.status_code != 200:
112+
return f"HTTP {response.status_code}: {response.text[:200]}"
113+
return response.json()
114+
106115
# --- app storage -------------------------------------------------------
107116

108117
def upload_app(self, apk):
@@ -367,6 +376,21 @@ def main():
367376
sys.exit(f"Real Device Access API probe failed: {error}")
368377

369378
print(describe_catalog(catalog, args.device_name))
379+
380+
# An empty catalog answers 200 just like a populated one, so distinguish "no devices
381+
# entitled to this API" from "wrong region" before concluding the API is unusable.
382+
if not catalog:
383+
statuses = device.device_statuses()
384+
count = len(statuses) if isinstance(statuses, list) else statuses
385+
print(f"{args.region}: /devices/status -> {count}")
386+
for region in ALL_REGIONS:
387+
if region == args.region:
388+
continue
389+
other = RealDeviceSession(region, username, access_key)
390+
try:
391+
print(f"{region}: {len(other.device_catalog())} device(s) in the catalog")
392+
except SauceError as error:
393+
print(f"{region}: {error}")
370394
matches = matching_devices(catalog, args.device_name)
371395
# Checked before --probe-only returns, so the probe fails loudly on a device name that
372396
# matches nothing rather than passing and letting the real run discover it.

0 commit comments

Comments
 (0)