Skip to content

Commit 04f17a6

Browse files
fix(nimbus): poll logcat for fenix log-state row instead of fixed sleep (#15631)
Because * The fenix enrollment integration test was intermittently failing on the beta channel job with "No log-state row found": the fixed 5s wait after `nimbus-cli log-state` races the SDK's async row print, which is slower on beta than release. This commit * Replaces the 5s post-log-state sleep with a 60s bounded poll on `adb logcat -d` that exits as soon as the expected experiment row appears. * Lengthens the failure message to surface the timeout. Fixes #15629
1 parent cf7c133 commit 04f17a6

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

experimenter/tests/integration/nimbus/android/test_fenix_enrollment.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
FENIX_APP = BaseExperimentApplications.FIREFOX_FENIX.value
1111
APP_APPLY_WAIT = 15
12-
LOG_STATE_WAIT = 5
12+
LOG_STATE_TIMEOUT = 60
13+
LOG_STATE_POLL_INTERVAL = 1
1314

1415

1516
@pytest.mark.fenix_enrollment
@@ -59,17 +60,24 @@ def test_fenix_enrollment(
5960
subprocess.check_call(
6061
["nimbus-cli", "--app", FENIX_APP, "--channel", fenix_channel, "log-state"]
6162
)
62-
time.sleep(LOG_STATE_WAIT)
63-
64-
logcat = subprocess.check_output(["adb", "logcat", "-d"], text=True)
6563

6664
pattern = re.compile(
6765
rf"nimbus_client:\s*{re.escape(experiment_slug)}\s+\|\s*\S+\s+\|\s*(\S+)"
6866
)
69-
match = pattern.search(logcat)
67+
68+
logcat = ""
69+
match = None
70+
deadline = time.monotonic() + LOG_STATE_TIMEOUT
71+
while time.monotonic() < deadline:
72+
logcat = subprocess.check_output(["adb", "logcat", "-d"], text=True)
73+
match = pattern.search(logcat)
74+
if match is not None:
75+
break
76+
time.sleep(LOG_STATE_POLL_INTERVAL)
77+
7078
nimbus_lines = [line for line in logcat.splitlines() if "nimbus_client" in line]
7179
assert match is not None, (
72-
f"No log-state row found for {experiment_slug}.\n"
80+
f"No log-state row found for {experiment_slug} after {LOG_STATE_TIMEOUT}s.\n"
7381
f"--- last 30 nimbus_client lines ---\n" + "\n".join(nimbus_lines[-30:])
7482
)
7583
enrolled_branch = match.group(1)

0 commit comments

Comments
 (0)