Skip to content

Commit 09a56d2

Browse files
committed
test: accept platform auto-abort in test_actor_charge_limit
Hitting max_total_charge_usd makes the platform auto-abort the run, which races with the Actor's clean exit, so the terminal status is non-deterministically SUCCEEDED or ABORTED; accept both.
1 parent 3f25d4a commit 09a56d2

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tests/e2e/test_actor_charge.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,20 @@ async def test_actor_charge_limit(
142142
) -> None:
143143
run = await run_actor(ppe_actor, max_total_charge_usd=Decimal('0.2'))
144144

145+
# Reaching `max_total_charge_usd` makes the platform abort the run automatically, and that abort races with the
146+
# Actor's own clean exit — so the terminal status is either SUCCEEDED or ABORTED. Both are valid here; the
147+
# behavior under test is that the charge limit capped the run at exactly 2 of the 4 attempted events.
148+
terminal_statuses = {ActorJobStatus.SUCCEEDED, ActorJobStatus.ABORTED}
149+
145150
# Refetch until the charged event counts propagate on the platform.
146151
run = await poll_until_condition(
147152
partial(_get_run, apify_client_async, run.id),
148-
lambda r: r.status == ActorJobStatus.SUCCEEDED and r.charged_event_counts == {'foobar': 2},
153+
lambda r: r.status in terminal_statuses and r.charged_event_counts == {'foobar': 2},
149154
timeout=30,
150155
poll_interval=1,
151156
)
152157

153-
assert run.status == ActorJobStatus.SUCCEEDED
158+
assert run.status in terminal_statuses
154159
assert run.charged_event_counts == {'foobar': 2}
155160

156161

0 commit comments

Comments
 (0)