Skip to content

Fix integration test cleanup #1295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 9, 2025
Merged

Fix integration test cleanup #1295

merged 4 commits into from
Jul 9, 2025

Conversation

Kehrlann
Copy link
Contributor

@Kehrlann Kehrlann commented Jul 9, 2025

  • A few lifecycle fixes here and there, ensuring the tests have the required dependencies.

  • Removed unused SecureRandom bean

  • The big chunck of this PR is to fix the "CloudFoundryCleaner" which was only called once. See explanation from the asociated commit:

    • CloudFoundryCleaner was not properly triggered on every test. In fact, it was only triggered when the integration test's TestContext would change, which was very infrequent (unsure it was ever triggered). It's possible the cleanup only ever happened when the test suite started.
    • This is because the "clean" method was linked to lifecycle methods of the CloudFoundryCleaner bean, which was only created once.
    • The solution is to add @DirtiesContext, to trigger a re-creation of this bean. We don't want to do it on every test, because it could add more that 1h to the whole test suite. To ensure that it is well understood why this annotation is there in the first place, we introduce the meta-annotation @CleanupCloudFoundryAfterClass.
    • Note that calling CloudFoundryCleaner#clean() directly in tests would not work, because that annotation deletes EVERYTHING, and then subsequent tests would not have an org, a space, etc to operate in. By using @DirtiesContext we ensure those other beans are recreated as well.
    • Lastly, I have a doubt that the CloudFoundryCleaner is even required. I believe deleting an org in current versions of CF deletes EVERYTHING within this org, so it should be enough. However, this would be a much bigger change to the tests, which we don't have the bandwidth to tackle at the moment.

Kehrlann added 4 commits July 9, 2025 09:32
- CloudFoundryCleaner was not properly triggered on every test. In fact,
  it was only triggered when the integration test's TestContext would
  change, which was very infrequent (unsure it was ever triggered). It's
  possible the cleanup only ever happened when the test suite started.
- This is because the "clean" method was linked to lifecycle methods of
  the CloudFoundryCleaner bean, which was only created once.
- The solution is to add `@DirtiesContext`, to trigger a re-creation of
  this bean. We don't want to do it on every test, because it could add
  more that 1h to the whole test suite. To ensure that it is well
  understood why this annotation is there in the first place, we
  introduce the meta-annotation @CleanupCloudFoundryAfterClass.
- Note that calling CloudFoundryCleaner#clean() directly in tests would
  not work, because that annotation deletes EVERYTHING, and then
  subsequent tests would not have an org, a space, etc to operate in. By
  using @DirtiesContext we ensure those other beans are recreated as
  well.
- Lastly, I have a doubt that the CloudFoundryCleaner is even required.
  I believe deleting an org in current versions of CF deletes EVERYTHING
  within this org, so it should be enough. However, this would be a much
  bigger change to the tests, which we don't have the bandwidth to
  tackle at the moment.
@Kehrlann Kehrlann merged commit 6317464 into main Jul 9, 2025
5 checks passed
@Kehrlann Kehrlann deleted the dgarnier/fix-integration-tests branch July 9, 2025 12:26
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