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

Enhancement/5832 deb rpm docker tests #6212

Merged

Conversation

kaanyalti
Copy link
Contributor

@kaanyalti kaanyalti commented Dec 4, 2024

  • Enhancement

What does this PR do?

Adds tests validating elastic-agent upgrade command does not and should not work for deb, rpm and docker.

Why is it important?

We currently don't have any tests validating that the upgrade command does not work

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

How to test this PR locally

  • Build deb, rpm packages and docker images
  • Run the following commands
 TEST_PACKAGES='deb' SNAPSHOT=true TEST_GROUPS="deb" TEST_PLATFORMS="linux/amd64" GOTEST_FLAGS='-test.run ^TestRestrictUpgradeDeb$' mage integration:test
 TEST_PACKAGES='rpm' SNAPSHOT=true TEST_GROUPS="rpm" TEST_PLATFORMS="linux/amd64" GOTEST_FLAGS='-test.run ^TestRestrictUpgradeRPM$' mage integration:test
K8S_VERSION=v1.31.0 TEST_INTEG_CLEAN_ON_EXIT=true INSTANCE_PROVISIONER=kind STACK_PROVISIONER=stateful TEST_PLATFORMS="kubernetes/arm64/1.31.0/<IMAGE TYPE>" SNAPSHOT=true mage integration:kubernetes

The image type can be basic, wolfi or any other listed in the test itself

Related issues

@kaanyalti kaanyalti requested a review from a team as a code owner December 4, 2024 14:12
Copy link
Contributor

mergify bot commented Dec 4, 2024

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

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

Copy link
Contributor

mergify bot commented Dec 4, 2024

backport-v8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Dec 4, 2024
@kaanyalti kaanyalti force-pushed the enhancement/5832_deb-rpm-docker-tests branch 2 times, most recently from 2d97ecf to bb1571e Compare December 5, 2024 14:22
@kaanyalti kaanyalti requested a review from a team as a code owner December 5, 2024 20:05
@rowlandgeoff
Copy link
Contributor

Maybe mark this PR as Draft for now while you keep testing it? I really wouldn't want to accidentally commit a change where the Buildkite pipelines are all getting commented out. 😉

@rowlandgeoff
Copy link
Contributor

trying to run only my test in ci

I don't think we currently have an easy mechanism of doing this. Perhaps something we can consider in the future.

@kaanyalti kaanyalti marked this pull request as draft December 6, 2024 02:53
@kaanyalti
Copy link
Contributor Author

buildkite test this

@kaanyalti kaanyalti force-pushed the enhancement/5832_deb-rpm-docker-tests branch from a87a4f0 to 8ccbc38 Compare December 9, 2024 20:32
Copy link
Contributor

mergify bot commented Dec 13, 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 enhancement/5832_deb-rpm-docker-tests upstream/enhancement/5832_deb-rpm-docker-tests
git merge upstream/main
git push upstream enhancement/5832_deb-rpm-docker-tests

@kaanyalti kaanyalti force-pushed the enhancement/5832_deb-rpm-docker-tests branch 4 times, most recently from b8d030d to 491761c Compare December 16, 2024 18:29
Copy link
Contributor

mergify bot commented Dec 17, 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 enhancement/5832_deb-rpm-docker-tests upstream/enhancement/5832_deb-rpm-docker-tests
git merge upstream/main
git push upstream enhancement/5832_deb-rpm-docker-tests

@michalpristas
Copy link
Contributor

michalpristas commented Dec 18, 2024

the problem with integration test is that /etc/elastic-agent is kept there and new installation assumes enrolled agent.
when you run purge it will be removed and next install will work.
why purge works and uninstall does not is this sneaky condition we have here:

case "$1" in
  purge)
    rm -rf /var/lib/elastic-agent /var/log/elastic-agent /etc/elastic-agent
    ;;

  # 0 is for rpm uninstall
  upgrade|remove|failed-upgrade|abort-install|abort-upgrade|disappear|0)

what we need to do is move rm -rf /etc/elastic-agent outside of this this if statement. this can be troublesome in case of upgrades. ideally we remove not only on purge but also uninstall but not upgrade

behavior also described in PR #4334

@kaanyalti kaanyalti force-pushed the enhancement/5832_deb-rpm-docker-tests branch 2 times, most recently from 8f74d86 to 694f0e8 Compare December 19, 2024 03:27
@kaanyalti kaanyalti marked this pull request as ready for review December 19, 2024 05:39
@kaanyalti
Copy link
Contributor Author

kaanyalti commented Dec 20, 2024

the problem with integration test is that /etc/elastic-agent is kept there and new installation assumes enrolled agent. when you run purge it will be removed and next install will work. why purge works and uninstall does not is this sneaky condition we have here:

case "$1" in
  purge)
    rm -rf /var/lib/elastic-agent /var/log/elastic-agent /etc/elastic-agent
    ;;

  # 0 is for rpm uninstall
  upgrade|remove|failed-upgrade|abort-install|abort-upgrade|disappear|0)

what we need to do is move rm -rf /etc/elastic-agent outside of this this if statement. this can be troublesome in case of upgrades. ideally we remove not only on purge but also uninstall but not upgrade

behavior also described in PR #4334

Based on our discussion implement manual removal of agent files during RPM clean up in the test fixture

@kaanyalti kaanyalti force-pushed the enhancement/5832_deb-rpm-docker-tests branch from aec6441 to fc6ed16 Compare December 20, 2024 04:21
Copy link

Copy link
Contributor

@michalpristas michalpristas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like that

Copy link
Contributor

@pkoutsovasilis pkoutsovasilis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice work 🙂 Thanks for addressing my comment ❤️

@kaanyalti kaanyalti merged commit 3f608bf into elastic:main Dec 20, 2024
13 checks passed
@kaanyalti kaanyalti deleted the enhancement/5832_deb-rpm-docker-tests branch December 20, 2024 15:47
mergify bot pushed a commit that referenced this pull request Dec 20, 2024
* enhancement(5832): added integration tests

* enhancement(5832): updated fixture install, updated assertions

* enhancement(5832): added kubernetes test

* enhancement(5832): ran mage update

* enhancement(5832): execute rpm test in default group

* Revert "enhancement(5832): execute rpm test in default group"

This reverts commit fa93a8e.

* enhancement(5832): debugging ci issues

* enahancement(5832): added logs to see if any other agent is running, commented out other integration tests

* enhancement(5832): added cleanup steps to rpm tests

* enhancement(5832): trying 777 permission

* enhancement(5832): removed diagnostics, added rpm cleanup step that purges all agent files

* enhancement(5832): running all tests

* enhancement(5832): uncommented integration test pipeline

* enhancement(5832): reverting unnecessary changes

* enhancement(5832): uncommenting integration tests

* enhancement(5832): reverted integration_tests.sh changes

* enhancement(5832): reverted fixture_install.go changes

* enhancement(5832): remove print

* enhancement(5832): logging output if cleanup fails

* enhancement(5832): updated k8s test, refactored upgrade test into test step

(cherry picked from commit 3f608bf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent users from upgrading standalone agents in container, deb, and rpm environments
4 participants