gitlab-org--gitlab-foss/spec/requests/api/jobs_spec.rb

1026 lines
33 KiB
Ruby
Raw Normal View History

2015-12-29 17:12:36 -05:00
require 'spec_helper'
describe API::Jobs do
include HttpIOHelpers
2018-07-18 17:46:56 -04:00
shared_examples 'a job with artifacts and trace' do |result_is_array: true|
context 'with artifacts and trace' do
let!(:second_job) { create(:ci_build, :trace_artifact, :artifacts, :test_reports, pipeline: pipeline) }
it 'returns artifacts and trace data', :skip_before_request do
get api(api_endpoint, api_user)
json_job = result_is_array ? json_response.select { |job| job['id'] == second_job.id }.first : json_response
expect(json_job['artifacts_file']).not_to be_nil
expect(json_job['artifacts_file']).not_to be_empty
expect(json_job['artifacts_file']['filename']).to eq(second_job.artifacts_file.filename)
expect(json_job['artifacts_file']['size']).to eq(second_job.artifacts_file.size)
expect(json_job['artifacts']).not_to be_nil
expect(json_job['artifacts']).to be_an Array
expect(json_job['artifacts'].size).to eq(second_job.job_artifacts.length)
json_job['artifacts'].each do |artifact|
expect(artifact).not_to be_nil
file_type = Ci::JobArtifact.file_types[artifact['file_type']]
expect(artifact['size']).to eq(second_job.job_artifacts.where(file_type: file_type).first.size)
expect(artifact['filename']).to eq(second_job.job_artifacts.where(file_type: file_type).first.filename)
expect(artifact['file_format']).to eq(second_job.job_artifacts.where(file_type: file_type).first.file_format)
end
end
end
end
set(:project) do
create(:project, :repository, public_builds: false)
end
set(:pipeline) do
create(:ci_empty_pipeline, project: project,
sha: project.commit.id,
ref: project.default_branch)
end
let!(:job) do
create(:ci_build, :success, pipeline: pipeline,
artifacts_expire_at: 1.day.since)
end
2015-12-29 17:12:36 -05:00
let(:user) { create(:user) }
2016-02-19 12:06:53 -05:00
let(:api_user) { user }
let(:reporter) { create(:project_member, :reporter, project: project).user }
let(:guest) { create(:project_member, :guest, project: project).user }
before do
project.add_developer(user)
end
2015-12-29 17:12:36 -05:00
describe 'GET /projects/:id/jobs' do
let(:query) { Hash.new }
2016-02-19 12:06:53 -05:00
2018-01-14 17:11:38 -05:00
before do |example|
unless example.metadata[:skip_before_request]
get api("/projects/#{project.id}/jobs", api_user), params: query
2018-01-14 17:11:38 -05:00
end
2016-07-14 12:53:27 -04:00
end
2016-02-19 12:06:53 -05:00
2015-12-29 17:12:36 -05:00
context 'authorized user' do
it 'returns project jobs' do
expect(response).to have_gitlab_http_status(200)
2017-01-24 15:49:10 -05:00
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
end
it 'returns correct values' do
expect(json_response).not_to be_empty
expect(json_response.first['commit']['id']).to eq project.commit.id
expect(Time.parse(json_response.first['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
end
2018-07-18 17:46:56 -04:00
context 'without artifacts and trace' do
it 'returns no artifacts nor trace data' do
json_job = json_response.first
expect(json_job['artifacts_file']).to be_nil
expect(json_job['artifacts']).to be_an Array
expect(json_job['artifacts']).to be_empty
end
end
it_behaves_like 'a job with artifacts and trace' do
let(:api_endpoint) { "/projects/#{project.id}/jobs" }
end
it 'returns pipeline data' do
json_job = json_response.first
expect(json_job['pipeline']).not_to be_empty
expect(json_job['pipeline']['id']).to eq job.pipeline.id
expect(json_job['pipeline']['ref']).to eq job.pipeline.ref
expect(json_job['pipeline']['sha']).to eq job.pipeline.sha
expect(json_job['pipeline']['status']).to eq job.pipeline.status
end
it 'avoids N+1 queries', :skip_before_request do
2018-07-18 17:46:56 -04:00
first_build = create(:ci_build, :trace_artifact, :artifacts, :test_reports, pipeline: pipeline)
2018-01-15 11:58:56 -05:00
first_build.runner = create(:ci_runner)
first_build.user = create(:user)
first_build.save
2018-01-14 17:11:38 -05:00
control_count = ActiveRecord::QueryRecorder.new { go }.count
2018-01-15 11:58:56 -05:00
second_pipeline = create(:ci_empty_pipeline, project: project, sha: project.commit.id, ref: project.default_branch)
2018-07-18 17:46:56 -04:00
second_build = create(:ci_build, :trace_artifact, :artifacts, :test_reports, pipeline: second_pipeline)
2018-01-15 11:58:56 -05:00
second_build.runner = create(:ci_runner)
second_build.user = create(:user)
second_build.save
2018-01-14 17:11:38 -05:00
expect { go }.not_to exceed_query_limit(control_count)
end
2016-02-19 12:06:53 -05:00
context 'filter project with one scope element' do
let(:query) { { 'scope' => 'pending' } }
2016-02-19 12:06:53 -05:00
it do
expect(response).to have_gitlab_http_status(200)
2016-02-19 12:06:53 -05:00
expect(json_response).to be_an Array
end
end
2016-02-19 12:06:53 -05:00
context 'filter project with array of scope elements' do
let(:query) { { scope: %w(pending running) } }
2016-02-19 12:06:53 -05:00
it do
expect(response).to have_gitlab_http_status(200)
2016-02-19 12:06:53 -05:00
expect(json_response).to be_an Array
end
2015-12-29 17:12:36 -05:00
end
2016-01-13 09:17:59 -05:00
2016-02-19 12:06:53 -05:00
context 'respond 400 when scope contains invalid state' do
let(:query) { { scope: %w(unknown running) } }
2016-01-13 09:17:59 -05:00
it { expect(response).to have_gitlab_http_status(400) }
2016-01-13 09:17:59 -05:00
end
2015-12-29 17:12:36 -05:00
end
context 'unauthorized user' do
context 'when user is not logged in' do
let(:api_user) { nil }
2015-12-29 17:12:36 -05:00
it 'does not return project jobs' do
expect(response).to have_gitlab_http_status(401)
end
end
context 'when user is guest' do
let(:api_user) { guest }
it 'does not return project jobs' do
expect(response).to have_gitlab_http_status(403)
end
2015-12-29 17:12:36 -05:00
end
end
2018-01-15 12:06:26 -05:00
2018-01-14 17:11:38 -05:00
def go
get api("/projects/#{project.id}/jobs", api_user), params: query
2018-01-14 17:11:38 -05:00
end
2015-12-29 17:12:36 -05:00
end
describe 'GET /projects/:id/pipelines/:pipeline_id/jobs' do
let(:query) { Hash.new }
2018-07-18 17:46:56 -04:00
before do |example|
unless example.metadata[:skip_before_request]
job
get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query
2018-07-18 17:46:56 -04:00
end
end
context 'authorized user' do
it 'returns pipeline jobs' do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
end
it 'returns correct values' do
expect(json_response).not_to be_empty
expect(json_response.first['commit']['id']).to eq project.commit.id
expect(Time.parse(json_response.first['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
2018-07-18 17:46:56 -04:00
expect(json_response.first['artifacts_file']).to be_nil
expect(json_response.first['artifacts']).to be_an Array
expect(json_response.first['artifacts']).to be_empty
end
it_behaves_like 'a job with artifacts and trace' do
let(:api_endpoint) { "/projects/#{project.id}/pipelines/#{pipeline.id}/jobs" }
end
it 'returns pipeline data' do
json_job = json_response.first
expect(json_job['pipeline']).not_to be_empty
expect(json_job['pipeline']['id']).to eq job.pipeline.id
expect(json_job['pipeline']['ref']).to eq job.pipeline.ref
expect(json_job['pipeline']['sha']).to eq job.pipeline.sha
expect(json_job['pipeline']['status']).to eq job.pipeline.status
end
context 'filter jobs with one scope element' do
let(:query) { { 'scope' => 'pending' } }
it do
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
end
end
context 'filter jobs with array of scope elements' do
let(:query) { { scope: %w(pending running) } }
it do
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
end
end
context 'respond 400 when scope contains invalid state' do
let(:query) { { scope: %w(unknown running) } }
it { expect(response).to have_gitlab_http_status(400) }
end
context 'jobs in different pipelines' do
let!(:pipeline2) { create(:ci_empty_pipeline, project: project) }
let!(:job2) { create(:ci_build, pipeline: pipeline2) }
it 'excludes jobs from other pipelines' do
json_response.each { |job| expect(job['pipeline']['id']).to eq(pipeline.id) }
end
end
it 'avoids N+1 queries' do
control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query
end.count
2018-07-18 17:46:56 -04:00
3.times { create(:ci_build, :trace_artifact, :artifacts, :test_reports, pipeline: pipeline) }
expect do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query
end.not_to exceed_all_query_limit(control_count)
end
end
context 'unauthorized user' do
context 'when user is not logged in' do
let(:api_user) { nil }
it 'does not return jobs' do
expect(response).to have_gitlab_http_status(401)
end
end
context 'when user is guest' do
let(:api_user) { guest }
it 'does not return jobs' do
expect(response).to have_gitlab_http_status(403)
end
end
end
end
describe 'GET /projects/:id/jobs/:job_id' do
2018-07-18 17:46:56 -04:00
before do |example|
unless example.metadata[:skip_before_request]
get api("/projects/#{project.id}/jobs/#{job.id}", api_user)
end
2016-07-14 12:53:27 -04:00
end
2016-02-19 12:06:53 -05:00
context 'authorized user' do
it 'returns specific job data' do
expect(response).to have_gitlab_http_status(200)
expect(json_response['id']).to eq(job.id)
expect(json_response['status']).to eq(job.status)
expect(json_response['stage']).to eq(job.stage)
expect(json_response['name']).to eq(job.name)
expect(json_response['ref']).to eq(job.ref)
expect(json_response['tag']).to eq(job.tag)
expect(json_response['coverage']).to eq(job.coverage)
expect(Time.parse(json_response['created_at'])).to be_like_time(job.created_at)
expect(Time.parse(json_response['started_at'])).to be_like_time(job.started_at)
expect(Time.parse(json_response['finished_at'])).to be_like_time(job.finished_at)
expect(Time.parse(json_response['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
2018-07-18 17:46:56 -04:00
expect(json_response['artifacts_file']).to be_nil
expect(json_response['artifacts']).to be_an Array
expect(json_response['artifacts']).to be_empty
expect(json_response['duration']).to eq(job.duration)
expect(json_response['web_url']).to be_present
end
2018-07-18 17:46:56 -04:00
it_behaves_like 'a job with artifacts and trace', result_is_array: false do
let(:api_endpoint) { "/projects/#{project.id}/jobs/#{second_job.id}" }
end
it 'returns pipeline data' do
json_job = json_response
expect(json_job['pipeline']).not_to be_empty
expect(json_job['pipeline']['id']).to eq job.pipeline.id
expect(json_job['pipeline']['ref']).to eq job.pipeline.ref
expect(json_job['pipeline']['sha']).to eq job.pipeline.sha
expect(json_job['pipeline']['status']).to eq job.pipeline.status
end
end
context 'unauthorized user' do
2016-02-19 12:06:53 -05:00
let(:api_user) { nil }
it 'does not return specific job data' do
expect(response).to have_gitlab_http_status(401)
end
end
end
describe 'DELETE /projects/:id/jobs/:job_id/artifacts' do
let!(:job) { create(:ci_build, :artifacts, pipeline: pipeline, user: api_user) }
before do
delete api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
end
context 'when user is anonymous' do
let(:api_user) { nil }
it 'does not delete artifacts' do
expect(job.job_artifacts.size).to eq 2
end
it 'returns status 401 (unauthorized)' do
expect(response).to have_http_status :unauthorized
end
end
context 'with developer' do
it 'does not delete artifacts' do
expect(job.job_artifacts.size).to eq 2
end
it 'returns status 403 (forbidden)' do
expect(response).to have_http_status :forbidden
end
end
context 'with authorized user' do
let(:maintainer) { create(:project_member, :maintainer, project: project).user }
let!(:api_user) { maintainer }
it 'deletes artifacts' do
expect(job.job_artifacts.size).to eq 0
end
it 'returns status 204 (no content)' do
expect(response).to have_http_status :no_content
end
end
end
describe 'GET /projects/:id/jobs/:job_id/artifacts/:artifact_path' do
context 'when job has artifacts' do
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
let(:artifact) do
'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
end
context 'when user is anonymous' do
let(:api_user) { nil }
context 'when project is public' do
it 'allows to access artifacts' do
project.update_column(:visibility_level,
Gitlab::VisibilityLevel::PUBLIC)
project.update_column(:public_builds, true)
get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(200)
end
end
context 'when project is public with builds access disabled' do
it 'rejects access to artifacts' do
project.update_column(:visibility_level,
Gitlab::VisibilityLevel::PUBLIC)
project.update_column(:public_builds, false)
get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(403)
end
end
context 'when project is private' do
it 'rejects access and hides existence of artifacts' do
project.update_column(:visibility_level,
Gitlab::VisibilityLevel::PRIVATE)
project.update_column(:public_builds, true)
get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(404)
end
end
end
context 'when user is authorized' do
it 'returns a specific artifact file for a valid path' do
expect(Gitlab::Workhorse)
.to receive(:send_artifacts_entry)
.and_call_original
get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(200)
expect(response.headers.to_h)
.to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
end
end
end
context 'when job does not have artifacts' do
it 'does not return job artifact file' do
get_artifact_file('some/artifact')
expect(response).to have_gitlab_http_status(404)
end
end
def get_artifact_file(artifact_path)
get api("/projects/#{project.id}/jobs/#{job.id}/" \
"artifacts/#{artifact_path}", api_user)
end
end
describe 'GET /projects/:id/jobs/:job_id/artifacts' do
2018-03-06 16:19:24 -05:00
shared_examples 'downloads artifact' do
let(:download_headers) do
{ 'Content-Transfer-Encoding' => 'binary',
'Content-Disposition' => %q(attachment; filename="ci_build_artifacts.zip"; filename*=UTF-8''ci_build_artifacts.zip) }
2018-03-06 16:19:24 -05:00
end
it 'returns specific job artifacts' do
expect(response).to have_gitlab_http_status(200)
expect(response.headers.to_h).to include(download_headers)
2018-03-06 16:19:24 -05:00
expect(response.body).to match_file(job.artifacts_file.file.file)
end
end
context 'normal authentication' do
context 'job with artifacts' do
context 'when artifacts are stored locally' do
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
before do
get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
end
context 'authorized user' do
it_behaves_like 'downloads artifact'
end
2018-03-07 13:27:49 -05:00
context 'unauthorized user' do
let(:api_user) { nil }
it 'does not return specific job artifacts' do
expect(response).to have_gitlab_http_status(404)
end
end
2016-02-19 12:06:53 -05:00
end
context 'when artifacts are stored remotely' do
2018-03-09 10:09:00 -05:00
let(:proxy_download) { false }
2018-03-07 13:27:49 -05:00
before do
2018-03-09 10:09:00 -05:00
stub_artifacts_object_storage(proxy_download: proxy_download)
2018-03-07 13:27:49 -05:00
end
let(:job) { create(:ci_build, pipeline: pipeline) }
let!(:artifact) { create(:ci_job_artifact, :archive, :remote_store, job: job) }
before do
job.reload
get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
end
2018-03-09 10:09:00 -05:00
context 'when proxy download is enabled' do
let(:proxy_download) { true }
it 'responds with the workhorse send-url' do
expect(response.headers[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("send-url:")
end
end
context 'when proxy download is disabled' do
it 'returns location redirect' do
expect(response).to have_gitlab_http_status(302)
end
end
2018-03-07 13:27:49 -05:00
context 'authorized user' do
it 'returns the file remote URL' do
expect(response).to redirect_to(artifact.file.url)
end
end
context 'unauthorized user' do
let(:api_user) { nil }
it 'does not return specific job artifacts' do
expect(response).to have_gitlab_http_status(404)
end
end
2016-02-19 12:06:53 -05:00
end
it 'does not return job artifacts if not uploaded' do
get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
2018-03-07 13:27:49 -05:00
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
describe 'GET /projects/:id/artifacts/:ref_name/download?job=name' do
let(:api_user) { reporter }
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline, user: api_user) }
before do
2018-03-07 13:27:49 -05:00
stub_artifacts_object_storage
job.success
end
2016-07-14 13:07:41 -04:00
def get_for_ref(ref = pipeline.ref, job_name = job.name)
get api("/projects/#{project.id}/jobs/artifacts/#{ref}/download", api_user), params: { job: job_name }
2016-07-14 13:07:41 -04:00
end
context 'when not logged in' do
2016-07-19 13:24:59 -04:00
let(:api_user) { nil }
2016-07-14 13:07:41 -04:00
before do
get_for_ref
2016-07-14 13:07:41 -04:00
end
it 'does not find a resource in a private project' do
expect(project).to be_private
expect(response).to have_gitlab_http_status(404)
2016-07-14 13:07:41 -04:00
end
end
context 'when logging as guest' do
let(:api_user) { guest }
before do
get_for_ref
end
it 'gives 403' do
expect(response).to have_gitlab_http_status(403)
end
end
context 'non-existing job' do
shared_examples 'not found' do
it { expect(response).to have_gitlab_http_status(:not_found) }
2016-07-14 13:07:41 -04:00
end
context 'has no such ref' do
before do
get_for_ref('TAIL')
end
it_behaves_like 'not found'
end
context 'has no such job' do
before do
get_for_ref(pipeline.ref, 'NOBUILD')
end
it_behaves_like 'not found'
end
2016-07-14 13:07:41 -04:00
end
context 'find proper job' do
shared_examples 'a valid file' do
context 'when artifacts are stored locally' do
let(:download_headers) do
{ 'Content-Transfer-Encoding' => 'binary',
'Content-Disposition' =>
%Q(attachment; filename="#{job.artifacts_file.filename}"; filename*=UTF-8''#{job.artifacts_file.filename}) }
end
2018-03-07 13:27:49 -05:00
it { expect(response).to have_http_status(:ok) }
it { expect(response.headers.to_h).to include(download_headers) }
end
2016-07-14 13:07:41 -04:00
context 'when artifacts are stored remotely' do
let(:job) { create(:ci_build, pipeline: pipeline, user: api_user) }
let!(:artifact) { create(:ci_job_artifact, :archive, :remote_store, job: job) }
before do
job.reload
get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
end
it 'returns location redirect' do
2018-03-07 13:27:49 -05:00
expect(response).to have_http_status(:found)
end
end
end
context 'with regular branch' do
before do
2016-10-26 05:34:40 -04:00
pipeline.reload
pipeline.update(ref: 'master',
sha: project.commit('master').sha)
get_for_ref('master')
end
it_behaves_like 'a valid file'
2016-07-14 13:07:41 -04:00
end
context 'with branch name containing slash' do
before do
2016-10-26 05:34:40 -04:00
pipeline.reload
pipeline.update(ref: 'improve/awesome',
sha: project.commit('improve/awesome').sha)
end
before do
get_for_ref('improve/awesome')
end
it_behaves_like 'a valid file'
end
2016-07-14 13:07:41 -04:00
end
end
describe 'GET id/jobs/artifacts/:ref_name/raw/*artifact_path?job=name' do
context 'when job has artifacts' do
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline, user: api_user) }
let(:artifact) { 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' }
let(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC }
let(:public_builds) { true }
before do
stub_artifacts_object_storage
job.success
project.update(visibility_level: visibility_level,
public_builds: public_builds)
get_artifact_file(artifact)
end
context 'when user is anonymous' do
let(:api_user) { nil }
context 'when project is public' do
let(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC }
let(:public_builds) { true }
it 'allows to access artifacts' do
expect(response).to have_gitlab_http_status(200)
expect(response.headers.to_h)
.to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
end
end
context 'when project is public with builds access disabled' do
let(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC }
let(:public_builds) { false }
it 'rejects access to artifacts' do
expect(response).to have_gitlab_http_status(403)
expect(json_response).to have_key('message')
expect(response.headers.to_h)
.not_to include('Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
end
end
context 'when project is private' do
let(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE }
let(:public_builds) { true }
it 'rejects access and hides existence of artifacts' do
expect(response).to have_gitlab_http_status(404)
expect(json_response).to have_key('message')
expect(response.headers.to_h)
.not_to include('Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
end
end
end
context 'when user is authorized' do
let(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE }
let(:public_builds) { true }
it 'returns a specific artifact file for a valid path' do
expect(Gitlab::Workhorse)
.to receive(:send_artifacts_entry)
.and_call_original
get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(200)
expect(response.headers.to_h)
.to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
end
end
context 'with branch name containing slash' do
before do
pipeline.reload
pipeline.update(ref: 'improve/awesome',
sha: project.commit('improve/awesome').sha)
end
it 'returns a specific artifact file for a valid path' do
get_artifact_file(artifact, 'improve/awesome')
expect(response).to have_gitlab_http_status(200)
expect(response.headers.to_h)
.to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
end
end
context 'non-existing job' do
shared_examples 'not found' do
it { expect(response).to have_gitlab_http_status(:not_found) }
end
context 'has no such ref' do
before do
get_artifact_file('some/artifact', 'wrong-ref')
end
it_behaves_like 'not found'
end
context 'has no such job' do
before do
get_artifact_file('some/artifact', pipeline.ref, 'wrong-job-name')
end
it_behaves_like 'not found'
end
end
end
context 'when job does not have artifacts' do
let(:job) { create(:ci_build, pipeline: pipeline, user: api_user) }
it 'does not return job artifact file' do
get_artifact_file('some/artifact')
expect(response).to have_gitlab_http_status(404)
end
end
def get_artifact_file(artifact_path, ref = pipeline.ref, job_name = job.name)
get api("/projects/#{project.id}/jobs/artifacts/#{ref}/raw/#{artifact_path}", api_user), params: { job: job_name }
end
end
describe 'GET /projects/:id/jobs/:job_id/trace' do
2016-07-14 12:53:27 -04:00
before do
get api("/projects/#{project.id}/jobs/#{job.id}/trace", api_user)
2016-07-14 12:53:27 -04:00
end
2016-02-19 12:06:53 -05:00
context 'authorized user' do
context 'when trace is in ObjectStorage' do
let!(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) }
let(:url) { 'http://object-storage/trace' }
2018-07-09 12:13:34 -04:00
let(:file_path) { expand_fixture_path('trace/sample_trace') }
before do
stub_remote_url_206(url, file_path)
allow_any_instance_of(JobArtifactUploader).to receive(:file_storage?) { false }
allow_any_instance_of(JobArtifactUploader).to receive(:url) { url }
2018-07-09 12:13:34 -04:00
allow_any_instance_of(JobArtifactUploader).to receive(:size) { File.size(file_path) }
end
it 'returns specific job trace' do
expect(response).to have_gitlab_http_status(200)
expect(response.body).to eq(job.trace.raw)
end
end
context 'when trace is artifact' do
let(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) }
it 'returns specific job trace' do
expect(response).to have_gitlab_http_status(200)
expect(response.body).to eq(job.trace.raw)
end
end
context 'when trace is file' do
let(:job) { create(:ci_build, :trace_live, pipeline: pipeline) }
it 'returns specific job trace' do
expect(response).to have_gitlab_http_status(200)
expect(response.body).to eq(job.trace.raw)
end
end
end
context 'unauthorized user' do
2016-02-19 12:06:53 -05:00
let(:api_user) { nil }
it 'does not return specific job trace' do
expect(response).to have_gitlab_http_status(401)
end
end
end
describe 'POST /projects/:id/jobs/:job_id/cancel' do
2016-07-14 12:53:27 -04:00
before do
post api("/projects/#{project.id}/jobs/#{job.id}/cancel", api_user)
2016-07-14 12:53:27 -04:00
end
2016-02-19 12:06:53 -05:00
context 'authorized user' do
context 'user with :update_build persmission' do
it 'cancels running or pending job' do
expect(response).to have_gitlab_http_status(201)
2017-12-21 12:21:27 -05:00
expect(project.builds.first.status).to eq('success')
end
end
context 'user without :update_build permission' do
let(:api_user) { reporter }
it 'does not cancel job' do
expect(response).to have_gitlab_http_status(403)
end
end
end
context 'unauthorized user' do
2016-02-19 12:06:53 -05:00
let(:api_user) { nil }
it 'does not cancel job' do
expect(response).to have_gitlab_http_status(401)
end
end
end
describe 'POST /projects/:id/jobs/:job_id/retry' do
let(:job) { create(:ci_build, :failed, pipeline: pipeline) }
2016-02-19 12:06:53 -05:00
2016-07-14 12:53:27 -04:00
before do
post api("/projects/#{project.id}/jobs/#{job.id}/retry", api_user)
2016-07-14 12:53:27 -04:00
end
2016-02-19 12:06:53 -05:00
context 'authorized user' do
2016-02-19 12:06:53 -05:00
context 'user with :update_build permission' do
it 'retries non-running job' do
expect(response).to have_gitlab_http_status(201)
expect(project.builds.first.status).to eq('failed')
expect(json_response['status']).to eq('pending')
end
end
context 'user without :update_build permission' do
let(:api_user) { reporter }
it 'does not retry job' do
expect(response).to have_gitlab_http_status(403)
end
end
end
context 'unauthorized user' do
2016-02-19 12:06:53 -05:00
let(:api_user) { nil }
it 'does not retry job' do
expect(response).to have_gitlab_http_status(401)
end
end
end
describe 'POST /projects/:id/jobs/:job_id/erase' do
let(:role) { :maintainer }
2017-11-07 08:45:55 -05:00
before do
project.add_role(user, role)
post api("/projects/#{project.id}/jobs/#{job.id}/erase", user)
end
context 'job is erasable' do
Squashed commit of the following: commit c35ca6594eb1d29cac46362d09036f3d128143ed Merge: 87da74fb98a 13ea4b387dd Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 27 13:25:22 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit 87da74fb98aef1f664553ca2b8406ca154e4c19f Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 20:27:45 2018 +0900 Remove unncessary GENERAL_ARCHIVE_FILE_TYPE commit 5a3cfc1fdc8e81dd5647e275f87c0da2d93235b4 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 20:19:44 2018 +0900 Expand entities in JobRequest::Artifacts commit 660f885ebb25a19182e601181050683d2b6134f6 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 20:06:14 2018 +0900 Add tests commit 60bca3dcfd055647a9f43523b79d5eebdc4bdc5a Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 19:30:52 2018 +0900 Simplify build runner presenter commit 81d1951d5562bec4086d719748360f3f24df4168 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 19:18:53 2018 +0900 Simplify `scope :test_reports` in job_artifacts commit 15d1d76ca1cb97501c82471eb1c927290071dcfb Merge: f3327b2912d ffbfd18ce2f Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 19:01:53 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit f3327b2912d0b169e7a059dca7b4d15e77567075 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 19:01:44 2018 +0900 Fix "or string" to "or a string". Use be_valid commit 9aaae6d60f7537f55f862f4d61de7a0d3a3b6bc2 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 21:25:57 2018 +0900 Fix spec file name - build_runner_presenter_spec.rb commit 41c64c190e2e2efa7ab91a0daa0598da2d755f05 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 21:18:12 2018 +0900 Rename to Ci::BuildRunnerPresenter commit e9762299eb66c8f88734f80d05d38b9616a8fde8 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 21:14:44 2018 +0900 Split methods into three in Ci::Builds::RunnerPresenter commit 6e73070313a782eb63d4fbcbe324d9acaf67334b Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 20:23:53 2018 +0900 Remove redandant as: :artifacts commit 063f647e4829d9c71a71d227f9946bb47b93691f Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 20:04:58 2018 +0900 Fix specs commit a45975afd9b9391390c1adafbeab72c970e97b64 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 18:18:53 2018 +0900 Created a separate presenter commit 431ad666e080124c90e13cbaf0d4f0969aa7b2f2 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 18:10:04 2018 +0900 Simplified config presenter commit 2e106569ea258f5f7556a8b454a6dd0e9cbe6902 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 17:25:05 2018 +0900 Skip file_format setting if the file_type is trace commit 0572bd8357a2e9ea16118a0bd85264e3fb799322 Merge: 30ae33daa1d 6cb30f83255 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 17:13:55 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit 30ae33daa1d4afcb57e6335fba62a3c5fc98468a Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 17:13:23 2018 +0900 Fix spec commit ccb6eb75187030ff0fd3c6e69f89eeca79d2a929 Merge: 1ebaaaf2094 34c57e09b9f Author: Shinya Maeda <shinya@gitlab.com> Date: Tue Jul 24 14:27:48 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit 1ebaaaf2094c47c03e16745d2f8af736ec102b76 Merge: bfdf565800b dc7b4b7bb97 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 23 14:22:29 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit bfdf565800b58e838a760aa01d2fadb64e2d768f Merge: 681bd6a878a 44dbeccbe10 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 19:10:47 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit 681bd6a878ad2a77c278f5619b51c542d7382aa2 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 18:19:46 2018 +0900 Specify DOWNTIME=false commit 59c4e31390e0d616d69babf8ac857e98f2dc774e Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 18:14:44 2018 +0900 Wrap long lines commit 3d85788edbe73fc74c72854508e47fe259d99236 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 18:05:31 2018 +0900 Checking filr_format and file_type paring commit 3c92a22faf6278e7a2d1ee13bd978bc659b72452 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 16:07:21 2018 +0900 Fix build presenter spec commit 36e69897b0524cdee6060c928c03af734afae664 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 16:02:09 2018 +0900 Erase test reports at the proper timing commit 402ae97ecf7f9e3fe541f2d6abef6e47ab740452 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 15:46:56 2018 +0900 Make GENERAL_ARCHIVE_FILE_TYPE as a single entry commit 75f75b3f5988398fff0660ca5f04aec756ab03bb Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 15:42:16 2018 +0900 Implement config artifact presenter commit 9ecaee914defba5f12a7a06375ea2876b4328d7f Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 14:27:54 2018 +0900 Introduce ARCHIVE_LEGACY_TRACES_MIGRATION_VERSION check commit 34ea9610ab9a249a576ee435f365b9e1fcca7f00 Merge: d88523ca884 b60364c0f37 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 13:46:52 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit d88523ca88420354f61bd36f533c62a6ca474423 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 21:00:40 2018 +0900 Revert unnecessary change commit d9beb10ede5e4e8abe388fadbd6412640293917a Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 20:57:03 2018 +0900 Remove scattering around erase_test_reports! commit c79f361ca01f8dbc0d395edee5fab7f5a0697934 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 20:53:00 2018 +0900 Rever archive_metadata refactoring (For simplifying) commit 55bc71a404d8cf5fa87e187f6e88da92ab95afa9 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 20:45:19 2018 +0900 Use array_of_strings_or_string in Command commit 8a576b18c8ab8ead2344e2885aaf2fde11af0328 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 20:40:06 2018 +0900 Fix spec commit a2cda62fb922184aaf0e78699e06846c96565e0d Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 18:27:11 2018 +0900 Fix presenter spec commit 95502e605af9bcf1a61dbeb26f9be4d181f8a7ba Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 18:23:41 2018 +0900 Fix artifact migratable commit a3930853c93862007ba6814511bc32042c7f4986 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 18:15:41 2018 +0900 Increment migration version to use `file_format` when archiving traces commit e31121cb5e617b0f05e375c2150ece0e38e5e0d6 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 17:57:15 2018 +0900 Impolement job_artifact.test_reports method commit e54707fdf97392839cb2c4711160bd3bc89da196 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 16:49:27 2018 +0900 Fix erase method commit 20e95824341af1ebc5877d28dc5eba26f73eddf9 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 16:28:00 2018 +0900 Fix spec commit 7ade498101d02573b20a2405ebe0bdb8efd8aa3b Merge: e7be6b2b362 98eccfc44c5 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 12:37:22 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit e7be6b2b3624ba44d56143084731cb9a6168f974 Merge: 5a8d4930e01 9bdc9b1ae69 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 18 15:43:36 2018 +0900 Merge branch 'master' into artifact-format-v2 commit 5a8d4930e0127aae311bfa3da70d9ab9637791e3 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 18 15:43:28 2018 +0900 Evaluate artifact_format commit c3ce06aa9bc6481b37a16d175adf0fd1c37a1bc0 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 22:27:46 2018 +0900 Fix sending junit.xml commit e5ce3668ee65217aba610d5311efd5e82bacddf3 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 19:02:06 2018 +0900 Add spec for Gitlab::Ci::Config::Entry::Artifacts commit ede107caf13fb215045576dcce18e20eec776df1 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:58:28 2018 +0900 Revert refactoring commit 15531ba9feff669b2ac05936e0feaee1856c1571 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:57:31 2018 +0900 Revert refactoring commit 14821f3babcc210bc52e4e825adc8333752fbc88 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:55:41 2018 +0900 Add spec for file format. Add spec for config_artifacts commit 882faeab57ab39d18f72abd9b65d286db92e1011 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:20:28 2018 +0900 Add file_format to factory commit 3cd0513e254db15141cd748f6209179f462974f2 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:12:52 2018 +0900 Rename migration file properly commit f511933b5f618fc47d1512554878913922dfba61 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:09:57 2018 +0900 Revert artifacts_archive_file refactoring commit e295e8cbdee065ee3af6dd82f512729554237cad Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 16:03:26 2018 +0900 Dry up the converion in Entry::Reports commit b0ffa42f6410be4718e7a36cb21f7b585421750e Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 15:50:42 2018 +0900 Set file_format at callers commit f3dc7a2e02901c79a9e572514a1b731c680e43cc Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 15:47:51 2018 +0900 Use presenter for presenting artifacts hash to runner commit e5299526138be90d65cf13368134e734b46f7597 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 14:59:09 2018 +0900 Support deleting junit artifact. Make wording explicit commit cc81c34acf23323257d190c23030d0a89265bccc Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 14:35:12 2018 +0900 Add changelog commit abde0f2ab5c5c1d99b2f94a049984877bb5a4d77 Merge: 4c87e5b388f fabf6a5634f Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 13:22:22 2018 +0900 Merge branch 'master' into artifact-format-v2 commit 4c87e5b388fb098fb6da71e17a47fa204033e4ac Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 17:33:07 2018 +0900 Fix static analysis commit bc96346be6990b75da9a36055814b24b5b805707 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 16:43:02 2018 +0900 Fix Config::Entry::Artifacts commit aac284613b9db43e3021198dc5b43b81806f1bce Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 14:40:20 2018 +0900 Generalized by DEFAULT_FILE_FORMAT commit a79299fdbb0ed74000ca37cff8fef8268cd29b13 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 13:55:02 2018 +0900 Cleanup API::Entities::JobRequest::Artifacts commit 1650249214768c23f6f46ec62c0c54448017eeb5 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 13:25:52 2018 +0900 Simplified file_type relations commit 981da91bc4c255ff992870e4e4c4393696f5bece Merge: e79808425eb 924146a8d6b Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 13:18:20 2018 +0900 Merge branch 'master' into artifact-format-v2 commit e79808425eb63c322a997e71d606d97b85e42048 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 18:16:52 2018 +0900 Remove unnecessary change commit a531bd7487955143489d286a0fb2e5d0984acc52 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 17:40:35 2018 +0900 Fix errors typo commit 57d6f21821c8ad934874c1aac3f627335c64c80d Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 13:32:35 2018 +0900 Use the correct type name commit da4ca63f25a27a1268317952061c81a28516653f Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 13:29:21 2018 +0900 Refactor job_artifacts_metadata to job_artifacts_archive_metadata commit 4098a8f10f92a6efa48080f8925809e251066f9d Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 13:23:55 2018 +0900 Add job_artifacts_junit relation commit 5342f07e100253713dbf50eb303da1977484077f Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 13:14:03 2018 +0900 Fix raw to raw? commit 15e0abcb22d9db3d8ef955e647f0a5d0a49c26b6 Merge: 31252fe8d75 ba38931d90b Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 13:12:38 2018 +0900 Merge branch 'master' into artifact-format-v2 commit 31252fe8d751319c5390f898f66f0af4a8581013 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 19:05:51 2018 +0900 Temporaly use type Hash for reports commit 583165c0349f40e7be16a8039dbffb4139f94921 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 15:27:21 2018 +0900 Revert unnecessary change commit eb48369b8311b538f46f59a31f4a6d3f8c9e68e1 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 15:21:46 2018 +0900 Use file_format raw for trace commit fb69ae8349d58499ad21965c0d1cf95e2b79a8e3 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 15:20:10 2018 +0900 Check the presence of the file_format commit c0840224bc8789d35da032c2a0ee48aa9f2232aa Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 15:16:19 2018 +0900 Add format_restriction validation commit d64fbd388cb2294447df5185366d8b5016591949 Merge: 7ec81e7c7d1 c2a0a3ab1ae Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 15:11:44 2018 +0900 Merge branch 'master' into artifact-format-v2 commit 7ec81e7c7d115f77d712892dfc79db72b9f5bc7a Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 20:23:54 2018 +0900 Artifacts presenter (Halfway) commit a3ccbe4c3a9b7d3095fe1929dee5fd9c57e168e0 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 20:22:52 2018 +0900 Fix schema.rb commit b630c670c707548799c6852e4465ef94fb4a0572 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 19:26:03 2018 +0900 Allow reports type under artifacts. Allow junit keyword in it. commit e7e37612487b556320d27f4fe0de32cd4ec20720 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 19:25:10 2018 +0900 Change column name to artifact_format commit f3f25d56a7c627f4bb9d91d19de175273a7a6a81 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 18:02:21 2018 +0900 Rename metadata to archive_metadata, and compress to file_format commit d7e0709319ab8fe35a2598a3d484eb89b1885934 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 17:47:18 2018 +0900 Validate compression. Clean up schema commit beb5990e7e3bfbb308245dc97284aaf9700bd982 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 5 19:06:54 2018 +0900 Make compression params at the first level commit 1e2e1c0db5412e1aed3bf47562350c20c69dc1a6 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 5 16:31:03 2018 +0900 Reorganize components
2018-07-27 01:04:35 -04:00
let(:job) { create(:ci_build, :trace_artifact, :artifacts, :test_reports, :success, project: project, pipeline: pipeline) }
it 'erases job content' do
expect(response).to have_gitlab_http_status(201)
Squashed commit of the following: commit c35ca6594eb1d29cac46362d09036f3d128143ed Merge: 87da74fb98a 13ea4b387dd Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 27 13:25:22 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit 87da74fb98aef1f664553ca2b8406ca154e4c19f Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 20:27:45 2018 +0900 Remove unncessary GENERAL_ARCHIVE_FILE_TYPE commit 5a3cfc1fdc8e81dd5647e275f87c0da2d93235b4 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 20:19:44 2018 +0900 Expand entities in JobRequest::Artifacts commit 660f885ebb25a19182e601181050683d2b6134f6 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 20:06:14 2018 +0900 Add tests commit 60bca3dcfd055647a9f43523b79d5eebdc4bdc5a Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 19:30:52 2018 +0900 Simplify build runner presenter commit 81d1951d5562bec4086d719748360f3f24df4168 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 19:18:53 2018 +0900 Simplify `scope :test_reports` in job_artifacts commit 15d1d76ca1cb97501c82471eb1c927290071dcfb Merge: f3327b2912d ffbfd18ce2f Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 19:01:53 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit f3327b2912d0b169e7a059dca7b4d15e77567075 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 26 19:01:44 2018 +0900 Fix "or string" to "or a string". Use be_valid commit 9aaae6d60f7537f55f862f4d61de7a0d3a3b6bc2 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 21:25:57 2018 +0900 Fix spec file name - build_runner_presenter_spec.rb commit 41c64c190e2e2efa7ab91a0daa0598da2d755f05 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 21:18:12 2018 +0900 Rename to Ci::BuildRunnerPresenter commit e9762299eb66c8f88734f80d05d38b9616a8fde8 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 21:14:44 2018 +0900 Split methods into three in Ci::Builds::RunnerPresenter commit 6e73070313a782eb63d4fbcbe324d9acaf67334b Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 20:23:53 2018 +0900 Remove redandant as: :artifacts commit 063f647e4829d9c71a71d227f9946bb47b93691f Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 20:04:58 2018 +0900 Fix specs commit a45975afd9b9391390c1adafbeab72c970e97b64 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 18:18:53 2018 +0900 Created a separate presenter commit 431ad666e080124c90e13cbaf0d4f0969aa7b2f2 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 18:10:04 2018 +0900 Simplified config presenter commit 2e106569ea258f5f7556a8b454a6dd0e9cbe6902 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 17:25:05 2018 +0900 Skip file_format setting if the file_type is trace commit 0572bd8357a2e9ea16118a0bd85264e3fb799322 Merge: 30ae33daa1d 6cb30f83255 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 17:13:55 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit 30ae33daa1d4afcb57e6335fba62a3c5fc98468a Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 25 17:13:23 2018 +0900 Fix spec commit ccb6eb75187030ff0fd3c6e69f89eeca79d2a929 Merge: 1ebaaaf2094 34c57e09b9f Author: Shinya Maeda <shinya@gitlab.com> Date: Tue Jul 24 14:27:48 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit 1ebaaaf2094c47c03e16745d2f8af736ec102b76 Merge: bfdf565800b dc7b4b7bb97 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 23 14:22:29 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit bfdf565800b58e838a760aa01d2fadb64e2d768f Merge: 681bd6a878a 44dbeccbe10 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 19:10:47 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit 681bd6a878ad2a77c278f5619b51c542d7382aa2 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 18:19:46 2018 +0900 Specify DOWNTIME=false commit 59c4e31390e0d616d69babf8ac857e98f2dc774e Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 18:14:44 2018 +0900 Wrap long lines commit 3d85788edbe73fc74c72854508e47fe259d99236 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 18:05:31 2018 +0900 Checking filr_format and file_type paring commit 3c92a22faf6278e7a2d1ee13bd978bc659b72452 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 16:07:21 2018 +0900 Fix build presenter spec commit 36e69897b0524cdee6060c928c03af734afae664 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 16:02:09 2018 +0900 Erase test reports at the proper timing commit 402ae97ecf7f9e3fe541f2d6abef6e47ab740452 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 15:46:56 2018 +0900 Make GENERAL_ARCHIVE_FILE_TYPE as a single entry commit 75f75b3f5988398fff0660ca5f04aec756ab03bb Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 15:42:16 2018 +0900 Implement config artifact presenter commit 9ecaee914defba5f12a7a06375ea2876b4328d7f Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 14:27:54 2018 +0900 Introduce ARCHIVE_LEGACY_TRACES_MIGRATION_VERSION check commit 34ea9610ab9a249a576ee435f365b9e1fcca7f00 Merge: d88523ca884 b60364c0f37 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 20 13:46:52 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit d88523ca88420354f61bd36f533c62a6ca474423 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 21:00:40 2018 +0900 Revert unnecessary change commit d9beb10ede5e4e8abe388fadbd6412640293917a Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 20:57:03 2018 +0900 Remove scattering around erase_test_reports! commit c79f361ca01f8dbc0d395edee5fab7f5a0697934 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 20:53:00 2018 +0900 Rever archive_metadata refactoring (For simplifying) commit 55bc71a404d8cf5fa87e187f6e88da92ab95afa9 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 20:45:19 2018 +0900 Use array_of_strings_or_string in Command commit 8a576b18c8ab8ead2344e2885aaf2fde11af0328 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 20:40:06 2018 +0900 Fix spec commit a2cda62fb922184aaf0e78699e06846c96565e0d Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 18:27:11 2018 +0900 Fix presenter spec commit 95502e605af9bcf1a61dbeb26f9be4d181f8a7ba Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 18:23:41 2018 +0900 Fix artifact migratable commit a3930853c93862007ba6814511bc32042c7f4986 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 18:15:41 2018 +0900 Increment migration version to use `file_format` when archiving traces commit e31121cb5e617b0f05e375c2150ece0e38e5e0d6 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 17:57:15 2018 +0900 Impolement job_artifact.test_reports method commit e54707fdf97392839cb2c4711160bd3bc89da196 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 16:49:27 2018 +0900 Fix erase method commit 20e95824341af1ebc5877d28dc5eba26f73eddf9 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 16:28:00 2018 +0900 Fix spec commit 7ade498101d02573b20a2405ebe0bdb8efd8aa3b Merge: e7be6b2b362 98eccfc44c5 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 19 12:37:22 2018 +0900 Merge branch 'master-ce' into artifact-format-v2 commit e7be6b2b3624ba44d56143084731cb9a6168f974 Merge: 5a8d4930e01 9bdc9b1ae69 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 18 15:43:36 2018 +0900 Merge branch 'master' into artifact-format-v2 commit 5a8d4930e0127aae311bfa3da70d9ab9637791e3 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 18 15:43:28 2018 +0900 Evaluate artifact_format commit c3ce06aa9bc6481b37a16d175adf0fd1c37a1bc0 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 22:27:46 2018 +0900 Fix sending junit.xml commit e5ce3668ee65217aba610d5311efd5e82bacddf3 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 19:02:06 2018 +0900 Add spec for Gitlab::Ci::Config::Entry::Artifacts commit ede107caf13fb215045576dcce18e20eec776df1 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:58:28 2018 +0900 Revert refactoring commit 15531ba9feff669b2ac05936e0feaee1856c1571 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:57:31 2018 +0900 Revert refactoring commit 14821f3babcc210bc52e4e825adc8333752fbc88 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:55:41 2018 +0900 Add spec for file format. Add spec for config_artifacts commit 882faeab57ab39d18f72abd9b65d286db92e1011 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:20:28 2018 +0900 Add file_format to factory commit 3cd0513e254db15141cd748f6209179f462974f2 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:12:52 2018 +0900 Rename migration file properly commit f511933b5f618fc47d1512554878913922dfba61 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 17:09:57 2018 +0900 Revert artifacts_archive_file refactoring commit e295e8cbdee065ee3af6dd82f512729554237cad Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 16:03:26 2018 +0900 Dry up the converion in Entry::Reports commit b0ffa42f6410be4718e7a36cb21f7b585421750e Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 15:50:42 2018 +0900 Set file_format at callers commit f3dc7a2e02901c79a9e572514a1b731c680e43cc Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 15:47:51 2018 +0900 Use presenter for presenting artifacts hash to runner commit e5299526138be90d65cf13368134e734b46f7597 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 14:59:09 2018 +0900 Support deleting junit artifact. Make wording explicit commit cc81c34acf23323257d190c23030d0a89265bccc Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 14:35:12 2018 +0900 Add changelog commit abde0f2ab5c5c1d99b2f94a049984877bb5a4d77 Merge: 4c87e5b388f fabf6a5634f Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jul 16 13:22:22 2018 +0900 Merge branch 'master' into artifact-format-v2 commit 4c87e5b388fb098fb6da71e17a47fa204033e4ac Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 17:33:07 2018 +0900 Fix static analysis commit bc96346be6990b75da9a36055814b24b5b805707 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 16:43:02 2018 +0900 Fix Config::Entry::Artifacts commit aac284613b9db43e3021198dc5b43b81806f1bce Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 14:40:20 2018 +0900 Generalized by DEFAULT_FILE_FORMAT commit a79299fdbb0ed74000ca37cff8fef8268cd29b13 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 13:55:02 2018 +0900 Cleanup API::Entities::JobRequest::Artifacts commit 1650249214768c23f6f46ec62c0c54448017eeb5 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 13:25:52 2018 +0900 Simplified file_type relations commit 981da91bc4c255ff992870e4e4c4393696f5bece Merge: e79808425eb 924146a8d6b Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 13 13:18:20 2018 +0900 Merge branch 'master' into artifact-format-v2 commit e79808425eb63c322a997e71d606d97b85e42048 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 18:16:52 2018 +0900 Remove unnecessary change commit a531bd7487955143489d286a0fb2e5d0984acc52 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 17:40:35 2018 +0900 Fix errors typo commit 57d6f21821c8ad934874c1aac3f627335c64c80d Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 13:32:35 2018 +0900 Use the correct type name commit da4ca63f25a27a1268317952061c81a28516653f Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 13:29:21 2018 +0900 Refactor job_artifacts_metadata to job_artifacts_archive_metadata commit 4098a8f10f92a6efa48080f8925809e251066f9d Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 13:23:55 2018 +0900 Add job_artifacts_junit relation commit 5342f07e100253713dbf50eb303da1977484077f Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 13:14:03 2018 +0900 Fix raw to raw? commit 15e0abcb22d9db3d8ef955e647f0a5d0a49c26b6 Merge: 31252fe8d75 ba38931d90b Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 12 13:12:38 2018 +0900 Merge branch 'master' into artifact-format-v2 commit 31252fe8d751319c5390f898f66f0af4a8581013 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 19:05:51 2018 +0900 Temporaly use type Hash for reports commit 583165c0349f40e7be16a8039dbffb4139f94921 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 15:27:21 2018 +0900 Revert unnecessary change commit eb48369b8311b538f46f59a31f4a6d3f8c9e68e1 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 15:21:46 2018 +0900 Use file_format raw for trace commit fb69ae8349d58499ad21965c0d1cf95e2b79a8e3 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 15:20:10 2018 +0900 Check the presence of the file_format commit c0840224bc8789d35da032c2a0ee48aa9f2232aa Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 15:16:19 2018 +0900 Add format_restriction validation commit d64fbd388cb2294447df5185366d8b5016591949 Merge: 7ec81e7c7d1 c2a0a3ab1ae Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Jul 11 15:11:44 2018 +0900 Merge branch 'master' into artifact-format-v2 commit 7ec81e7c7d115f77d712892dfc79db72b9f5bc7a Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 20:23:54 2018 +0900 Artifacts presenter (Halfway) commit a3ccbe4c3a9b7d3095fe1929dee5fd9c57e168e0 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 20:22:52 2018 +0900 Fix schema.rb commit b630c670c707548799c6852e4465ef94fb4a0572 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 19:26:03 2018 +0900 Allow reports type under artifacts. Allow junit keyword in it. commit e7e37612487b556320d27f4fe0de32cd4ec20720 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 19:25:10 2018 +0900 Change column name to artifact_format commit f3f25d56a7c627f4bb9d91d19de175273a7a6a81 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 18:02:21 2018 +0900 Rename metadata to archive_metadata, and compress to file_format commit d7e0709319ab8fe35a2598a3d484eb89b1885934 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jul 6 17:47:18 2018 +0900 Validate compression. Clean up schema commit beb5990e7e3bfbb308245dc97284aaf9700bd982 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 5 19:06:54 2018 +0900 Make compression params at the first level commit 1e2e1c0db5412e1aed3bf47562350c20c69dc1a6 Author: Shinya Maeda <shinya@gitlab.com> Date: Thu Jul 5 16:31:03 2018 +0900 Reorganize components
2018-07-27 01:04:35 -04:00
expect(job.job_artifacts.count).to eq(0)
expect(job.trace.exist?).to be_falsy
expect(job.artifacts_file.exists?).to be_falsy
expect(job.artifacts_metadata.exists?).to be_falsy
expect(job.has_job_artifacts?).to be_falsy
end
it 'updates job' do
job.reload
expect(job.erased_at).to be_truthy
expect(job.erased_by).to eq(user)
end
end
context 'job is not erasable' do
let(:job) { create(:ci_build, :trace_live, project: project, pipeline: pipeline) }
it 'responds with forbidden' do
expect(response).to have_gitlab_http_status(403)
end
end
2017-11-07 08:45:55 -05:00
2017-11-07 08:57:58 -05:00
context 'when a developer erases a build' do
let(:role) { :developer }
let(:job) { create(:ci_build, :trace_artifact, :artifacts, :success, project: project, pipeline: pipeline, user: owner) }
2017-11-07 08:45:55 -05:00
context 'when the build was created by the developer' do
let(:owner) { user }
it { expect(response).to have_gitlab_http_status(201) }
end
context 'when the build was created by the other' do
let(:owner) { create(:user) }
it { expect(response).to have_gitlab_http_status(403) }
end
end
end
2016-06-10 11:11:27 -04:00
describe 'POST /projects/:id/jobs/:job_id/artifacts/keep' do
2016-06-10 11:11:27 -04:00
before do
post api("/projects/#{project.id}/jobs/#{job.id}/artifacts/keep", user)
2016-06-10 11:11:27 -04:00
end
context 'artifacts did not expire' do
let(:job) do
create(:ci_build, :trace_artifact, :artifacts, :success,
2016-06-10 11:11:27 -04:00
project: project, pipeline: pipeline, artifacts_expire_at: Time.now + 7.days)
end
2016-06-10 15:45:06 -04:00
it 'keeps artifacts' do
expect(response).to have_gitlab_http_status(200)
expect(job.reload.artifacts_expire_at).to be_nil
2016-06-10 11:11:27 -04:00
end
end
context 'no artifacts' do
let(:job) { create(:ci_build, project: project, pipeline: pipeline) }
2016-06-10 11:11:27 -04:00
2016-06-10 15:45:06 -04:00
it 'responds with not found' do
expect(response).to have_gitlab_http_status(404)
2016-06-10 11:11:27 -04:00
end
end
end
2016-08-15 09:58:22 -04:00
describe 'POST /projects/:id/jobs/:job_id/play' do
2016-08-15 09:58:22 -04:00
before do
post api("/projects/#{project.id}/jobs/#{job.id}/play", api_user)
2016-08-15 09:58:22 -04:00
end
context 'on an playable job' do
let(:job) { create(:ci_build, :manual, project: project, pipeline: pipeline) }
2016-08-15 09:58:22 -04:00
context 'when user is authorized to trigger a manual action' do
it 'plays the job' do
expect(response).to have_gitlab_http_status(200)
expect(json_response['user']['id']).to eq(user.id)
expect(json_response['id']).to eq(job.id)
expect(job.reload).to be_pending
end
end
context 'when user is not authorized to trigger a manual action' do
context 'when user does not have access to the project' do
let(:api_user) { create(:user) }
it 'does not trigger a manual action' do
expect(job.reload).to be_manual
expect(response).to have_gitlab_http_status(404)
end
end
context 'when user is not allowed to trigger the manual action' do
let(:api_user) { reporter }
it 'does not trigger a manual action' do
expect(job.reload).to be_manual
expect(response).to have_gitlab_http_status(403)
end
end
2016-08-15 09:58:22 -04:00
end
end
context 'on a non-playable job' do
2016-08-15 09:58:22 -04:00
it 'returns a status code 400, Bad Request' do
expect(response).to have_gitlab_http_status 400
expect(response.body).to match("Unplayable Job")
2016-08-15 09:58:22 -04:00
end
end
end
2015-12-29 17:12:36 -05:00
end