Skip to content

fix: Make TasksTest.cancel independent of the task's timing - #1419

Merged
ZPascal merged 1 commit into
cloudfoundry:mainfrom
ZPascal:fix-tasks-cancel-flake
Nov 26, 2026
Merged

ZPascal merged 1 commit into
cloudfoundry:mainfrom
ZPascal:fix-tasks-cancel-flake

Conversation

@ZPascal

@ZPascal ZPascal commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

TasksTest.cancel flakes, e.g. in the v2 job of #1409 (run 45671668192):

TasksTest.cancel expectation "expectNext(CANCELING)" failed (expected value: CANCELING; actual value: FAILED)

Cause

The Cloud Controller's cancel endpoint (TaskCancel, TasksController#cancel) sets the task to CANCELING, cancels it in Diego and then renders task.reload. When Diego's completion callback has already marked the canceled task FAILED by then, the response shows FAILED.

A second race: the test canceled an ls task. If that finished before the cancel request, the Cloud Controller rejects the cancel with Task state is SUCCEEDED and therefore cannot be canceled.

Changes

  • Accept CANCELING or FAILED in the cancel response (as DeploymentsTest does for CANCELING/CANCELED).
  • Cancel a sleep 99 task, like operations.ApplicationsTest.terminateTask does, so the task is still running when the cancel arrives.

Testing

  • ./mvnw -Pintegration-test -DskipTests spotless:check install passes.
  • The integration test itself runs in this PR's CI.

The 5.x.x counterpart is #1420.

The Cloud Controller sets a canceled task to CANCELING, cancels it in
Diego and then reloads it for the response. When Diego reports the
canceled task as FAILED before that reload, the response shows FAILED and
the test failed with "expected value: CANCELING; actual value: FAILED".

The test now accepts CANCELING and FAILED, and cancels a "sleep 99" task
instead of "ls", which could finish before the cancel request and make the
Cloud Controller reject it.
@ZPascal
ZPascal merged commit cb4f3b8 into cloudfoundry:main Nov 26, 2026
4 checks passed
@ZPascal
ZPascal deleted the fix-tasks-cancel-flake branch November 26, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants