Skip to content

test(dataproc): call teardown inside dataproc/ tests - #14789

Open
NimJay wants to merge 1 commit into
mainfrom
nimjay-dataproc-cluster-cleanup
Open

NimJay wants to merge 1 commit into
mainfrom
nimjay-dataproc-cluster-cleanup

Conversation

@NimJay

@NimJay NimJay commented Nov 12, 2026 •

Copy link
Copy Markdown

Description

  • Two dataproc tests weren't actually cleaning up the Dataproc clusters that they were creating.
  • See Google-internal bug: b/582098748

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended.

To verify that this works, please see the Dataproc clusters at: https://console.cloud.google.com/dataproc/clusters
You'll find the project ID in the internal bug: b/582098748

Compliance & Style


Post-Approval Actions

  • Please merge this PR for me once it is approved

@NimJay
NimJay requested review from a team as code owners November 12, 2026 16:39
@product-auto-label product-auto-label Bot added api: dataproc Issues related to the Managed Service for Apache Spark API. samples Issues that are directly related to samples. labels Nov 12, 2026
out, _ = capsys.readouterr()
assert "Job finished successfully" in out
finally:
teardown()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

All we're doing is adding:

    finally:
        teardown()

out, _ = capsys.readouterr()
assert "Job finished successfully" in out
finally:
teardown()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

All we're doing is adding:

    finally:
        teardown()

@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 wraps Dataproc cluster creation, job submission, and teardown in a try...finally block within the test functions to ensure cleanup. However, because these test functions are decorated with @backoff.on_exception, any transient failure during job submission will trigger the finally block (deleting the cluster) and then recreate the cluster on retry. Since cluster operations are slow, this can cause test timeouts. It is recommended to use a module-scoped pytest fixture to handle cluster setup and teardown, ensuring the cluster is created once and only the job submission is retried.



@backoff.on_exception(backoff.expo, (Exception), max_tries=5)
def teardown():

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This teardown() doesn't actually get triggered by pytest.

@NimJay

NimJay commented Nov 12, 2026

Copy link
Copy Markdown
Author

If this PR becomes stale (i.e., a few months old), I suggest closing this PR entirely since the tests are disabled anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: dataproc Issues related to the Managed Service for Apache Spark API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant