Skip to content
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

[8.15](backport #5409) [Integration Test Framework] fix createTempDir and flaky tests #5444

Closed
wants to merge 1 commit into from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 5, 2024

What does this PR do?

createTempDir register a test cleanup function to remove the folder it created, however, on Windows, this folder sometimes fails to be removed because there are still open file handlers for the files within the folder.

We fix this problem by retrying to remove the folder with a maximum overall wait time of 3 seconds. This is a very similar approach to what Go's t.TempDir does.

Fix the flakiness from TestUpgradeHandler* tests by re-working the
mockUpgradeManager, now it accepts a function for its Upgrade method
and their implementation is goroutine safe

Why is it important?

It fixes flakiness on Windows hosts

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added an entry in ./changelog/fragments using the changelog tool
  • [ ] I have added an integration test or an E2E test

Disruptive User Impact

There is not user impact

How to test this PR locally

Run the integration test on Windows:

SNAPSHOT=true TEST_PLATFORMS="windows/amd64" mage -v integration:single TestEventLogFile

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

This is an automatic backport of pull request #5409 done by [Mergify](https://mergify.com).

createTempDir register a test cleanup function to remove the folder it
created, however, on Windows, this folder sometimes fails to be
removed because there are still open file handlers for the files
within the folder.

We fix this problem calling install.RemovePath that will retry removing
the folder for about 2s. This is a very similar approach to
what Go's t.TempDir does.

Fix the flakiness from TestUpgradeHandler* tests by re-working the
mockUpgradeManager, now it accepts a function for its Upgrade method
and their implementation is goroutine safe

(cherry picked from commit 1242e71)

# Conflicts:
#	internal/pkg/agent/application/actions/handlers/handler_action_upgrade_test.go
#	pkg/testing/fixture.go
#	testing/integration/event_logging_test.go
@mergify mergify bot requested a review from a team as a code owner September 5, 2024 15:52
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels Sep 5, 2024
@mergify mergify bot requested review from michel-laterman and swiatekm and removed request for a team September 5, 2024 15:52
Copy link
Contributor Author

mergify bot commented Sep 5, 2024

Cherry-pick of 1242e71 has failed:

On branch mergify/bp/8.15/pr-5409
Your branch is up to date with 'origin/8.15'.

You are currently cherry-picking commit 1242e7186a.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   internal/pkg/agent/application/actions/handlers/handler_action_upgrade_test.go
	both modified:   pkg/testing/fixture.go
	both modified:   testing/integration/event_logging_test.go

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@belimawr
Copy link
Contributor

belimawr commented Sep 5, 2024

I added this backport to #5410 so we get a single PR with all the fixes and hopefully don't need to force merge anything.

Copy link
Contributor Author

mergify bot commented Sep 6, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b mergify/bp/8.15/pr-5409 upstream/mergify/bp/8.15/pr-5409
git merge upstream/8.15
git push upstream mergify/bp/8.15/pr-5409

@belimawr
Copy link
Contributor

belimawr commented Sep 6, 2024

Closing in favour of #5410

@belimawr belimawr closed this Sep 6, 2024
@mergify mergify bot deleted the mergify/bp/8.15/pr-5409 branch September 6, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport conflicts There is a conflict in the backported pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant