Skip to content

test(compute): add JUnit 5 integration tests for WaitForOperation - #10396

Merged
XrossFox merged 2 commits into
GoogleCloudPlatform:mainfrom
XrossFox:create-missing-test-rename-tests
Nov 26, 2026
Merged

XrossFox merged 2 commits into
GoogleCloudPlatform:mainfrom
XrossFox:create-missing-test-rename-tests

Conversation

@XrossFox

@XrossFox XrossFox commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Add compute/cloud-client/src/test/java/compute/WaitForOperationIT.java covering the Compute Engine WaitForOperation sample:

  • Waiting for an in-progress zonal disk creation operation to reach DONE
  • Handling an operation that is already in Status.DONE
  • Verifying NotFoundException is thrown for a non-existent operation Uses an AutoCloseable TempZonalDisk fixture with try-with-resources to isolate and clean up temporary disks per test, and documents required environment variables in class Javadoc.

Fixes b/585606810

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended.
  • Tests pass: mvn clean verify required
  • Lint passes: mvn -P lint checkstyle:check required
  • Static Analysis: mvn -P lint clean compile pmd:cpd-check spotbugs:check advisory only

Compliance & Style

  • I have followed Sample Format Guide
  • pom.xml parent set to latest shared-configuration
  • Appropriate changes to README are included in PR
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample

Post-Approval Actions

  • Please merge this PR for me once it is approved

Add compute/cloud-client/src/test/java/compute/WaitForOperationIT.java
covering the Compute Engine WaitForOperation sample:
- Waiting for an in-progress zonal disk creation operation to reach DONE
- Handling an operation that is already in Status.DONE
- Verifying NotFoundException is thrown for a non-existent operation
Uses an AutoCloseable TempZonalDisk fixture with try-with-resources to
isolate and clean up temporary disks per test, and documents required
environment variables in class Javadoc.
@product-auto-label product-auto-label Bot added api: compute Issues related to the Compute Engine API. samples Issues that are directly related to samples. labels Nov 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces integration tests for the WaitForOperation class in WaitForOperationIT.java, using a temporary zonal disk helper (TempZonalDisk) to manage resource creation and cleanup. The feedback highlights a potential resource leak in the close() method of TempZonalDisk: if waitUntilDone() throws an exception, the subsequent disk deletion is skipped. It is recommended to wrap waitUntilDone() in a try-finally block to ensure cleanup always executes.

…tionIT cases

Address code review feedback on WaitForOperationIT:
- Bound TempZonalDisk cleanup polling with a 3-minute deadline and 1s
  backoff, make initialOperation immutable, and ensure disk deletion
  still runs if waiting fails while preserving suppressed exceptions
  and thread interrupt status
- Use a synthetic non-existent Status.DONE Operation in
  testWaitForOperationAlreadyDone to avoid provisioning a live disk
  and fail with NotFoundException if WaitForOperation ever re-waits
- Explicitly set Status.RUNNING on the invalid Operation test case
@XrossFox

XrossFox commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Please note that failures on the pipeline are unrelated to these changes, they will be addressed on a different task b/590601059.

@angelcaamal angelcaamal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the errors will be fixed, LGTM!

@XrossFox
XrossFox marked this pull request as ready for review November 26, 2026 16:39
@XrossFox
XrossFox requested review from a team and yoshi-approver as code owners November 26, 2026 16:39

@amcolin amcolin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@XrossFox
XrossFox merged commit 6b76942 into GoogleCloudPlatform:main Nov 26, 2026
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: compute Issues related to the Compute Engine API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants