Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-02-06 17:18:32 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2018-02-28 22:59:25 +0300
commit999118f0ec6edabc9e13c089381ad664970a080a (patch)
tree4201e2944efb5379c9355999fc3750d0b0710566 /spec/services/ci
parentb14c484bb1d174c7c355de2258be1a4414b2cf78 (diff)
Merge branch 'feature/sm/artifacts-trace-ee' into 'master'
EE: Trace as artifacts (FileStorage and ObjectStorage) Closes #4171 See merge request gitlab-org/gitlab-ee!4258
Diffstat (limited to 'spec/services/ci')
-rw-r--r--spec/services/ci/create_trace_artifact_service_spec.rb43
-rw-r--r--spec/services/ci/retry_build_service_spec.rb5
2 files changed, 46 insertions, 2 deletions
diff --git a/spec/services/ci/create_trace_artifact_service_spec.rb b/spec/services/ci/create_trace_artifact_service_spec.rb
new file mode 100644
index 00000000000..847a88920fe
--- /dev/null
+++ b/spec/services/ci/create_trace_artifact_service_spec.rb
@@ -0,0 +1,43 @@
+require 'spec_helper'
+
+describe Ci::CreateTraceArtifactService do
+ describe '#execute' do
+ subject { described_class.new(nil, nil).execute(job) }
+
+ let(:job) { create(:ci_build) }
+
+ context 'when the job does not have trace artifact' do
+ context 'when the job has a trace file' do
+ before do
+ allow_any_instance_of(Gitlab::Ci::Trace)
+ .to receive(:default_path) { expand_fixture_path('trace/sample_trace') }
+
+ allow_any_instance_of(JobArtifactUploader).to receive(:move_to_cache) { false }
+ allow_any_instance_of(JobArtifactUploader).to receive(:move_to_store) { false }
+ end
+
+ it 'creates trace artifact' do
+ expect { subject }.to change { Ci::JobArtifact.count }.by(1)
+
+ expect(job.job_artifacts_trace.read_attribute(:file)).to eq('sample_trace')
+ end
+
+ context 'when the job has already had trace artifact' do
+ before do
+ create(:ci_job_artifact, :trace, job: job)
+ end
+
+ it 'does not create trace artifact' do
+ expect { subject }.not_to change { Ci::JobArtifact.count }
+ end
+ end
+ end
+
+ context 'when the job does not have a trace file' do
+ it 'does not create trace artifact' do
+ expect { subject }.not_to change { Ci::JobArtifact.count }
+ end
+ end
+ end
+ end
+end
diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb
index ea5d1f67b0c..4750091a7a4 100644
--- a/spec/services/ci/retry_build_service_spec.rb
+++ b/spec/services/ci/retry_build_service_spec.rb
@@ -17,7 +17,8 @@ describe Ci::RetryBuildService do
%i[id status user token coverage trace runner artifacts_expire_at
artifacts_file artifacts_metadata artifacts_size created_at
updated_at started_at finished_at queued_at erased_by
- erased_at auto_canceled_by job_artifacts job_artifacts_archive job_artifacts_metadata].freeze
+ erased_at auto_canceled_by job_artifacts job_artifacts_archive
+ job_artifacts_metadata job_artifacts_trace].freeze
IGNORE_ACCESSORS =
%i[type lock_version target_url base_tags trace_sections
@@ -37,7 +38,7 @@ describe Ci::RetryBuildService do
let(:build) do
create(:ci_build, :failed, :artifacts, :expired, :erased,
:queued, :coverage, :tags, :allowed_to_fail, :on_tag,
- :triggered, :trace, :teardown_environment,
+ :triggered, :trace_artifact, :teardown_environment,
description: 'my-job', stage: 'test', pipeline: pipeline,
auto_canceled_by: create(:ci_empty_pipeline, project: project)) do |build|
##