Repository navigation
test(postman): assert active import jobs against their state, not timing (#37887) - #37912
Conversation
…ing (#37887) The "Get all active Jobs" request asserted that no active job had startedAt or completedAt. The job processor runs concurrently, so a job can be RUNNING by the time the request lands, and the active list also includes FAILED and ABANDONED jobs, which carry completedAt. Timestamps are now checked against each job's reported state, the state must be one of the states getActiveJobs returns, and a newly created job missing from the active list is accepted only if its status endpoint reports SUCCESS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @fabrizzio-dotCMS's task in 11s —— View job I'll analyze this and get back to you. |
|
|
Resolve the server URL with the same baseUrl fallback the collection pre-request script uses, and assert the lookup returned 200 before reading entity.state so an error response fails with a readable message instead of a TypeError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
dotbot code review:
Test-only change. ACTIVE_STATES exactly matches PostgresJobQueue.getActiveJobs filter and state-conditional timestamp assertions remove the timing race. Both prior fallback-lookup hardening items are verified present in HEAD. Tip: comment with "/dotbot address comments" to attempt automated fixes for unresolved review threads. reviewed by dotbot · meta/muse-spark-1.3 · medium |
|
dotbot code review:
Test-only change to a Postman collection. ACTIVE_STATES exactly matches the states filtered by PostgresJobQueue.getActiveJobs (PENDING, RUNNING, FAILED, ABANDONED, CANCEL_REQUESTED, CANCELLING), and the state-conditional timestamp assertions match the Job lifecycle transitions in AbstractJob (markAsRunning always sets startedAt; markAsFailed/markAsAbandoned always set completedAt). Both prior review findings (serverURL fallback and res.code guard in the fallback lookup) are present in HEAD. No new issues found. Tip: comment with "/dotbot address comments" to attempt automated fixes for unresolved review threads. reviewed by dotbot · ~z-ai/glm-latest · medium |
dotCMS-Machine-User
left a comment
There was a problem hiding this comment.
✅ dotbot review: all reviewer models (meta/muse-spark-1.3, ~z-ai/glm-latest) agree — patch is correct.
approved automatically by dotbot
ihoffmann-dot
left a comment
There was a problem hiding this comment.
Non-blocking suggestion: ContentImportResource.postman_collection.json, test "jobId is present in the response or already finished successfully"
When the job is not in the active list, the outer pm.test returns immediately and the real SUCCESS assertion runs in a nested pm.test inside the async pm.sendRequest callback. The outer test is always green, and a failed or cancelled job is only reported by the nested test, which may register after the outer one completes.
Consider moving the fallback lookup out of the outer test into its own top-level pm.sendRequest + pm.test, so a single, clearly named test carries the pass/fail result.
The rest looks good: ACTIVE_STATES matches PostgresJobQueue.getActiveJobs, and asserting timestamps against the reported state removes the timing flakiness.
Closes #37887
Problem
ContentImportResource→TestGetStatus→ Get all active Jobs asserted that no active job hadstartedAtorcompletedAt. The job processor runs concurrently with the collection, so a freshly created job can already beRUNNING(withstartedAt) when the request lands — which is what failed run 37020786581. The active list (PostgresJobQueue.getActiveJobs) also includesFAILEDandABANDONEDjobs, which carrycompletedAt, so that assertion had the same latent problem.Change
Only the "Get all active Jobs" test script changes; no server code.
statemust be one of the statesgetActiveJobsreturns:PENDING,RUNNING,FAILED,ABANDONED,CANCEL_REQUESTED,CANCELLING.PENDING→ nostartedAt, nocompletedAtRUNNING→startedAtpresent, nocompletedAtFAILED/ABANDONED→completedAtpresentGET /api/v1/content/_import/{jobId}reportsSUCCESS.Verification
RUNNINGwithstartedAt(the CI failure)FAILEDjob withcompletedAtin the active listSUCCESSFAILEDRUNNINGwithoutstartedAtPENDINGwithstartedAtSUCCESSin the active listPENDING🤖 Generated with Claude Code
This PR fixes: #37887