Skip to content

fix: Make TasksTest.cancel independent of the task's timing (5.x.x) - #1420

Merged
ZPascal merged 1 commit into
cloudfoundry:5.x.xfrom
ZPascal:fix-tasks-cancel-flake-5.x.x
Nov 26, 2026
Merged

ZPascal merged 1 commit into
cloudfoundry:5.x.xfrom
ZPascal:fix-tasks-cancel-flake-5.x.x

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 -Dmaven.javadoc.skip spotless:check install passes (JDK 11).
  • The integration test itself runs in this PR's CI.

The main counterpart is #1419.

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 ea225aa into cloudfoundry:5.x.x Nov 26, 2026
6 checks passed
@ZPascal
ZPascal deleted the fix-tasks-cancel-flake-5.x.x branch November 26, 2026 12:00
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