Skip to content

Commit b7ba6e5

Browse files
committed
Standardize timeout values and improve API caching delays
Assisted-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent da269be commit b7ba6e5

2 files changed

Lines changed: 35 additions & 28 deletions

File tree

src/validation/testcase/base.py

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ class TestFailureError(Exception):
2626

2727
class Testcase(ABC):
2828
CHECK_TIME_FOR_STATUSES_TO_APPEAR = (
29-
2 # minutes - time to wait for statuses to appear after trigger
29+
3 # minutes - time to wait for statuses to appear after trigger
3030
)
31-
CHECK_TIME_FOR_REACTION = 2 # minutes - time to wait for commit statuses to be set to pending
31+
CHECK_TIME_FOR_REACTION = 3 # minutes - time to wait for commit statuses to be set to pending
3232
CHECK_TIME_FOR_SUBMIT_BUILDS = 5 # minutes - time to wait for build to be submitted in Copr
3333
CHECK_TIME_FOR_BUILD = 60 # minutes - time to wait for build to complete
3434
CHECK_TIME_FOR_WATCH_STATUSES = 60 # minutes - time to watch for commit statuses
3535
POLLING_INTERVAL = 2 # minutes - interval between status/build checks
36+
# Initial wait times after triggering build, before first API check (API caching delays)
37+
WAIT_AFTER_OPENED_PR = 2 # minutes - wait for API to reflect statuses after opening new PR
38+
WAIT_AFTER_COMMENT_PUSH = 1 # minutes - wait after comment/push trigger
3639
PACKIT_YAML_PATH = ".packit.yaml"
3740
MAX_COMMENTS_TO_CHECK = 5 # Limit comment fetching to avoid excessive API calls
3841
HTTP_FORBIDDEN = 403 # HTTP status code for forbidden/access denied
@@ -256,12 +259,19 @@ async def run_checks(self):
256259
self._build_triggered_at = datetime.now(tz=timezone.utc)
257260
self.trigger_build()
258261

259-
# Wait for packit-service to process the webhook and set statuses
262+
# Wait for API to reflect newly created statuses (caching/eventual consistency)
260263
if self.trigger == Trigger.pr_opened:
261-
logging.debug("Waiting 30s for packit-service to receive webhook...")
262-
await asyncio.sleep(30)
264+
logging.debug(
265+
"Waiting %d minute(s) for API to reflect new statuses...",
266+
self.WAIT_AFTER_OPENED_PR,
267+
)
268+
await asyncio.sleep(self.WAIT_AFTER_OPENED_PR * 60)
263269
else:
264-
await asyncio.sleep(5)
270+
logging.debug(
271+
"Waiting %d minute(s) for webhook processing...",
272+
self.WAIT_AFTER_COMMENT_PUSH,
273+
)
274+
await asyncio.sleep(self.WAIT_AFTER_COMMENT_PUSH * 60)
265275

266276
# Check that statuses are set (should show build was skipped)
267277
await self.check_pending_check_runs()
@@ -282,11 +292,10 @@ async def check_pending_check_runs(self):
282292
Check whether some check run is set to queued
283293
(they are updated in loop, so it is enough).
284294
"""
285-
# Filter to only recent statuses (created after build was triggered)
286-
recent_statuses = [
287-
status for status in self.get_statuses() if self.is_status_recent(status)
288-
]
289-
status_names = [self.get_status_name(status) for status in recent_statuses]
295+
# Don't filter by recency here - just check that statuses exist
296+
# Recency filtering happens later in watch_statuses() to exclude old completed statuses
297+
all_statuses = self.get_statuses()
298+
status_names = [self.get_status_name(status) for status in all_statuses]
290299

291300
# Phase 1: Wait for statuses to appear
292301
watch_end = datetime.now(tz=timezone.utc) + timedelta(
@@ -302,10 +311,8 @@ async def check_pending_check_runs(self):
302311
)
303312
return
304313
await asyncio.sleep(30)
305-
recent_statuses = [
306-
status for status in self.get_statuses() if self.is_status_recent(status)
307-
]
308-
status_names = [self.get_status_name(status) for status in recent_statuses]
314+
all_statuses = self.get_statuses()
315+
status_names = [self.get_status_name(status) for status in all_statuses]
309316

310317
logging.info(
311318
"Watching pending statuses for commit %s",
@@ -326,10 +333,11 @@ async def check_pending_check_runs(self):
326333
)
327334
return
328335

336+
# Check all statuses with matching names (don't filter by recency yet)
329337
new_statuses = [
330338
status
331339
for status in self.get_statuses()
332-
if self.get_status_name(status) in status_names and self.is_status_recent(status)
340+
if self.get_status_name(status) in status_names
333341
]
334342

335343
for status in new_statuses:
@@ -359,14 +367,19 @@ async def check_build_submitted(self):
359367
self._build_triggered_at = datetime.now(tz=timezone.utc)
360368
self.trigger_build()
361369

362-
# For new PR, wait longer to give packit-service time to receive webhook
363-
# and set up initial statuses before we start polling
370+
# Wait for API to reflect newly created statuses (caching/eventual consistency)
364371
if self.trigger == Trigger.pr_opened:
365-
logging.debug("Waiting 30s for packit-service to receive webhook...")
366-
await asyncio.sleep(30)
372+
logging.debug(
373+
"Waiting %d minute(s) for API to reflect new statuses...",
374+
self.WAIT_AFTER_OPENED_PR,
375+
)
376+
await asyncio.sleep(self.WAIT_AFTER_OPENED_PR * 60)
367377
else:
368-
# For comment/push triggers, shorter wait is fine
369-
await asyncio.sleep(5)
378+
logging.debug(
379+
"Waiting %d minute(s) for webhook processing...",
380+
self.WAIT_AFTER_COMMENT_PUSH,
381+
)
382+
await asyncio.sleep(self.WAIT_AFTER_COMMENT_PUSH * 60)
370383

371384
watch_end = datetime.now(tz=timezone.utc) + timedelta(
372385
minutes=self.CHECK_TIME_FOR_SUBMIT_BUILDS,

src/validation/testcase/gitlab.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313

1414

1515
class GitlabTestcase(Testcase):
16-
# Gitlab instances are more slow than GitHub
17-
CHECK_TIME_FOR_STATUSES_TO_APPEAR = (
18-
3 # minutes - time to wait for statuses to appear after trigger
19-
)
20-
CHECK_TIME_FOR_REACTION = 3 # minutes - time to wait for commit statuses to be set to pending
21-
CHECK_TIME_FOR_SUBMIT_BUILDS = 7 # minutes - time to wait for build to be submitted in Copr
2216
project: GitlabProject
2317

2418
@property

0 commit comments

Comments
 (0)