| ... | @@ -527,6 +527,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do |
... | @@ -527,6 +527,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do |
|
|
|
|
|
|
|
describe 'GET trace.json' do
|
|
describe 'GET trace.json' do
|
|
|
before do
|
|
before do
|
|
|
|
stub_feature_flags(job_log_json: true)
|
|
|
get_trace
|
|
get_trace
|
|
|
end
|
|
end
|
|
|
|
|
|
| ... | @@ -535,8 +536,119 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do |
... | @@ -535,8 +536,119 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do |
|
|
|
|
|
|
|
it 'returns a trace' do
|
|
it 'returns a trace' do
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
expect(response).to match_response_schema('job/build_trace')
|
|
|
expect(json_response['id']).to eq job.id
|
|
expect(json_response['id']).to eq job.id
|
|
|
expect(json_response['status']).to eq job.status
|
|
expect(json_response['status']).to eq job.status
|
|
|
|
expect(json_response['state']).to be_present
|
|
|
|
expect(json_response['append']).not_to be_nil
|
|
|
|
expect(json_response['truncated']).not_to be_nil
|
|
|
|
expect(json_response['size']).to be_present
|
|
|
|
expect(json_response['total']).to be_present
|
|
|
|
expect(json_response['lines'].count).to be_positive
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when job has a trace' do
|
|
|
|
let(:job) { create(:ci_build, :trace_live, pipeline: pipeline) }
|
|
|
|
|
|
|
|
it 'returns a trace' do
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
expect(response).to match_response_schema('job/build_trace')
|
|
|
|
expect(json_response['id']).to eq job.id
|
|
|
|
expect(json_response['status']).to eq job.status
|
|
|
|
expect(json_response['lines']).to eq [{ 'content' => [{ 'text' => 'BUILD TRACE' }], 'offset' => 0 }]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when job has no traces' do
|
|
|
|
let(:job) { create(:ci_build, pipeline: pipeline) }
|
|
|
|
|
|
|
|
it 'returns no traces' do
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
expect(response).to match_response_schema('job/build_trace')
|
|
|
|
expect(json_response['id']).to eq job.id
|
|
|
|
expect(json_response['status']).to eq job.status
|
|
|
|
expect(json_response['lines']).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when job has a trace with ANSI sequence and Unicode' do
|
|
|
|
let(:job) { create(:ci_build, :unicode_trace_live, pipeline: pipeline) }
|
|
|
|
|
|
|
|
it 'returns a trace with Unicode' do
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
expect(response).to match_response_schema('job/build_trace')
|
|
|
|
expect(json_response['id']).to eq job.id
|
|
|
|
expect(json_response['status']).to eq job.status
|
|
|
|
expect(json_response['lines'].flat_map {|l| l['content'].map { |c| c['text'] } }).to include("ヾ(´༎ຶД༎ຶ`)ノ")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when trace artifact is in ObjectStorage' do
|
|
|
|
let(:url) { 'http://object-storage/trace' }
|
|
|
|
let(:file_path) { expand_fixture_path('trace/sample_trace') }
|
|
|
|
let!(:job) { create(:ci_build, :success, :trace_artifact, pipeline: pipeline) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow_any_instance_of(JobArtifactUploader).to receive(:file_storage?) { false }
|
|
|
|
allow_any_instance_of(JobArtifactUploader).to receive(:url) { url }
|
|
|
|
allow_any_instance_of(JobArtifactUploader).to receive(:size) { File.size(file_path) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there are no network issues' do
|
|
|
|
before do
|
|
|
|
stub_remote_url_206(url, file_path)
|
|
|
|
|
|
|
|
get_trace
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a trace' do
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
expect(json_response['id']).to eq job.id
|
|
|
|
expect(json_response['status']).to eq job.status
|
|
|
|
expect(json_response['lines'].count).to be_positive
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there is a network issue' do
|
|
|
|
before do
|
|
|
|
stub_remote_url_500(url)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a trace' do
|
|
|
|
expect { get_trace }.to raise_error(Gitlab::HttpIO::FailedToGetChunkError)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_trace
|
|
|
|
get :trace,
|
|
|
|
params: {
|
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
|
|
|
id: job.id
|
|
|
|
},
|
|
|
|
format: :json
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET legacy trace.json' do
|
|
|
|
before do
|
|
|
|
get_trace
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when job has a trace artifact' do
|
|
|
|
let(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) }
|
|
|
|
|
|
|
|
it 'returns a trace' do
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
expect(json_response['id']).to eq job.id
|
|
|
|
expect(json_response['status']).to eq job.status
|
|
|
|
expect(json_response['state']).to be_present
|
|
|
|
expect(json_response['append']).not_to be_nil
|
|
|
|
expect(json_response['truncated']).not_to be_nil
|
|
|
|
expect(json_response['size']).to be_present
|
|
|
|
expect(json_response['total']).to be_present
|
|
|
expect(json_response['html']).to eq(job.trace.html)
|
|
expect(json_response['html']).to eq(job.trace.html)
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
| ... | @@ -612,12 +724,13 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do |
... | @@ -612,12 +724,13 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do |
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def get_trace
|
|
def get_trace
|
|
|
get :trace, params: {
|
|
get :trace,
|
|
|
namespace_id: project.namespace,
|
|
params: {
|
|
|
project_id: project,
|
|
namespace_id: project.namespace,
|
|
|
id: job.id
|
|
project_id: project,
|
|
|
},
|
|
id: job.id
|
|
|
format: :json
|
|
},
|
|
|
|
format: :json
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
| ... | |
... | |
| ... | | ... | |