Remove Ci::Build#timeout
This commit is contained in:
parent
403decbbad
commit
6ecde0076a
|
@ -26,6 +26,8 @@ module Ci
|
|||
|
||||
has_one :metadata, class_name: 'Ci::BuildMetadata'
|
||||
|
||||
delegate :timeout, to: :metadata, prefix: true, allow_nil: true
|
||||
|
||||
# The "environment" field for builds is a String, and is the unexpanded name
|
||||
def persisted_environment
|
||||
@persisted_environment ||= Environment.find_by(
|
||||
|
@ -241,10 +243,6 @@ module Ci
|
|||
latest_builds.where('stage_idx < ?', stage_idx)
|
||||
end
|
||||
|
||||
def timeout
|
||||
ensure_metadata.timeout
|
||||
end
|
||||
|
||||
def triggered_by?(current_user)
|
||||
user == current_user
|
||||
end
|
||||
|
|
|
@ -1120,7 +1120,7 @@ module API
|
|||
end
|
||||
|
||||
class RunnerInfo < Grape::Entity
|
||||
expose :timeout
|
||||
expose :metadata_timeout, as: :timeout
|
||||
end
|
||||
|
||||
class Step < Grape::Entity
|
||||
|
|
|
@ -14,7 +14,7 @@ module Gitlab
|
|||
self.new(:script).tap do |step|
|
||||
step.script = job.options[:before_script].to_a + job.options[:script].to_a
|
||||
step.script = job.commands.split("\n") if step.script.empty?
|
||||
step.timeout = job.timeout
|
||||
step.timeout = job.metadata_timeout
|
||||
step.when = WHEN_ON_SUCCESS
|
||||
end
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ module Gitlab
|
|||
|
||||
self.new(:after_script).tap do |step|
|
||||
step.script = after_script
|
||||
step.timeout = job.timeout
|
||||
step.timeout = job.metadata_timeout
|
||||
step.when = WHEN_ALWAYS
|
||||
step.allow_failure = true
|
||||
end
|
||||
|
|
|
@ -5,10 +5,14 @@ describe Gitlab::Ci::Build::Step do
|
|||
shared_examples 'has correct script' do
|
||||
subject { described_class.from_commands(job) }
|
||||
|
||||
before do
|
||||
job.run!
|
||||
end
|
||||
|
||||
it 'fabricates an object' do
|
||||
expect(subject.name).to eq(:script)
|
||||
expect(subject.script).to eq(script)
|
||||
expect(subject.timeout).to eq(job.timeout)
|
||||
expect(subject.timeout).to eq(job.metadata_timeout)
|
||||
expect(subject.when).to eq('on_success')
|
||||
expect(subject.allow_failure).to be_falsey
|
||||
end
|
||||
|
@ -47,6 +51,10 @@ describe Gitlab::Ci::Build::Step do
|
|||
|
||||
subject { described_class.from_after_script(job) }
|
||||
|
||||
before do
|
||||
job.run!
|
||||
end
|
||||
|
||||
context 'when after_script is empty' do
|
||||
it 'doesn not fabricate an object' do
|
||||
is_expected.to be_nil
|
||||
|
@ -59,7 +67,7 @@ describe Gitlab::Ci::Build::Step do
|
|||
it 'fabricates an object' do
|
||||
expect(subject.name).to eq(:after_script)
|
||||
expect(subject.script).to eq(['ls -la', 'date'])
|
||||
expect(subject.timeout).to eq(job.timeout)
|
||||
expect(subject.timeout).to eq(job.metadata_timeout)
|
||||
expect(subject.when).to eq('always')
|
||||
expect(subject.allow_failure).to be_truthy
|
||||
end
|
||||
|
|
|
@ -1271,43 +1271,6 @@ describe Ci::Build do
|
|||
end
|
||||
|
||||
describe 'project settings' do
|
||||
describe '#timeout' do
|
||||
set(:project2) { create(:project, :repository, group: group, build_timeout: 1000) }
|
||||
set(:pipeline2) { create(:ci_pipeline, project: project2, sha: project2.commit.id, ref: project2.default_branch, status: 'success') }
|
||||
|
||||
let(:build) { create(:ci_build, :pending, pipeline: pipeline2) }
|
||||
|
||||
subject { build.timeout }
|
||||
|
||||
before do
|
||||
build.run!
|
||||
end
|
||||
|
||||
context 'when runner is not assigned' do
|
||||
it 'returns project timeout configuration' do
|
||||
is_expected.to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when runner sets timeout to bigger value' do
|
||||
let(:runner2) { create(:ci_runner, maximum_timeout: 2000) }
|
||||
let(:build) { create(:ci_build, :pending, pipeline: pipeline2, runner: runner2) }
|
||||
|
||||
it 'returns project timeout configuration' do
|
||||
is_expected.to eq(project2.build_timeout)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when runner sets timeout to smaller value' do
|
||||
let(:runner2) { create(:ci_runner, maximum_timeout: 600) }
|
||||
let(:build) { create(:ci_build, :pending, pipeline: pipeline2, runner: runner2) }
|
||||
|
||||
it 'returns project timeout configuration' do
|
||||
is_expected.to eq(runner2.maximum_timeout)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#allow_git_fetch' do
|
||||
it 'return project allow_git_fetch configuration' do
|
||||
expect(build.allow_git_fetch).to eq(project.build_allow_git_fetch)
|
||||
|
|
|
@ -360,12 +360,12 @@ describe API::Runner do
|
|||
let(:expected_steps) do
|
||||
[{ 'name' => 'script',
|
||||
'script' => %w(ls date),
|
||||
'timeout' => job.timeout,
|
||||
'timeout' => job.metadata_timeout,
|
||||
'when' => 'on_success',
|
||||
'allow_failure' => false },
|
||||
{ 'name' => 'after_script',
|
||||
'script' => %w(ls date),
|
||||
'timeout' => job.timeout,
|
||||
'timeout' => job.metadata_timeout,
|
||||
'when' => 'always',
|
||||
'allow_failure' => true }]
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue