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
7392e4b8
Commit
7392e4b8
authored
May 26, 2021
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a separate trait that describes a queued build in tests
parent
6c5272ca
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
59 deletions
+59
-59
ee/spec/requests/api/ci/runner_spec.rb
ee/spec/requests/api/ci/runner_spec.rb
+1
-1
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+2
-2
spec/requests/api/ci/runner/jobs_request_post_spec.rb
spec/requests/api/ci/runner/jobs_request_post_spec.rb
+20
-20
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+35
-35
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+1
-1
No files found.
ee/spec/requests/api/ci/runner_spec.rb
View file @
7392e4b8
...
@@ -23,7 +23,7 @@ RSpec.describe API::Ci::Runner do
...
@@ -23,7 +23,7 @@ RSpec.describe API::Ci::Runner do
}
}
end
end
let!
(
:ci_build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
secrets:
secrets
)
}
let!
(
:ci_build
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
secrets:
secrets
)
}
context
'when secrets management feature is available'
do
context
'when secrets management feature is available'
do
before
do
before
do
...
...
spec/factories/ci/builds.rb
View file @
7392e4b8
...
@@ -5,7 +5,7 @@ FactoryBot.define do
...
@@ -5,7 +5,7 @@ FactoryBot.define do
name
{
'test'
}
name
{
'test'
}
add_attribute
(
:protected
)
{
false
}
add_attribute
(
:protected
)
{
false
}
created_at
{
'Di 29. Okt 09:50:00 CET 2013'
}
created_at
{
'Di 29. Okt 09:50:00 CET 2013'
}
created
pending
options
do
options
do
{
{
...
@@ -78,7 +78,7 @@ FactoryBot.define do
...
@@ -78,7 +78,7 @@ FactoryBot.define do
end
end
trait
:pending
do
trait
:pending
do
queued
queued
_at
{
'Di 29. Okt 09:50:59 CET 2013'
}
status
{
'pending'
}
status
{
'pending'
}
end
end
...
...
spec/requests/api/ci/runner/jobs_request_post_spec.rb
View file @
7392e4b8
...
@@ -23,7 +23,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -23,7 +23,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
let
(
:runner
)
{
create
(
:ci_runner
,
:project
,
projects:
[
project
])
}
let
(
:runner
)
{
create
(
:ci_runner
,
:project
,
projects:
[
project
])
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:job
)
do
let
(
:job
)
do
create
(
:ci_build
,
:artifacts
,
:extended_options
,
create
(
:ci_build
,
:
pending
,
:queued
,
:
artifacts
,
:extended_options
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
end
end
...
@@ -129,7 +129,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -129,7 +129,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
context
'when other projects have pending jobs'
do
context
'when other projects have pending jobs'
do
before
do
before
do
job
.
success
job
.
success
create
(
:ci_build
,
:pending
)
create
(
:ci_build
,
:pending
,
:queued
)
end
end
it_behaves_like
'no jobs available'
it_behaves_like
'no jobs available'
...
@@ -239,7 +239,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -239,7 +239,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end
end
context
'when job is made for tag'
do
context
'when job is made for tag'
do
let!
(
:job
)
{
create
(
:ci_build
,
:tag
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
tag
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
it
'sets branch as ref_type'
do
it
'sets branch as ref_type'
do
request_job
request_job
...
@@ -297,7 +297,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -297,7 +297,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end
end
context
'when job filtered by job_age'
do
context
'when job filtered by job_age'
do
let!
(
:job
)
{
create
(
:ci_build
,
:tag
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
,
queued_at:
60
.
seconds
.
ago
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
tag
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
,
queued_at:
60
.
seconds
.
ago
)
}
context
'job is queued less than job_age parameter'
do
context
'job is queued less than job_age parameter'
do
let
(
:job_age
)
{
120
}
let
(
:job_age
)
{
120
}
...
@@ -359,7 +359,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -359,7 +359,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end
end
context
'when job is for a release'
do
context
'when job is for a release'
do
let!
(
:job
)
{
create
(
:ci_build
,
:release_options
,
pipeline:
pipeline
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
release_options
,
pipeline:
pipeline
)
}
context
'when `multi_build_steps` is passed by the runner'
do
context
'when `multi_build_steps` is passed by the runner'
do
it
'exposes release info'
do
it
'exposes release info'
do
...
@@ -398,7 +398,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -398,7 +398,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
context
'when job is made for merge request'
do
context
'when job is made for merge request'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
source: :merge_request_event
,
project:
project
,
ref:
'feature'
,
merge_request:
merge_request
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
source: :merge_request_event
,
project:
project
,
ref:
'feature'
,
merge_request:
merge_request
)
}
let!
(
:job
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'spinach'
,
ref:
'feature'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
name:
'spinach'
,
ref:
'feature'
,
stage:
'test'
,
stage_idx:
0
)
}
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:merge_request
)
{
create
(
:merge_request
)
}
it
'sets branch as ref_type'
do
it
'sets branch as ref_type'
do
...
@@ -472,9 +472,9 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -472,9 +472,9 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end
end
context
'when project and pipeline have multiple jobs'
do
context
'when project and pipeline have multiple jobs'
do
let!
(
:job
)
{
create
(
:ci_build
,
:tag
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
tag
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job2
)
{
create
(
:ci_build
,
:tag
,
pipeline:
pipeline
,
name:
'rubocop'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job2
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
tag
,
pipeline:
pipeline
,
name:
'rubocop'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:test_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'deploy'
,
stage:
'deploy'
,
stage_idx:
1
)
}
let!
(
:test_job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
name:
'deploy'
,
stage:
'deploy'
,
stage_idx:
1
)
}
before
do
before
do
job
.
success
job
.
success
...
@@ -524,8 +524,8 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -524,8 +524,8 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end
end
context
'when pipeline have jobs with artifacts'
do
context
'when pipeline have jobs with artifacts'
do
let!
(
:job
)
{
create
(
:ci_build
,
:tag
,
:artifacts
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
tag
,
:artifacts
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:test_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'deploy'
,
stage:
'deploy'
,
stage_idx:
1
)
}
let!
(
:test_job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
name:
'deploy'
,
stage:
'deploy'
,
stage_idx:
1
)
}
before
do
before
do
job
.
success
job
.
success
...
@@ -544,10 +544,10 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -544,10 +544,10 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end
end
context
'when explicit dependencies are defined'
do
context
'when explicit dependencies are defined'
do
let!
(
:job
)
{
create
(
:ci_build
,
:tag
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
tag
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job2
)
{
create
(
:ci_build
,
:tag
,
pipeline:
pipeline
,
name:
'rubocop'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job2
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
tag
,
pipeline:
pipeline
,
name:
'rubocop'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:test_job
)
do
let!
(
:test_job
)
do
create
(
:ci_build
,
pipeline:
pipeline
,
token:
'test-job-token'
,
name:
'deploy'
,
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
token:
'test-job-token'
,
name:
'deploy'
,
stage:
'deploy'
,
stage_idx:
1
,
stage:
'deploy'
,
stage_idx:
1
,
options:
{
script:
[
'bash'
],
dependencies:
[
job2
.
name
]
})
options:
{
script:
[
'bash'
],
dependencies:
[
job2
.
name
]
})
end
end
...
@@ -568,10 +568,10 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -568,10 +568,10 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end
end
context
'when dependencies is an empty array'
do
context
'when dependencies is an empty array'
do
let!
(
:job
)
{
create
(
:ci_build
,
:tag
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
tag
,
pipeline:
pipeline
,
name:
'spinach'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job2
)
{
create
(
:ci_build
,
:tag
,
pipeline:
pipeline
,
name:
'rubocop'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:job2
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
tag
,
pipeline:
pipeline
,
name:
'rubocop'
,
stage:
'test'
,
stage_idx:
0
)
}
let!
(
:empty_dependencies_job
)
do
let!
(
:empty_dependencies_job
)
do
create
(
:ci_build
,
pipeline:
pipeline
,
token:
'test-job-token'
,
name:
'empty_dependencies_job'
,
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
token:
'test-job-token'
,
name:
'empty_dependencies_job'
,
stage:
'deploy'
,
stage_idx:
1
,
stage:
'deploy'
,
stage_idx:
1
,
options:
{
script:
[
'bash'
],
dependencies:
[]
})
options:
{
script:
[
'bash'
],
dependencies:
[]
})
end
end
...
@@ -732,7 +732,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -732,7 +732,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end
end
describe
'port support'
do
describe
'port support'
do
let
(
:job
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
options:
options
)
}
let
(
:job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
options:
options
)
}
context
'when job image has ports'
do
context
'when job image has ports'
do
let
(
:options
)
do
let
(
:options
)
do
...
@@ -784,7 +784,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -784,7 +784,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
describe
'a job with excluded artifacts'
do
describe
'a job with excluded artifacts'
do
context
'when excluded paths are defined'
do
context
'when excluded paths are defined'
do
let
(
:job
)
do
let
(
:job
)
do
create
(
:ci_build
,
pipeline:
pipeline
,
token:
'test-job-token'
,
name:
'test'
,
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
token:
'test-job-token'
,
name:
'test'
,
stage:
'deploy'
,
stage_idx:
1
,
stage:
'deploy'
,
stage_idx:
1
,
options:
{
artifacts:
{
paths:
[
'abc'
],
exclude:
[
'cde'
]
}
})
options:
{
artifacts:
{
paths:
[
'abc'
],
exclude:
[
'cde'
]
}
})
end
end
...
@@ -832,7 +832,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
...
@@ -832,7 +832,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
subject
{
request_job
}
subject
{
request_job
}
context
'when triggered by a user'
do
context
'when triggered by a user'
do
let
(
:job
)
{
create
(
:ci_build
,
user:
user
,
project:
project
)
}
let
(
:job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
user:
user
,
project:
project
)
}
subject
{
request_job
(
id:
job
.
id
)
}
subject
{
request_job
(
id:
job
.
id
)
}
...
...
spec/services/ci/register_job_service_spec.rb
View file @
7392e4b8
...
@@ -11,7 +11,7 @@ module Ci
...
@@ -11,7 +11,7 @@ module Ci
let!
(
:shared_runner
)
{
create
(
:ci_runner
,
:instance
)
}
let!
(
:shared_runner
)
{
create
(
:ci_runner
,
:instance
)
}
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:project
,
projects:
[
project
])
}
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:project
,
projects:
[
project
])
}
let!
(
:group_runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
group
])
}
let!
(
:group_runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
group
])
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
describe
'#execute'
do
describe
'#execute'
do
shared_examples
'handles runner assignment'
do
shared_examples
'handles runner assignment'
do
...
@@ -76,11 +76,11 @@ module Ci
...
@@ -76,11 +76,11 @@ module Ci
let!
(
:project3
)
{
create
:project
,
shared_runners_enabled:
true
}
let!
(
:project3
)
{
create
:project
,
shared_runners_enabled:
true
}
let!
(
:pipeline3
)
{
create
:ci_pipeline
,
project:
project3
}
let!
(
:pipeline3
)
{
create
:ci_pipeline
,
project:
project3
}
let!
(
:build1_project1
)
{
pending_job
}
let!
(
:build1_project1
)
{
pending_job
}
let!
(
:build2_project1
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
}
let!
(
:build2_project1
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
let!
(
:build3_project1
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
}
let!
(
:build3_project1
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
let!
(
:build1_project2
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline2
)
}
let!
(
:build1_project2
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline2
)
}
let!
(
:build2_project2
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline2
)
}
let!
(
:build2_project2
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline2
)
}
let!
(
:build1_project3
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline3
)
}
let!
(
:build1_project3
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline3
)
}
context
'when using fair scheduling'
do
context
'when using fair scheduling'
do
context
'when all builds are pending'
do
context
'when all builds are pending'
do
...
@@ -227,17 +227,17 @@ module Ci
...
@@ -227,17 +227,17 @@ module Ci
let!
(
:pipeline3
)
{
create
(
:ci_pipeline
,
project:
project3
)
}
let!
(
:pipeline3
)
{
create
(
:ci_pipeline
,
project:
project3
)
}
let!
(
:build1_project1
)
{
pending_job
}
let!
(
:build1_project1
)
{
pending_job
}
let!
(
:build2_project1
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:build2_project1
)
{
create
(
:ci_build
,
:queued
,
pipeline:
pipeline
)
}
let!
(
:build3_project1
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:build3_project1
)
{
create
(
:ci_build
,
:queued
,
pipeline:
pipeline
)
}
let!
(
:build1_project2
)
{
create
(
:ci_build
,
pipeline:
pipeline2
)
}
let!
(
:build1_project2
)
{
create
(
:ci_build
,
:queued
,
pipeline:
pipeline2
)
}
let!
(
:build2_project2
)
{
create
(
:ci_build
,
pipeline:
pipeline2
)
}
let!
(
:build2_project2
)
{
create
(
:ci_build
,
:queued
,
pipeline:
pipeline2
)
}
let!
(
:build1_project3
)
{
create
(
:ci_build
,
pipeline:
pipeline3
)
}
let!
(
:build1_project3
)
{
create
(
:ci_build
,
:queued
,
pipeline:
pipeline3
)
}
# these shouldn't influence the scheduling
# these shouldn't influence the scheduling
let!
(
:unrelated_group
)
{
create
(
:group
)
}
let!
(
:unrelated_group
)
{
create
(
:group
)
}
let!
(
:unrelated_project
)
{
create
(
:project
,
group_runners_enabled:
true
,
group:
unrelated_group
)
}
let!
(
:unrelated_project
)
{
create
(
:project
,
group_runners_enabled:
true
,
group:
unrelated_group
)
}
let!
(
:unrelated_pipeline
)
{
create
(
:ci_pipeline
,
project:
unrelated_project
)
}
let!
(
:unrelated_pipeline
)
{
create
(
:ci_pipeline
,
project:
unrelated_project
)
}
let!
(
:build1_unrelated_project
)
{
create
(
:ci_build
,
:pending
,
pipeline:
unrelated_pipeline
)
}
let!
(
:build1_unrelated_project
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
unrelated_pipeline
)
}
let!
(
:unrelated_group_runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
unrelated_group
])
}
let!
(
:unrelated_group_runner
)
{
create
(
:ci_runner
,
:group
,
groups:
[
unrelated_group
])
}
it
'does not consider builds from other group runners'
do
it
'does not consider builds from other group runners'
do
...
@@ -318,7 +318,7 @@ module Ci
...
@@ -318,7 +318,7 @@ module Ci
subject
{
described_class
.
new
(
specific_runner
).
execute
}
subject
{
described_class
.
new
(
specific_runner
).
execute
}
context
'with multiple builds are in queue'
do
context
'with multiple builds are in queue'
do
let!
(
:other_build
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
}
let!
(
:other_build
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
before
do
before
do
allow_any_instance_of
(
Ci
::
RegisterJobService
).
to
receive
(
:builds_for_project_runner
)
allow_any_instance_of
(
Ci
::
RegisterJobService
).
to
receive
(
:builds_for_project_runner
)
...
@@ -359,7 +359,7 @@ module Ci
...
@@ -359,7 +359,7 @@ module Ci
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:project
,
projects:
[
project
])
}
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:project
,
projects:
[
project
])
}
context
'when a job is protected'
do
context
'when a job is protected'
do
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:protected
,
pipeline:
pipeline
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:
queued
,
:
protected
,
pipeline:
pipeline
)
}
it
'picks the job'
do
it
'picks the job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_job
)
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_job
)
...
@@ -367,7 +367,7 @@ module Ci
...
@@ -367,7 +367,7 @@ module Ci
end
end
context
'when a job is unprotected'
do
context
'when a job is unprotected'
do
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
it
'picks the job'
do
it
'picks the job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_job
)
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_job
)
...
@@ -375,7 +375,7 @@ module Ci
...
@@ -375,7 +375,7 @@ module Ci
end
end
context
'when protected attribute of a job is nil'
do
context
'when protected attribute of a job is nil'
do
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
before
do
before
do
pending_job
.
update_attribute
(
:protected
,
nil
)
pending_job
.
update_attribute
(
:protected
,
nil
)
...
@@ -391,7 +391,7 @@ module Ci
...
@@ -391,7 +391,7 @@ module Ci
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:project
,
:ref_protected
,
projects:
[
project
])
}
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:project
,
:ref_protected
,
projects:
[
project
])
}
context
'when a job is protected'
do
context
'when a job is protected'
do
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:protected
,
pipeline:
pipeline
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:
queued
,
:
protected
,
pipeline:
pipeline
)
}
it
'picks the job'
do
it
'picks the job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_job
)
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_job
)
...
@@ -399,7 +399,7 @@ module Ci
...
@@ -399,7 +399,7 @@ module Ci
end
end
context
'when a job is unprotected'
do
context
'when a job is unprotected'
do
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
it
'does not pick the job'
do
it
'does not pick the job'
do
expect
(
execute
(
specific_runner
)).
to
be_nil
expect
(
execute
(
specific_runner
)).
to
be_nil
...
@@ -407,7 +407,7 @@ module Ci
...
@@ -407,7 +407,7 @@ module Ci
end
end
context
'when protected attribute of a job is nil'
do
context
'when protected attribute of a job is nil'
do
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
before
do
before
do
pending_job
.
update_attribute
(
:protected
,
nil
)
pending_job
.
update_attribute
(
:protected
,
nil
)
...
@@ -421,7 +421,7 @@ module Ci
...
@@ -421,7 +421,7 @@ module Ci
context
'runner feature set is verified'
do
context
'runner feature set is verified'
do
let
(
:options
)
{
{
artifacts:
{
reports:
{
junit:
"junit.xml"
}
}
}
}
let
(
:options
)
{
{
artifacts:
{
reports:
{
junit:
"junit.xml"
}
}
}
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
options:
options
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
options:
options
)
}
subject
{
execute
(
specific_runner
,
params
)
}
subject
{
execute
(
specific_runner
,
params
)
}
...
@@ -457,7 +457,7 @@ module Ci
...
@@ -457,7 +457,7 @@ module Ci
shared_examples
'validation is active'
do
shared_examples
'validation is active'
do
context
'when depended job has not been completed yet'
do
context
'when depended job has not been completed yet'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
manual
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
{
expect
(
subject
).
to
eq
(
pending_job
)
}
it
{
expect
(
subject
).
to
eq
(
pending_job
)
}
end
end
...
@@ -494,7 +494,7 @@ module Ci
...
@@ -494,7 +494,7 @@ module Ci
shared_examples
'validation is not active'
do
shared_examples
'validation is not active'
do
context
'when depended job has not been completed yet'
do
context
'when depended job has not been completed yet'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:
pending
,
:queued
,
:
manual
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
{
expect
(
subject
).
to
eq
(
pending_job
)
}
it
{
expect
(
subject
).
to
eq
(
pending_job
)
}
end
end
...
@@ -519,7 +519,7 @@ module Ci
...
@@ -519,7 +519,7 @@ module Ci
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
let!
(
:pending_job
)
do
let!
(
:pending_job
)
do
create
(
:ci_build
,
:pending
,
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
stage_idx:
1
,
pipeline:
pipeline
,
stage_idx:
1
,
options:
{
script:
[
"bash"
],
dependencies:
[
'test'
]
})
options:
{
script:
[
"bash"
],
dependencies:
[
'test'
]
})
end
end
...
@@ -530,7 +530,7 @@ module Ci
...
@@ -530,7 +530,7 @@ module Ci
end
end
context
'when build is degenerated'
do
context
'when build is degenerated'
do
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:degenerated
,
pipeline:
pipeline
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:
queued
,
:
degenerated
,
pipeline:
pipeline
)
}
subject
{
execute
(
specific_runner
,
{})
}
subject
{
execute
(
specific_runner
,
{})
}
...
@@ -545,7 +545,7 @@ module Ci
...
@@ -545,7 +545,7 @@ module Ci
context
'when build has data integrity problem'
do
context
'when build has data integrity problem'
do
let!
(
:pending_job
)
do
let!
(
:pending_job
)
do
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
end
end
before
do
before
do
...
@@ -570,7 +570,7 @@ module Ci
...
@@ -570,7 +570,7 @@ module Ci
context
'when build fails to be run!'
do
context
'when build fails to be run!'
do
let!
(
:pending_job
)
do
let!
(
:pending_job
)
do
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
end
end
before
do
before
do
...
@@ -612,12 +612,12 @@ module Ci
...
@@ -612,12 +612,12 @@ module Ci
context
'when only some builds can be matched by runner'
do
context
'when only some builds can be matched by runner'
do
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:project
,
projects:
[
project
],
tag_list:
%w[matching]
)
}
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:project
,
projects:
[
project
],
tag_list:
%w[matching]
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
tag_list:
%w[matching]
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
tag_list:
%w[matching]
)
}
before
do
before
do
# create additional matching and non-matching jobs
# create additional matching and non-matching jobs
create_list
(
:ci_build
,
2
,
:pending
,
pipeline:
pipeline
,
tag_list:
%w[matching]
)
create_list
(
:ci_build
,
2
,
:pending
,
:queued
,
pipeline:
pipeline
,
tag_list:
%w[matching]
)
create
(
:ci_build
,
pipeline:
pipeline
,
tag_list:
%w[non-matching]
)
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
,
tag_list:
%w[non-matching]
)
end
end
it
'observes queue size of only matching jobs'
do
it
'observes queue size of only matching jobs'
do
...
@@ -665,7 +665,7 @@ module Ci
...
@@ -665,7 +665,7 @@ module Ci
end
end
context
'when there is another build in queue'
do
context
'when there is another build in queue'
do
let!
(
:next_pending_job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
}
let!
(
:next_pending_job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
it
'skips this build and picks another build'
do
it
'skips this build and picks another build'
do
expect
(
Gitlab
::
Ci
::
Queue
::
Metrics
.
queue_operations_total
).
to
receive
(
:increment
)
expect
(
Gitlab
::
Ci
::
Queue
::
Metrics
.
queue_operations_total
).
to
receive
(
:increment
)
...
@@ -747,8 +747,8 @@ module Ci
...
@@ -747,8 +747,8 @@ module Ci
end
end
context
'when project already has running jobs'
do
context
'when project already has running jobs'
do
let!
(
:build2
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
,
runner:
shared_runner
)
}
let!
(
:build2
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
,
runner:
shared_runner
)
}
let!
(
:build3
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
,
runner:
shared_runner
)
}
let!
(
:build3
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
,
runner:
shared_runner
)
}
it
'counts job queuing time histogram with expected labels'
do
it
'counts job queuing time histogram with expected labels'
do
allow
(
attempt_counter
).
to
receive
(
:increment
)
allow
(
attempt_counter
).
to
receive
(
:increment
)
...
@@ -831,9 +831,9 @@ module Ci
...
@@ -831,9 +831,9 @@ module Ci
end
end
context
'when max queue depth is reached'
do
context
'when max queue depth is reached'
do
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:degenerated
,
pipeline:
pipeline
)
}
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
:
queued
,
:
degenerated
,
pipeline:
pipeline
)
}
let!
(
:pending_job_2
)
{
create
(
:ci_build
,
:pending
,
:degenerated
,
pipeline:
pipeline
)
}
let!
(
:pending_job_2
)
{
create
(
:ci_build
,
:pending
,
:
queued
,
:
degenerated
,
pipeline:
pipeline
)
}
let!
(
:pending_job_3
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
)
}
let!
(
:pending_job_3
)
{
create
(
:ci_build
,
:pending
,
:queued
,
pipeline:
pipeline
)
}
before
do
before
do
stub_const
(
"
#{
described_class
}
::MAX_QUEUE_DEPTH"
,
2
)
stub_const
(
"
#{
described_class
}
::MAX_QUEUE_DEPTH"
,
2
)
...
...
spec/services/ci/retry_build_service_spec.rb
View file @
7392e4b8
...
@@ -66,7 +66,7 @@ RSpec.describe Ci::RetryBuildService do
...
@@ -66,7 +66,7 @@ RSpec.describe Ci::RetryBuildService do
let_it_be
(
:another_pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let_it_be
(
:another_pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let_it_be
(
:build
)
do
let_it_be
(
:build
)
do
create
(
:ci_build
,
:failed
,
:expired
,
:erased
,
:queued
,
:coverage
,
:tags
,
create
(
:ci_build
,
:failed
,
:
picked
,
:
expired
,
:erased
,
:queued
,
:coverage
,
:tags
,
:allowed_to_fail
,
:on_tag
,
:triggered
,
:teardown_environment
,
:resource_group
,
:allowed_to_fail
,
:on_tag
,
:triggered
,
:teardown_environment
,
:resource_group
,
description:
'my-job'
,
stage:
'test'
,
stage_id:
stage
.
id
,
description:
'my-job'
,
stage:
'test'
,
stage_id:
stage
.
id
,
pipeline:
pipeline
,
auto_canceled_by:
another_pipeline
,
pipeline:
pipeline
,
auto_canceled_by:
another_pipeline
,
...
...
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