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
954827d7
Commit
954827d7
authored
May 24, 2021
by
Marius Bobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract shared examples out of specs
Extract shared examples out of specs
parent
5c48b88c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
48 deletions
+36
-48
ee/spec/services/ci/pipeline_creation/drop_not_runnable_builds_service_spec.rb
...ipeline_creation/drop_not_runnable_builds_service_spec.rb
+22
-30
ee/spec/services/ci/process_pipeline_service_spec.rb
ee/spec/services/ci/process_pipeline_service_spec.rb
+1
-1
spec/services/ci/create_pipeline_service/needs_spec.rb
spec/services/ci/create_pipeline_service/needs_spec.rb
+1
-1
spec/services/ci/pipeline_creation/drop_not_runnable_builds_service_spec.rb
...ipeline_creation/drop_not_runnable_builds_service_spec.rb
+12
-16
No files found.
ee/spec/services/ci/pipeline_creation/drop_not_runnable_builds_service_spec.rb
View file @
954827d7
...
...
@@ -22,18 +22,30 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
describe
'#execute'
do
subject
(
:execute
)
{
described_class
.
new
(
pipeline
).
execute
}
shared_examples
'available CI quota'
do
it
'does not drop the jobs'
do
expect
{
execute
}.
not_to
change
{
job
.
reload
.
status
}
end
end
shared_examples
'limit exceeded'
do
it
'drops the job'
do
execute
job
.
reload
expect
(
job
).
to
be_failed
expect
(
job
.
failure_reason
).
to
eq
(
'ci_quota_exceeded'
)
end
end
context
'with public projects'
do
before
do
pipeline
.
project
.
update!
(
visibility_level:
::
Gitlab
::
VisibilityLevel
::
PUBLIC
)
end
context
'with available CI quota'
do
it
'does not drop the jobs'
do
expect
{
execute
}.
not_to
change
{
job
.
reload
.
status
}
end
end
it_behaves_like
'available CI quota'
context
'when the C
i
quota is exceeded'
do
context
'when the C
I
quota is exceeded'
do
before
do
allow
(
pipeline
.
project
).
to
receive
(
:ci_minutes_quota
)
.
and_return
(
double
(
'quota'
,
minutes_used_up?:
true
))
...
...
@@ -50,11 +62,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
pipeline
.
project
.
update!
(
visibility_level:
::
Gitlab
::
VisibilityLevel
::
INTERNAL
)
end
context
'with available CI quota'
do
it
'does not drop the jobs'
do
expect
{
execute
}.
not_to
change
{
job
.
reload
.
status
}
end
end
it_behaves_like
'available CI quota'
context
'when the Ci quota is exceeded'
do
before
do
...
...
@@ -62,13 +70,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
.
and_return
(
double
(
'quota'
,
minutes_used_up?:
true
))
end
it
'drops the job'
do
execute
job
.
reload
expect
(
job
).
to
be_failed
expect
(
job
.
failure_reason
).
to
eq
(
'ci_quota_exceeded'
)
end
it_behaves_like
'limit exceeded'
end
end
...
...
@@ -77,11 +79,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
pipeline
.
project
.
update!
(
visibility_level:
::
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
context
'with available CI quota'
do
it
'does not drop the jobs'
do
expect
{
execute
}.
not_to
change
{
job
.
reload
.
status
}
end
end
it_behaves_like
'available CI quota'
context
'when the Ci quota is exceeded'
do
before
do
...
...
@@ -89,13 +87,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
.
and_return
(
double
(
'quota'
,
minutes_used_up?:
true
))
end
it
'drops the job'
do
execute
job
.
reload
expect
(
job
).
to
be_failed
expect
(
job
.
failure_reason
).
to
eq
(
'ci_quota_exceeded'
)
end
it_behaves_like
'limit exceeded'
end
end
end
...
...
ee/spec/services/ci/process_pipeline_service_spec.rb
View file @
954827d7
...
...
@@ -54,7 +54,7 @@ RSpec.describe Ci::ProcessPipelineService, '#execute' do
end
context
'with no runners'
do
it
'creates a downstream cross-project pipeline'
do
it
'creates a
failed
downstream cross-project pipeline'
do
service
.
execute
Sidekiq
::
Worker
.
drain_all
...
...
spec/services/ci/create_pipeline_service/needs_spec.rb
View file @
954827d7
...
...
@@ -226,7 +226,7 @@ RSpec.describe Ci::CreatePipelineService do
end
context
'when there are no runners matching the builds'
do
it
'creates a pipeline
with build_a and test_b pending; deploy_b manual
'
,
:sidekiq_inline
do
it
'creates a pipeline
but all jobs failed
'
,
:sidekiq_inline
do
processables
=
pipeline
.
processables
expect
(
pipeline
).
to
be_created_successfully
...
...
spec/services/ci/pipeline_creation/drop_not_runnable_builds_service_spec.rb
View file @
954827d7
...
...
@@ -17,24 +17,26 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
describe
'#execute'
do
subject
(
:execute
)
{
described_class
.
new
(
pipeline
).
execute
}
shared_examples
'jobs allowed to run'
do
it
'does not drop the jobs'
do
expect
{
execute
}.
not_to
change
{
job
.
reload
.
status
}
end
end
context
'when the feature flag is disabled'
do
before
do
stub_feature_flags
(
ci_drop_new_builds_when_ci_quota_exceeded:
false
)
end
it
'does not drop the jobs'
do
expect
{
execute
}.
not_to
change
{
job
.
reload
.
status
}
end
it_behaves_like
'jobs allowed to run'
end
context
'when the pipeline status is
not created
'
do
context
'when the pipeline status is
running
'
do
before
do
pipeline
.
update!
(
status: :running
)
end
it
'does not drop the jobs'
do
expect
{
execute
}.
not_to
change
{
job
.
reload
.
status
}
end
it_behaves_like
'jobs allowed to run'
end
context
'when there are no runners available'
do
...
...
@@ -56,9 +58,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
create
(
:ci_runner
,
:online
,
runner_type: :project_type
,
projects:
[
project
])
end
it
'does not drop the jobs'
do
expect
{
execute
}.
not_to
change
{
job
.
reload
.
status
}
end
it_behaves_like
'jobs allowed to run'
end
context
'with group runners'
do
...
...
@@ -66,9 +66,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
create
(
:ci_runner
,
:online
,
runner_type: :group_type
,
groups:
[
group
])
end
it
'does not drop the jobs'
do
expect
{
execute
}.
not_to
change
{
job
.
reload
.
status
}
end
it_behaves_like
'jobs allowed to run'
end
context
'with instance runners'
do
...
...
@@ -76,9 +74,7 @@ RSpec.describe Ci::PipelineCreation::DropNotRunnableBuildsService do
create
(
:ci_runner
,
:online
,
runner_type: :instance_type
)
end
it
'does not drop the jobs'
do
expect
{
execute
}.
not_to
change
{
job
.
reload
.
status
}
end
it_behaves_like
'jobs allowed to run'
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