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

Clarify purpose of .agent-versions file #5522

Merged
merged 13 commits into from
Sep 20, 2024

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Sep 11, 2024

What does this PR do?

This PR clarifies the purpose of the .agent-versions file. It does so by making the following changes:

  • Moves and renames the file from .agent-versions.json to testing/integration/testdata/.upgrade-test-agent-versions.yml and adjust the contents to match. The reason for using YAML is so we can add a header comment about the contents of the file in the file itself.
  • Updates the upgrade integration tests that use this file to reference the new one.
  • Updates the commit message in PRs created by automation to keep this file updated.

Before this PR

Before this PR, we had an .agent-versions.json file and it looked like this:

{
  "testVersions": [
    "8.15.2-SNAPSHOT",
    "8.15.1",
    "8.15.0",
    "7.17.25-SNAPSHOT"
  ]
}

After this PR

After this PR, we instead have an testing/integration/testdata/.upgrade-test-agent-versions.yml file and it looks like this:

# This file is generated automatically. Please do not manually edit it.

# The testVersions list in this file specifies Elastic Agent versions to be used as
# the starting (pre-upgrade) or ending (post-upgrade) versions of Elastic Agent in
# upgrade integration tests.

testVersions:
  - 8.15.2-SNAPSHOT
  - 8.15.1
  - 8.15.0
  - 7.17.25-SNAPSHOT

Why is it important?

To make it easier to understand the purpose of the .agent-versions file and to prevent accidental manual edits to it.

How to test this PR locally

  1. Create a dummy, valid testing/integration/testdata/.upgrade-test-agent-versions.yml file.
  2. Run integration:updateVersions.
  3. Make sure the testing/integration/testdata/.upgrade-test-agent-versions.yml file is updated with the expected contents.

Copy link
Contributor

mergify bot commented Sep 11, 2024

This pull request does not have a backport label. Could you fix it @ycombinator? 🙏
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 Sep 11, 2024

backport-v8.x has been added to help with the transition to the new branch 8.x.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Sep 11, 2024
@ycombinator ycombinator added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Sep 11, 2024
@ycombinator ycombinator marked this pull request as ready for review September 11, 2024 16:03
@ycombinator ycombinator requested a review from a team as a code owner September 11, 2024 16:03
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

Copy link
Member

@pchila pchila left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -22,7 +22,7 @@ else
git add .agent-versions.json .package-version

nl=$'\n' # otherwise the new line character is not recognized properly
commit_desc="These files are used for picking agent versions in integration tests.${nl}${nl}The content is based on responses from https://www.elastic.co/api/product_versions and https://snapshots.elastic.co${nl}${nl}The current update is generated based on the following requirements:${nl}${nl}Package version: ${package_version}${nl}${nl}\`\`\`json${nl}${version_requirements}${nl}\`\`\`"
commit_desc="These files are used for picking the starting (pre-upgrade) agent versions in upgrade integration tests.${nl}${nl}The content is based on responses from https://www.elastic.co/api/product_versions and https://snapshots.elastic.co${nl}${nl}The current update is generated based on the following requirements:${nl}${nl}Package version: ${package_version}${nl}${nl}\`\`\`json${nl}${version_requirements}${nl}\`\`\`"
Copy link
Member

@rdner rdner Sep 11, 2024

Choose a reason for hiding this comment

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

This is not entirely true, the upgrade tests run both directions and these versions are not used in just upgrade tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I see now that the versions from this file are not just used as starting versions in the upgrade test. For example, TestStandaloneUpgradeRetryDownload calls upgradetest.PreviousMinor() to set the end version and that function ends up looking at the versions from the file. So I will fix the text in this PR accordingly.

But I'm not seeing where the versions from this file are being used outside of upgrade tests. Could you point me to an example?

Copy link
Member

Choose a reason for hiding this comment

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

@ycombinator yes, I meant the usage of upgradetest.PreviousMinor() in other tests, there is a few of them https://github.com/search?q=repo%3Aelastic%2Felastic-agent%20upgradetest.PreviousMinor()&type=code

@swiatekm
Copy link
Contributor

Since this file is only used for tests, can we move it to the testing directory, and maybe change the name to be more indicative of the purpose? Say .upgrade-test-agent-versions.yaml? In general, it almost seems like an implementation detail of the upgradetest package, minus the fact that a mage target is used to update it (I assume that's why it's a separate file and not just some constants in Go code.).

@ycombinator
Copy link
Contributor Author

ycombinator commented Sep 12, 2024

Since this file is only used for tests, can we move it to the testing directory, and maybe change the name to be more indicative of the purpose? Say .upgrade-test-agent-versions.yaml? In general, it almost seems like an implementation detail of the upgradetest package, minus the fact that a mage target is used to update it (I assume that's why it's a separate file and not just some constants in Go code.).

