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
e844f5a5
Commit
e844f5a5
authored
Jun 09, 2021
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for creating and removing build runtime metadata
parent
85def17c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
7 deletions
+63
-7
app/models/ci/build.rb
app/models/ci/build.rb
+4
-6
app/models/ci/running_build.rb
app/models/ci/running_build.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+58
-0
No files found.
app/models/ci/build.rb
View file @
e844f5a5
...
@@ -300,7 +300,7 @@ module Ci
...
@@ -300,7 +300,7 @@ module Ci
end
end
# rubocop:disable CodeReuse/ServiceClass
# rubocop:disable CodeReuse/ServiceClass
after_transition
any
: :pending
do
|
build
,
transition
|
after_transition
any
=>
[
:pending
]
do
|
build
,
transition
|
Ci
::
UpdateBuildQueueService
.
new
.
push
(
build
,
transition
)
Ci
::
UpdateBuildQueueService
.
new
.
push
(
build
,
transition
)
build
.
run_after_commit
do
build
.
run_after_commit
do
...
@@ -312,11 +312,11 @@ module Ci
...
@@ -312,11 +312,11 @@ module Ci
Ci
::
UpdateBuildQueueService
.
new
.
pop
(
build
,
transition
)
Ci
::
UpdateBuildQueueService
.
new
.
pop
(
build
,
transition
)
end
end
after_transition
any
: :running
do
|
build
,
transition
|
after_transition
any
=>
[
:running
]
do
|
build
,
transition
|
Ci
::
UpdateBuildQueueService
.
new
.
track
(
build
,
transition
)
Ci
::
UpdateBuildQueueService
.
new
.
track
(
build
,
transition
)
end
end
after_transition
running:
any
do
|
build
|
after_transition
running:
any
do
|
build
,
transition
|
Ci
::
UpdateBuildQueueService
.
new
.
untrack
(
build
,
transition
)
Ci
::
UpdateBuildQueueService
.
new
.
untrack
(
build
,
transition
)
Ci
::
BuildRunnerSession
.
where
(
build:
build
).
delete_all
Ci
::
BuildRunnerSession
.
where
(
build:
build
).
delete_all
...
@@ -1095,9 +1095,7 @@ module Ci
...
@@ -1095,9 +1095,7 @@ module Ci
end
end
def
shared_runner_build?
def
shared_runner_build?
return
false
if
runner
.
nil?
runner
&
.
instance_type?
runner
.
instance_type?
end
end
protected
protected
...
...
app/models/ci/running_build.rb
View file @
e844f5a5
...
@@ -11,7 +11,7 @@ module Ci
...
@@ -11,7 +11,7 @@ module Ci
enum
runner_type:
::
Ci
::
Runner
.
runner_types
enum
runner_type:
::
Ci
::
Runner
.
runner_types
def
self
.
upsert_shared_runner_build!
(
build
)
def
self
.
upsert_shared_runner_build!
(
build
)
unless
build
.
runner
&&
build
.
runner
.
instance_type
?
unless
build
.
shared_runner_build
?
raise
ArgumentError
,
'build has not been picked by a shared runner'
raise
ArgumentError
,
'build has not been picked by a shared runner'
end
end
...
...
spec/models/ci/build_spec.rb
View file @
e844f5a5
...
@@ -493,6 +493,34 @@ RSpec.describe Ci::Build do
...
@@ -493,6 +493,34 @@ RSpec.describe Ci::Build do
expect
(
build
.
queuing_entry
).
to
be_present
expect
(
build
.
queuing_entry
).
to
be_present
end
end
end
end
context
'when build has been picked by a shared runner'
do
let
(
:build
)
{
create
(
:ci_build
,
:pending
)
}
it
'creates runtime metadata entry'
do
build
.
runner
=
create
(
:ci_runner
,
:instance_type
)
build
.
run!
expect
(
build
.
reload
.
runtime_metadata
).
to
be_present
end
end
end
describe
'#drop'
do
context
'when has a runtime tracking entry'
do
let
(
:build
)
{
create
(
:ci_build
,
:pending
)
}
it
'removes runtime tracking entry'
do
build
.
runner
=
create
(
:ci_runner
,
:instance_type
)
build
.
run!
expect
(
build
.
reload
.
runtime_metadata
).
to
be_present
build
.
drop!
expect
(
build
.
reload
.
runtime_metadata
).
not_to
be_present
end
end
end
end
describe
'#schedulable?'
do
describe
'#schedulable?'
do
...
@@ -5179,4 +5207,34 @@ RSpec.describe Ci::Build do
...
@@ -5179,4 +5207,34 @@ RSpec.describe Ci::Build do
it
{
expect
(
matcher
.
project
).
to
eq
(
build
.
project
)
}
it
{
expect
(
matcher
.
project
).
to
eq
(
build
.
project
)
}
end
end
describe
'#shared_runner_build?'
do
context
'when build does not have a runner assigned'
do
it
'is not a shared runner build'
do
expect
(
build
.
runner
).
to
be_nil
expect
(
build
).
not_to
be_shared_runner_build
end
end
context
'when build has a project runner assigned'
do
before
do
build
.
runner
=
create
(
:ci_runner
,
:project
)
end
it
'is not a shared runner build'
do
expect
(
build
).
not_to
be_shared_runner_build
end
end
context
'when build has an instance runner assigned'
do
before
do
build
.
runner
=
create
(
:ci_runner
,
:instance_type
)
end
it
'is a shared runner build'
do
expect
(
build
).
to
be_shared_runner_build
end
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