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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
3fdba5c9
Commit
3fdba5c9
authored
Apr 21, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix missing pipeline duration for blocked pipelines
parent
9c35162f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
19 deletions
+48
-19
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+4
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+44
-19
No files found.
app/models/ci/pipeline.rb
View file @
3fdba5c9
...
@@ -75,6 +75,10 @@ module Ci
...
@@ -75,6 +75,10 @@ module Ci
pipeline
.
update_duration
pipeline
.
update_duration
end
end
before_transition
any
=>
[
:manual
]
do
|
pipeline
|
pipeline
.
update_duration
end
before_transition
canceled:
any
-
[
:canceled
]
do
|
pipeline
|
before_transition
canceled:
any
-
[
:canceled
]
do
|
pipeline
|
pipeline
.
auto_canceled_by
=
nil
pipeline
.
auto_canceled_by
=
nil
end
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
3fdba5c9
...
@@ -296,32 +296,56 @@ describe Ci::Pipeline, models: true do
...
@@ -296,32 +296,56 @@ describe Ci::Pipeline, models: true do
describe
'state machine'
do
describe
'state machine'
do
let
(
:current
)
{
Time
.
now
.
change
(
usec:
0
)
}
let
(
:current
)
{
Time
.
now
.
change
(
usec:
0
)
}
let
(
:build
)
{
create_build
(
'build1'
,
0
)
}
let
(
:build
)
{
create_build
(
'build1'
,
queued_at:
0
)
}
let
(
:build_b
)
{
create_build
(
'build2'
,
0
)
}
let
(
:build_b
)
{
create_build
(
'build2'
,
queued_at:
0
)
}
let
(
:build_c
)
{
create_build
(
'build3'
,
0
)
}
let
(
:build_c
)
{
create_build
(
'build3'
,
queued_at:
0
)
}
describe
'#duration'
do
describe
'#duration'
do
before
do
context
'when multiple builds are finished'
do
travel_to
(
current
+
30
)
do
before
do
build
.
run!
travel_to
(
current
+
30
)
do
build
.
success!
build
.
run!
build_b
.
run!
build
.
success!
build_c
.
run!
build_b
.
run!
end
build_c
.
run!
end
travel_to
(
current
+
40
)
do
travel_to
(
current
+
40
)
do
build_b
.
drop!
build_b
.
drop!
end
travel_to
(
current
+
70
)
do
build_c
.
success!
end
end
end
travel_to
(
current
+
70
)
do
it
'matches sum of builds duration'
do
build_c
.
success!
pipeline
.
reload
expect
(
pipeline
.
duration
).
to
eq
(
40
)
end
end
end
end
it
'matches sum of builds duration'
do
context
'when pipeline becomes blocked'
do
pipeline
.
reload
let!
(
:build
)
{
create_build
(
'build:1'
)
}
let!
(
:action
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
)
}
expect
(
pipeline
.
duration
).
to
eq
(
40
)
before
do
travel_to
(
current
+
1
.
minute
)
do
build
.
run!
end
travel_to
(
current
+
5
.
minutes
)
do
build
.
success!
end
end
it
'recalculates pipeline duration'
do
pipeline
.
reload
expect
(
pipeline
).
to
be_manual
expect
(
pipeline
.
duration
).
to
eq
4
.
minutes
end
end
end
end
end
...
@@ -383,12 +407,13 @@ describe Ci::Pipeline, models: true do
...
@@ -383,12 +407,13 @@ describe Ci::Pipeline, models: true do
end
end
end
end
def
create_build
(
name
,
queued_at
=
current
,
started_from
=
0
)
def
create_build
(
name
,
queued_at
:
current
,
started_from:
0
,
**
opts
)
create
(
:ci_build
,
create
(
:ci_build
,
name:
name
,
name:
name
,
pipeline:
pipeline
,
pipeline:
pipeline
,
queued_at:
queued_at
,
queued_at:
queued_at
,
started_at:
queued_at
+
started_from
)
started_at:
queued_at
+
started_from
,
**
opts
)
end
end
end
end
...
...
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