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
2ca0eae0
Commit
2ca0eae0
authored
May 13, 2021
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for pushing build to a queue
parent
c1353c95
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
app/models/ci/build.rb
app/models/ci/build.rb
+1
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+27
-4
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+2
-1
No files found.
app/models/ci/build.rb
View file @
2ca0eae0
...
...
@@ -37,6 +37,7 @@ module Ci
has_one
:deployment
,
as: :deployable
,
class_name:
'Deployment'
has_one
:pending_state
,
class_name:
'Ci::BuildPendingState'
,
inverse_of: :build
has_one
:queuing_entry
,
class_name:
'Ci::PendingBuild'
,
foreign_key: :build_id
has_many
:trace_sections
,
class_name:
'Ci::BuildTraceSection'
has_many
:trace_chunks
,
class_name:
'Ci::BuildTraceChunk'
,
foreign_key: :build_id
,
inverse_of: :build
has_many
:report_results
,
class_name:
'Ci::BuildReportResult'
,
inverse_of: :build
...
...
spec/models/ci/build_spec.rb
View file @
2ca0eae0
...
...
@@ -323,8 +323,6 @@ RSpec.describe Ci::Build do
describe
'#enqueue'
do
let
(
:build
)
{
create
(
:ci_build
,
:created
)
}
subject
{
build
.
enqueue
}
before
do
allow
(
build
).
to
receive
(
:any_unmet_prerequisites?
).
and_return
(
has_prerequisites
)
allow
(
Ci
::
PrepareBuildService
).
to
receive
(
:perform_async
)
...
...
@@ -334,20 +332,45 @@ RSpec.describe Ci::Build do
let
(
:has_prerequisites
)
{
true
}
it
'transitions to preparing'
do
subject
build
.
enqueue
expect
(
build
).
to
be_preparing
end
it
'does not push build to the queue'
do
build
.
enqueue
expect
(
::
Ci
::
PendingBuild
.
all
.
count
).
to
be_zero
end
end
context
'build has no prerequisites'
do
let
(
:has_prerequisites
)
{
false
}
it
'transitions to pending'
do
subject
build
.
enqueue
expect
(
build
).
to
be_pending
end
it
'pushed build to a queue'
do
build
.
enqueue
expect
(
build
.
queuing_entry
).
to
be_present
end
context
'when build status transition fails'
do
before
do
::
Ci
::
Build
.
find
(
build
.
id
).
update_column
(
:lock_version
,
100
)
end
it
'does not push build to a queue'
do
expect
{
build
.
enqueue
}
.
to
raise_error
(
ActiveRecord
::
StaleObjectError
)
expect
(
build
.
queuing_entry
).
not_to
be_present
end
end
end
end
...
...
spec/services/ci/retry_build_service_spec.rb
View file @
2ca0eae0
...
...
@@ -59,7 +59,8 @@ RSpec.describe Ci::RetryBuildService do
metadata runner_session trace_chunks upstream_pipeline_id
artifacts_file artifacts_metadata artifacts_size commands
resource resource_group_id processed security_scans author
pipeline_id report_results pending_state pages_deployments]
.
freeze
pipeline_id report_results pending_state pages_deployments
queuing_entry]
.
freeze
shared_examples
'build duplication'
do
let_it_be
(
:another_pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
...
...
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