Skip to content

Commit

Permalink
Fix acceptance/packaging upgrade test near a release (#15826)
Browse files Browse the repository at this point in the history
The current mechanism of discovering the latest released version per
branch (via ARTIFACTS_API) isn't foolproof near the time of a new
release, as it may be pick a version that hasn't been released
yet. This leads to failures[^1] of the packaging upgrade tests, as we
attempt to download a package file that doesn't exist yet.

This commit switches to an API that that is more up to date regarding
the release version truth.

[^1]: https://buildkite.com/elastic/logstash-exhaustive-tests-pipeline/builds/125#018d319b-9a33-4306-b7f2-5b41937a8881/1033-1125
  • Loading branch information
dliappis authored Jan 22, 2024
1 parent c5cb1fe commit 15e19a9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions qa/acceptance/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,21 @@
# under the License.

require 'net/http'
require 'json'

ARTIFACTS_API = "https://artifacts-api.elastic.co/v1/versions"
ARTIFACT_VERSIONS_API = "https://storage.googleapis.com/artifacts-api/releases.properties"

def logstash_download_metadata(version, arch, artifact_type)
filename = "logstash-#{version}-#{arch}.#{artifact_type}"
{ url: "https://artifacts.elastic.co/downloads/logstash/#{filename}", dest: File.join(ROOT, 'qa', filename) }
end

def fetch_latest_logstash_release_version(branch)
uri = URI(ARTIFACTS_API)
uri = URI(ARTIFACT_VERSIONS_API)
major = branch.split('.').first

response = retryable_http_get(uri)
versions_data = JSON.parse(response)

filtered_versions = versions_data["versions"].select { |v| v.start_with?(branch) && !v.include?('SNAPSHOT') }

return filtered_versions.max_by { |v| Gem::Version.new(v) }
response.match(/current_#{major}=(\S+)/)&.captures&.first
end

def retryable_http_get(uri, max_retries=5, retry_wait=10)
Expand Down

0 comments on commit 15e19a9

Please sign in to comment.