I'm a +1 to this idea. The generic name of the file and it's current location has confused me in the past, which is part of the reason I raised this PR to switch to YAML so we could at least add comments in the file.

Other reviewers (@rdner @pchila @AndersonQ @blakerouse @cmacknz), any objections to this move? I'll make sure that everyone on the team is aware of it, in case they go looking for the file.

@pchila
Copy link
Member

pchila commented Sep 12, 2024

I'm a +1 to this idea. The generic name of the file and it's current location has confused me in the past, which is part of the reason I raised this PR to switch to YAML so we could at least add comments in the file.

Other reviewers (@rdner @pchila @AndersonQ @blakerouse @cmacknz), any objections to this move? I'll make sure that everyone on the team is aware of it, in case they go looking for the file.

If we are discussing moving files, .agent-versions should live under testing/integration/testdata (along with a good rename to make it explicit what it's for) since it's data for the upgrade tests to use.

In any case I am in favor of moving the file away from the repo root and/or renaming. 👍

@rdner
Copy link
Member

rdner commented Sep 12, 2024

I'm fine with moving the file. It might require changes in the automation code here https://github.com/elastic/elastic-agent/blob/main/.github/workflows/bump-agent-versions.sh

@rdner
Copy link
Member

rdner commented Sep 12, 2024

@ycombinator actually this script requires changes even for this original PR here

changes=$(git status -s -uno .agent-versions.json .package-version)

I missed that 🙂

@ycombinator
Copy link
Contributor Author

Based on the discussion, I've moved the .agent-versions file to testing/integration/testdata/.upgrade-test-agent-versions.yml and updated code to look at this new location and filename. Please re-review when you get a chance. Thanks!

@ycombinator ycombinator force-pushed the clarify-agent-version-automation branch from 51db753 to a47ffb2 Compare September 16, 2024 14:26
@@ -0,0 +1,12 @@
# This file is generated automatically. Please do not manually edit it.
Copy link
Member

Choose a reason for hiding this comment

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

We do manually edit this occasionally when we need to temporarily block a version because of a bug, but in general that is the exception.

@ycombinator ycombinator force-pushed the clarify-agent-version-automation branch from a47ffb2 to b196b17 Compare September 20, 2024 00:39
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@ycombinator ycombinator merged commit 2feeb36 into elastic:main Sep 20, 2024
13 checks passed
@ycombinator ycombinator deleted the clarify-agent-version-automation branch September 20, 2024 04:14
mergify bot pushed a commit that referenced this pull request Sep 20, 2024
* Clarify commit message

* Convert file to YML and add header comment

* Reintroducing rand/v2 import cleaned up by IDE

* Use YAML v3

* Replace .agent-versions.json with .agent-versions.yml

* Running mage fmt

* Adding a newline in the header comment

* Fix comment

* Fix commit message

* Look for changes in new file

* Moving + renaming agent versions file

* Updating code to refer to new file location + name

* Running mage integration:updateVersions

(cherry picked from commit 2feeb36)

# Conflicts:
#	.agent-versions.json
ycombinator added a commit that referenced this pull request Sep 20, 2024
* Clarify commit message

* Convert file to YML and add header comment

* Reintroducing rand/v2 import cleaned up by IDE

* Use YAML v3

* Replace .agent-versions.json with .agent-versions.yml

* Running mage fmt

* Adding a newline in the header comment

* Fix comment

* Fix commit message

* Look for changes in new file

* Moving + renaming agent versions file

* Updating code to refer to new file location + name

* Running mage integration:updateVersions

(cherry picked from commit 2feeb36)

# Conflicts:
#	.agent-versions.json
ycombinator added a commit that referenced this pull request Sep 20, 2024
* Clarify commit message

* Convert file to YML and add header comment

* Reintroducing rand/v2 import cleaned up by IDE

* Use YAML v3

* Replace .agent-versions.json with .agent-versions.yml

* Running mage fmt

* Adding a newline in the header comment

* Fix comment

* Fix commit message

* Look for changes in new file

* Moving + renaming agent versions file

* Updating code to refer to new file location + name

* Running mage integration:updateVersions

(cherry picked from commit 2feeb36)

# Conflicts:
#	.agent-versions.json

Co-authored-by: Shaunak Kashyap <[email protected]>
belimawr pushed a commit to belimawr/elastic-agent that referenced this pull request Sep 27, 2024
* Clarify commit message

* Convert file to YML and add header comment

* Reintroducing rand/v2 import cleaned up by IDE

* Use YAML v3

* Replace .agent-versions.json with .agent-versions.yml

* Running mage fmt

* Adding a newline in the header comment

* Fix comment

* Fix commit message

* Look for changes in new file

* Moving + renaming agent versions file

* Updating code to refer to new file location + name

* Running mage integration:updateVersions
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 Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants