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

Integration tests: Parse agent version from version.go #6611

Merged
merged 7 commits into from
Jan 30, 2025

Conversation

pazone
Copy link
Contributor

@pazone pazone commented Jan 27, 2025

What does this PR do?

The way how we defined the agent version for integration tests wasn't reliable. It works correctly on the main branch but might work incorrectly on 8.17. That blocks the backports to 8.17 and 8.16. The new approach parses version.go.

  • Modified integration test scripts
  • The regexes will be replaced and simplified when this issue is done

Why is it important?

Checklist

  • I have read and understood the pull request guidelines of this project.
  • 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

How to test this PR locally

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?
  • ...

@pazone pazone added enhancement New feature or request skip-changelog Team:Ingest-EngProd backport-8.x Automated backport to the 8.x branch with mergify labels Jan 27, 2025
@pazone pazone requested review from cmacknz and blakerouse January 27, 2025 14:48
@pazone pazone requested review from a team as code owners January 27, 2025 14:48
@mergify mergify bot assigned pazone Jan 27, 2025
@pazone pazone marked this pull request as draft January 28, 2025 09:58
@pazone pazone marked this pull request as ready for review January 28, 2025 20:46
@pazone pazone changed the title Integration tests: use the mage target to get agent version Integration tests: Parse agent version from version.go Jan 28, 2025
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

Comment on lines +33 to +37
# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925
AGENT_VERSION=$(grep "const defaultBeatVersion =" version/version.go | cut -d\" -f2)
AGENT_VERSION="${AGENT_VERSION}-SNAPSHOT"
export AGENT_VERSION
echo "~~~ Agent version: ${AGENT_VERSION}"
Copy link
Member

Choose a reason for hiding this comment

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

I see this in two places, do you mind moving this logic to a make goal or something else? Otherwise, it's hard to maintain.

For instance, the APM Server uses:

Therefore the call is as simple as this https://github.com/elastic/apm-server/blob/42e0cbf5b049a92b5536f34090b15f5eb0a7167e/.buildkite/scripts/dra.sh#L39

Copy link
Contributor Author

@pazone pazone Jan 29, 2025

Choose a reason for hiding this comment

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

What is the second place? If it's the PS file for Windows then unfortunately it's hard to avoid(Possible but the solution is controversial).
I also added a comment above(in the code). The mentioned issue will replace it with AGENT_VERSION=$(cat .agent-version).
I would like to ask you a QQ about your example if you don't mind. Wouldn't it be easier to create a similar .version file and embed it to the version.go? Then getting the version will be as simple as it mentioned above

Copy link
Member

Choose a reason for hiding this comment

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

What is the second place? If it's the PS file for Windows then unfortunately it's hard to avoid(Possible but the solution is controversial).

Yep

Wouldn't it be easier to create a similar .version file and embed it to the version.go?

I think so, thanks for bringing this to my attention, if there is a plan, then all good.

@pazone pazone merged commit cab384c into main Jan 30, 2025
14 checks passed
@pazone pazone deleted the ci_it_version_mage_target branch January 30, 2025 16:08
mergify bot pushed a commit that referenced this pull request Jan 30, 2025
* Integration tests: use the mage target to get agent version

* Added snapshot to version

* Test run

* Test run Windows

* Removed -v flag

* Parse agent version

* Cleanup

(cherry picked from commit cab384c)
@oakrizan oakrizan added backport-8.16 Automated backport with mergify backport-8.17 Automated backport with mergify labels Feb 10, 2025
mergify bot pushed a commit that referenced this pull request Feb 10, 2025
* Integration tests: use the mage target to get agent version

* Added snapshot to version

* Test run

* Test run Windows

* Removed -v flag

* Parse agent version

* Cleanup

(cherry picked from commit cab384c)

# Conflicts:
#	.buildkite/scripts/integration-tests.ps1
@oakrizan oakrizan added backport-8.17 Automated backport with mergify and removed backport-8.17 Automated backport with mergify labels Feb 11, 2025
@oakrizan
Copy link
Contributor

https://github.com/Mergifyio backport 8.17

Copy link
Contributor

mergify bot commented Feb 11, 2025

backport 8.17

✅ Backports have been created

  • Backport to branch 8.17 not needed, change already in branch 8.17

oakrizan added a commit that referenced this pull request Feb 11, 2025
…rsion.go (#6786)

* Integration tests: Parse agent version from version.go (#6611)
---------

Co-authored-by: Pavel Zorin <[email protected]>
Co-authored-by: Olga Naydyonock <[email protected]>
@v1v
Copy link
Member

v1v commented Feb 11, 2025

@pazone , I cannot find this backport in 9.0, can you confirm whether it's needed?

oakrizan added a commit that referenced this pull request Feb 13, 2025
* Integration tests: use the mage target to get agent version

(cherry picked from commit cab384c)

Co-authored-by: Pavel Zorin <[email protected]>
Co-authored-by: Olga Naydyonock <[email protected]>
@pazone pazone added the backport-9.0 Automated backport to the 9.0 branch label Feb 13, 2025
mergify bot pushed a commit that referenced this pull request Feb 13, 2025
* Integration tests: use the mage target to get agent version

* Added snapshot to version

* Test run

* Test run Windows

* Removed -v flag

* Parse agent version

* Cleanup

(cherry picked from commit cab384c)
oakrizan pushed a commit that referenced this pull request Feb 14, 2025
* Integration tests: use the mage target to get agent version

(cherry picked from commit cab384c)

Co-authored-by: Pavel Zorin <[email protected]>
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 backport-8.16 Automated backport with mergify backport-8.17 Automated backport with mergify backport-9.0 Automated backport to the 9.0 branch enhancement New feature or request skip-changelog Team:Ingest-EngProd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants