-
Notifications
You must be signed in to change notification settings - Fork 160
Use a version file instead of artifact API in integration tests #4331
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
Conversation
This pull request does not have a backport label. Could you fix it @rdner? 🙏
NOTE: |
ea2b4b1
to
7950632
Compare
Now there is a new mage target `mage integrations:updateVersions` that requests a list of version from the artifact API according to the set requirements and creates a `.agent-versions.json` file in the root of the repository. This file is later used for running integration tests.
7950632
to
618f787
Compare
{ | ||
"testVersions": [ | ||
"8.14.0-SNAPSHOT", | ||
"8.13.0-SNAPSHOT", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is not real and it should be 8.13.0
instead. I replaced it for 2 reasons:
- The artifacts for 8.13.0 are not released yet, so the agent would fail to upgrade. We need to wait until it's released.
- I'd like to test the Github workflow I created, it should create a PR that replaces this line.
--label 'update-versions' \ | ||
--reviewer 'elastic/elastic-agent-control-plane' \ | ||
--repo $GITHUB_REPOSITORY | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this Github workflow using my fork repo as a target. Here is the example of a created PR rdner#4
I used the following environment variables:
GITHUB_RUN_ID=12347
GITHUB_REPOSITORY=rdner/elastic-agent
GITHUB_REF_NAME=versions-file-generator
and my personal access token with gh
.
|
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
I checked out this PR and generated the versions file: ❯ mage integration:updateVersions
~/go/src/github.com/elastic/elastic-agent versions-file-generator !1 ······················ 01:21:00 PM
❯ cat .agent-versions.json {
"testVersions": [
"8.14.0-SNAPSHOT",
"8.13.0",
"8.12.3",
"7.17.18"
]
} I have a few questions about the output:
|
If I change the agent version to 8.13.0 in this PR to simulate what it would do on the 8.13 branch I get: diff --git a/version/version.go b/version/version.go
index 7b092deae1..eefb327ba2 100644
--- a/version/version.go
+++ b/version/version.go
@@ -4,5 +4,5 @@
package version
-const defaultBeatVersion = "8.14.0"
+const defaultBeatVersion = "8.13.0"
const Agent = defaultBeatVersion
This has the same problem of including 8.12.3 which shouldn't exist. If this is supposed to be 8.12.3-SNAPSHOT then it seems more reasonable. |
// | ||
// Every version on the resulting list will meet the given requirements (by OR condition). | ||
// However, it's not guaranteed that the list contains the amount of versions per requirement. | ||
// For example, if only 2 previous minor versions exist but 5 requested, the list will have only 2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to return an error in this case? Requesting a specific number of versions is not a requirement if it is actually considered optional by the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cmacknz this is going to be a reply to your comments above too: #4331 (comment) and #4331 (comment)
Every time there is a different output from the mage target we're going to have a PR for a review (unless there is an existing one). So, there will be a CI build where we can see if the versions are used properly, it's up to us when to approve and merge those PRs manually.
The purpose of the generator is to create a file closest to our requirements, that we can review and approve.
We currently have all these issues too, we just don't see them, we don't even know what versions we're testing against in each run unless we check the detailed logs. This is the main problem this PR is solving.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also fine-tune the version requirements in a follow up later as we see the incoming automation PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few questions about the output:
Why do we list 8.13.0 instead of 8.13.0-SNAPSHOT? Because the build candidate exists?
Why do we list 8.12.3? The latest minor release is 8.12.2 and there is no planned 8.12.3 yet.
In both cases these versions are returned by the artifact API as released and there is no additional check whether the artifact exists on the CDN or not.
response
```json { "versions": [ "7.17.14", "7.17.15", "7.17.16", "7.17.17", "7.17.18-SNAPSHOT", "7.17.18", "7.17.19-SNAPSHOT", "8.10.0", "8.10.1", "8.10.2", "8.10.3", "8.10.4", "8.11.0", "8.11.1", "8.11.2", "8.11.3", "8.11.4", "8.12.0", "8.12.1-SNAPSHOT", "8.12.1", "8.12.2-SNAPSHOT", "8.12.2", "8.12.3-SNAPSHOT", "8.12.3", "8.13.0-SNAPSHOT", "8.13.0", "8.14.0-SNAPSHOT" ], "aliases": [ "7.17-SNAPSHOT", "7.17", "8.10", "8.11", "8.12-SNAPSHOT", "8.12", "8.13-SNAPSHOT", "8.13", "8.14-SNAPSHOT" ], "manifests": { "last-update-time": "Tue, 05 Mar 2024 13:33:02 UTC", "seconds-since-last-update": 161 } } ```There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK so an 8.12.3 artifact does exist. Looking into https://artifacts-staging.elastic.co/elastic-agent-package/8.12.3-511be3e7/manifest-8.12.3.json and tacking down the job that produced it TIL that Buildkite now does a daily staging build for example https://buildkite.com/elastic/unified-release-staging/builds/813.
So a staging build for the next release patch release will always exist, even if we are not planning to actually release it. This is just a slower version of the snapshot build so we would never want to test both this and a snapshot, we don't gain enough additional test coverage.
Every non-snapshot build return by the artifacts API is potentially an unreleased build candidate. I think we need a way to obviously tell official releases from build candidates when doing version selection. There are a few ways to do this:
- We could use https://www.elastic.co/api/product_versions which returns every available release
- We could try to download each version from artifacts.elastic.co to see if we get a 404.
- We could look at the available releases on the elastic-agent GitHub page as Paolo suggested earlier.
I think for upgrades we want to always test the two previous minor versions, using the official releases when they are available so we simulate what real users would be doing. So for main, 8.13, and 8.12 currently we'd want to test:
- main: 8.14.0-SNAPSHOT, 8.13.0-SNAPSHOT, 8.12.2, 7.17.18
- 8.13: 8.13.0-SNAPSHOT, 8.12.2 8.11.4, and 7.17.18
- 8.12: 8.12.3-SNAPSHOT, 8.11.4, 8.10.4, 7.17.18
I am admittedly a bit torn on whether we should just always test the latest snapshot (e.g 8.12.3-SNAPSHOT) for a given branch or use the most recent public release if it exists (e.g. 8.12.2). I am currently biased towards using the public release since that is what will happen in reality when a branch is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but wasn't the whole point of testing the latest snapshot to ensure upgrade isn't broken on the new version? Or we're covering that with that test which modifies the agent's package to simulate it's another version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two halves of the upgrade process to test:
- We need to make sure that previous releases can upgrade to the version we are about to release. Previous releases need to be able to find the agent executable so they can replace themselves with it and ensure the new watcher works properly. For this we want to test the two previous minors and 7.17.
- We need to make sure the version we are about to release can upgrade itself to another version. In practice it is a downgrade to a snapshot from the same version. This tests logic to download, extract, and replace the binary in the current version.
"testVersions": [ | ||
"8.14.0-SNAPSHOT", | ||
"8.13.0-SNAPSHOT", | ||
"8.12.2", | ||
"7.17.18" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: are we gonna distinguish the snapshot from the release versions we want to use in each test by the suffix ?
Why not creating 2 separate lists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see any functional difference of having a separate list. This is how the list was formed before my PR and I'd like to integrate this feature without changing the interface and how our tests work. This basically replaces what GetUpgradableVersions
function returned.
This pull request is now in conflicts. Could you fix it? 🙏
|
To solve these problems maybe we can get the released versions from the github releases of agent and beats (for 7.X) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for a first iteration, we can always refine it later as needed.
All the outstanding comments on my side are non-blocking
logger logger | ||
c httpDoer | ||
url string | ||
logFunc logFunc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change to make this PR work (conflict resolution), refactoring of the artifact client is not the goal of this PR. We can follow up on this while working on #4354
|
What does this PR do?
Now there is a new mage target
mage integrations:updateVersions
that requests a list of version from the artifactAPI according to the set requirements and creates a
.agent-versions.json
file in the root of the repository.This file is later used for running integration tests.
Why is it important?
This will make our integration tests more stable and deterministic.
Checklist
- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration files- [ ] I have added an entry in./changelog/fragments
using the changelog tool- [ ] I have added an integration test or an E2E testHow to test this PR locally
Related issues