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

Fix race conditions in ManagerV2 tests #36185

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

belimawr
Copy link
Contributor

@belimawr belimawr commented Jul 31, 2023

What does this PR do?

This PR fixes a number of race conditions in the ManagerV2
tests. Most of them were due to the use of Testify's Eventually
function to read some values while some callbacks from the manager
would also modify those values. The simplest solution was to use the
atomic values on those cases.

One test (TestInputReload) had a race condition between the test and
the manager itself, so it was removed. There is an integration tests
that covers the same functionality.

Why is it important?

It fixes some race conditions and #36192

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.next.asciidoc or CHANGELOG-developer.next.asciidoc.
  • I have made my commit title and message explanatory about the purpose and the reason of the change

## Author's Checklist

How to test this PR locally

cd x-pack/libbeat/management
go test -race
cd ../../../
cd x-pack/filebeat
mage docker:composeUp
cd ../../
cd x-pack/filebeat/tests/integration
go test -tags=integration -race

All tests must pass and there should be no race condition.

Related issues

## Use cases
## Screenshots
## Logs

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 31, 2023
@botelastic
Copy link

botelastic bot commented Jul 31, 2023

This pull request doesn't have a Team:<team> label.

@mergify
Copy link
Contributor

mergify bot commented Jul 31, 2023

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @belimawr? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 31, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-08-21T14:34:25.363+0000

  • Duration: 81 min 50 sec

Test stats 🧪

Test Results
Failed 0
Passed 8264
Skipped 381
Total 8645

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@belimawr belimawr force-pushed the fix-race-condition-manager-tests branch 2 times, most recently from d34c645 to 37b14a1 Compare August 2, 2023 10:33
@belimawr belimawr marked this pull request as ready for review August 2, 2023 10:33
@belimawr belimawr requested a review from a team as a code owner August 2, 2023 10:33
@belimawr belimawr force-pushed the fix-race-condition-manager-tests branch from 37b14a1 to 8aee56c Compare August 2, 2023 10:53
@pierrehilbert pierrehilbert added the Team:Elastic-Agent Label for the Agent team label Aug 2, 2023
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Aug 2, 2023
@belimawr belimawr force-pushed the fix-race-condition-manager-tests branch from 8aee56c to 687baf9 Compare August 2, 2023 16:22
@belimawr belimawr enabled auto-merge (squash) August 4, 2023 08:08
@mergify
Copy link
Contributor

mergify bot commented Aug 4, 2023

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 fix-race-condition-manager-tests upstream/fix-race-condition-manager-tests
git merge upstream/main
git push upstream fix-race-condition-manager-tests

This commit fixes a number of race conditions in the ManagerV2
tests. Most of them were due to the use of Testify's Eventually
function to read some values while some callbacks from the manager
would also modify those values. The simplest solution was to use the
atomic values on those cases.

One test (TestInputReload) had a race condition between the test and
the manager itself, so it was removed. There is an integration tests
that covers the same functionality.

There are also some minor clean up regarding logging on tests.
@belimawr belimawr force-pushed the fix-race-condition-manager-tests branch from 687baf9 to 51d6a16 Compare August 21, 2023 14:34
@belimawr
Copy link
Contributor Author

Rebase onto main, force push

@belimawr belimawr requested a review from rdner August 21, 2023 16:59
@belimawr belimawr merged commit 818c72d into elastic:main Aug 22, 2023
10 checks passed
@cmacknz cmacknz added the backport-v8.10.0 Automated backport with mergify label Aug 29, 2023
@cmacknz
Copy link
Member

cmacknz commented Aug 29, 2023

Needs to be backported to 8.10 this is failing there as well #36449 (comment)

mergify bot pushed a commit that referenced this pull request Aug 29, 2023
This commit fixes a number of race conditions in the ManagerV2
tests. Most of them were due to the use of Testify's Eventually
function to read some values while some callbacks from the manager
would also modify those values. The simplest solution was to use the
atomic values on those cases.

One test (TestInputReload) had a race condition between the test and
the manager itself, so it was removed. There is an integration tests
that covers the same functionality.

Closes #36192

(cherry picked from commit 818c72d)
belimawr added a commit that referenced this pull request Aug 31, 2023
This commit fixes a number of race conditions in the ManagerV2
tests. Most of them were due to the use of Testify's Eventually
function to read some values while some callbacks from the manager
would also modify those values. The simplest solution was to use the
atomic values on those cases.

One test (TestInputReload) had a race condition between the test and
the manager itself, so it was removed. There is an integration tests
that covers the same functionality.

Closes #36192

(cherry picked from commit 818c72d)

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
Scholar-Li pushed a commit to Scholar-Li/beats that referenced this pull request Feb 5, 2024
This commit fixes a number of race conditions in the ManagerV2
tests. Most of them were due to the use of Testify's Eventually
function to read some values while some callbacks from the manager
would also modify those values. The simplest solution was to use the
atomic values on those cases.

One test (TestInputReload) had a race condition between the test and
the manager itself, so it was removed. There is an integration tests
that covers the same functionality.

Closes elastic#36192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.10.0 Automated backport with mergify Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build 149 for 8.8 with status FAILURE - FAIL: x-pack/libbeat/management TestInputReload (20.01s)
5 participants