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 #5361) Fix TestEnvWithDefault and TestContainerCMDEventToStderr #5459

Closed
wants to merge 1 commit into from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 6, 2024

What does this PR do?

This PR fixes two tests:

TestEnvWithDefault
Now TestEnvWithDefault unsets all environment variables it sets,
allowing it to be run multiple times using -count.

TestContainerCMDEventToStderr
TestContainerCMDEventToStderr did not call agentFixture.Prepare early
enough leading to an empty STATE_PATH env var, so all state
information was in /usr/share/elastic-agent, which could make
subsequent tests to fail because they could read
/usr/share/elastic-agent/state/container-paths.yml and use a state
path different than the one set in the test.

Why is it important?

It fixes tests and prevents TestEventLogOutputConfiguredViaFleet from being flaky.

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 no disruptive user impact because this PR only updates tests.

How to test this PR locally

Testing the fix in TestContainerCMDEventToStderr

  1. Run the test
SNAPSHOT=true TEST_PLATFORMS="linux/amd64" mage integration:single TestContainerCMDEventToStderr
  1. SSH into the VM
$(mage integration:ssh)
  1. Ensure /usr/share/elastic-agent does not exist

TestEnvWithDefault

cd internal/pkg/agent/cmd
go test -count=10 -v -run=TestEnvWithDefault

Make sure the test succeeds

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 #5361 done by [Mergify](https://mergify.com).

Now TestEnvWithDefault unsets all environment variables it sets,
allowing it to be run multiple times using `-count`.

TestContainerCMDEventToStderr did not call agentFixture.Prepare early
enough leading to an empty STATE_PATH env var, so all state
information was in /usr/share/elastic-agent, which could make
subsequent tests to fail because they could read
/usr/share/elastic-agent/state/container-paths.yml and use a state
path different than the one set in the test.

---------

Co-authored-by: Paolo Chilà <paolo.chila@elastic.co>
(cherry picked from commit 632eec6)
@mergify mergify bot requested a review from a team as a code owner September 6, 2024 15:27
@mergify mergify bot added the backport label Sep 6, 2024
@mergify mergify bot requested review from andrzej-stencel and swiatekm and removed request for a team September 6, 2024 15:27
Copy link

@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-5361 branch September 6, 2024 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant