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

Move FakeInput tests into their own test suite #4079

Merged
merged 6 commits into from
Jan 17, 2024
Merged

Conversation

faec
Copy link
Contributor

@faec faec commented Jan 12, 2024

Tests using the FakeInput and FakeShipper components need to run Agent test code in a temporary test directory. To do this, they need to modify the global flags unversionedHome and topPath. However, they can't safely restore these flags at the end of the test, because it is detected as a data race with access of these flags during the test execution (logically this is not a real race but the race detector doesn't know that).

This PR resolves that by moving these tests into their own test suite, which sets the correct temporary paths at the beginning of each test instead of through a manual helper function call. This way the globals don't need to be explicitly cleaned up after the tests, and there's less risk of omitting the temporary directory setup in a test where it's needed.

The diff is less than it looks like, since (other than moving to a different file) most tests only have changes in their first couple lines.

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

Related issues

@faec faec added Team:Elastic-Agent Label for the Agent team Cleanup labels Jan 12, 2024
@faec faec self-assigned this Jan 12, 2024
@faec faec requested a review from a team as a code owner January 12, 2024 19:19
@faec faec requested review from michalpristas and pchila January 12, 2024 19:19
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

Copy link
Contributor

mergify bot commented Jan 12, 2024

This pull request does not have a backport label. Could you fix it @faec? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

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

NOTE: backport-skip has been added to this pull request.

Copy link

Quality Gate passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No Coverage information No data about Coverage
0.0% 0.0% Duplication on New Code

See analysis details on SonarQube

@pierrehilbert
Copy link
Contributor

Unrelated failure #4076

@pierrehilbert
Copy link
Contributor

@faec do we need another round of review or should I force merge this one as the failure is unrelated to this change?

@faec faec merged commit 71c7cb3 into elastic:main Jan 17, 2024
7 checks passed
@faec faec deleted the fakeinput-tests branch January 17, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix data race in tests that modify global agent paths in component runtime tests
5 participants