Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
3e7f3bc7
Commit
3e7f3bc7
authored
Feb 26, 2018
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor timeout selection mechanism
parent
e75614e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
8 deletions
+48
-8
app/models/ci/build.rb
app/models/ci/build.rb
+2
-8
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+46
-0
No files found.
app/models/ci/build.rb
View file @
3e7f3bc7
...
...
@@ -124,7 +124,7 @@ module Ci
after_transition
pending: :running
do
|
build
|
build
.
used_timeout
=
build
.
timeout
build
.
timeout_source
=
build
.
should_use_runner_timeout?
?
'Runner'
:
'Project'
build
.
timeout_source
=
build
.
timeout
<
build
.
project
.
build_timeout
?
'Runner'
:
'Project'
build
.
save!
build
.
run_after_commit
do
...
...
@@ -239,13 +239,7 @@ module Ci
end
def
timeout
return
runner
.
maximum_job_timeout
if
should_use_runner_timeout?
project
.
build_timeout
end
def
should_use_runner_timeout?
!
runner
.
nil?
&&
runner
.
defines_maximum_job_timeout?
&&
runner
.
maximum_job_timeout
<
project
.
build_timeout
[
project
.
build_timeout
,
runner
&
.
maximum_job_timeout
].
compact
.
min
end
def
triggered_by?
(
current_user
)
...
...
spec/models/ci/build_spec.rb
View file @
3e7f3bc7
...
...
@@ -2036,6 +2036,52 @@ describe Ci::Build do
end
end
describe
'state transition: pending: :running'
do
let
(
:runner
)
{
create
(
:ci_runner
)
}
let
(
:job
)
{
create
(
:ci_build
,
:pending
,
runner:
runner
)
}
before
do
job
.
project
.
build_timeout
=
1800
job
.
project
.
save!
end
shared_examples
'saves data on transition'
do
it
'saves used_timeout and timeout_source on transition'
do
expect
(
job
.
used_timeout
).
to
be_nil
expect
(
job
.
timeout_source
).
to
be_nil
job
.
run!
expect
(
job
.
used_timeout
).
to
eq
(
expected_timeout
)
expect
(
job
.
timeout_source
).
to
eq
(
expected_timeout_source
)
end
end
context
'when runner timeout overrides project timeout'
do
let
(
:expected_timeout
)
{
900
}
let
(
:expected_timeout_source
)
{
'Runner'
}
before
do
runner
.
maximum_job_timeout
=
900
runner
.
save!
end
it_behaves_like
'saves data on transition'
end
context
"when runner timeout doesn't override project timeout"
do
let
(
:expected_timeout
)
{
1800
}
let
(
:expected_timeout_source
)
{
'Project'
}
before
do
runner
.
maximum_job_timeout
=
3600
runner
.
save!
end
it_behaves_like
'saves data on transition'
end
end
describe
'state transition: any => [:running]'
do
shared_examples
'validation is active'
do
context
'when depended job has not been completed yet'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment