Commit 284ed39e authored by Douwe Maan's avatar Douwe Maan

Merge branch 'send-entry-via-Gitlab-Workhorse-Send-Data' into 'master'

Use Gitlab-Workhorse-Send-Data to send entry

## What does this MR do?

Use Gitlab-Workhorse-Send-Data to send entry:

Closes #19224, Closes #19128

Also requires this MR to work:
https://gitlab.com/gitlab-org/gitlab-workhorse/merge_requests/53

## Are there points in the code the reviewer needs to double check?

Do we have a test for this?

## Why was this MR needed?

This way gitlab-workhorse does not have to call any API.

See merge request !5094
parents 36c60b4c 1bfc2ed6
......@@ -23,10 +23,9 @@ class Projects::ArtifactsController < Projects::ApplicationController
entry = build.artifacts_metadata_entry(params[:path])
if entry.exists?
render json: { archive: build.artifacts_file.path,
entry: Base64.encode64(entry.path) }
send_artifacts_entry(build, entry)
else
render json: {}, status: 404
render_404
end
end
......
......@@ -28,4 +28,10 @@ module WorkhorseHelper
headers.store(*Gitlab::Workhorse.send_git_archive(repository, ref: ref, format: format))
head :ok
end
# Send an entry from artifacts through Workhorse
def send_artifacts_entry(build, entry)
headers.store(*Gitlab::Workhorse.send_artifacts_entry(build, entry))
head :ok
end
end
......@@ -68,10 +68,16 @@ class Spinach::Features::ProjectBuildsArtifacts < Spinach::FeatureSteps
end
step 'download of a file extracted from build artifacts should start' do
# this will be accelerated by Workhorse
response_json = JSON.parse(page.body, symbolize_names: true)
expect(response_json[:archive]).to end_with('build_artifacts.zip')
expect(response_json[:entry]).to eq Base64.encode64('ci_artifacts.txt')
send_data = response_headers[Gitlab::Workhorse::SEND_DATA_HEADER]
expect(send_data).to start_with('artifacts-entry:')
base64_params = send_data.sub(/\Aartifacts\-entry:/, '')
params = JSON.parse(Base64.urlsafe_decode64(base64_params))
expect(params.keys).to eq(['Archive', 'Entry'])
expect(params['Archive']).to end_with('build_artifacts.zip')
expect(params['Entry']).to eq(Base64.encode64('ci_artifacts.txt'))
end
step 'I click a first row within build artifacts table' do
......
......@@ -63,6 +63,18 @@ module Gitlab
]
end
def send_artifacts_entry(build, entry)
params = {
'Archive' => build.artifacts_file.path,
'Entry' => Base64.encode64(entry.path)
}
[
SEND_DATA_HEADER,
"artifacts-entry:#{encode(params)}"
]
end
protected
def encode(hash)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment