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
faac8dbe
Commit
faac8dbe
authored
Jul 13, 2021
by
Allison Browne
Committed by
Bob Van Landuyt
Jul 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ::Ci::Minutes::UpdateBuildMinutesService called twice
parent
003f4531
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
109 deletions
+20
-109
ee/app/workers/ee/ci/build_finished_worker.rb
ee/app/workers/ee/ci/build_finished_worker.rb
+3
-4
ee/spec/workers/build_finished_worker_spec.rb
ee/spec/workers/build_finished_worker_spec.rb
+0
-94
ee/spec/workers/ee/ci/build_finished_worker_spec.rb
ee/spec/workers/ee/ci/build_finished_worker_spec.rb
+17
-11
No files found.
ee/app/workers/ee/ci/build_finished_worker.rb
View file @
faac8dbe
...
@@ -4,10 +4,9 @@ module EE
...
@@ -4,10 +4,9 @@ module EE
module
Ci
module
Ci
module
BuildFinishedWorker
module
BuildFinishedWorker
def
process_build
(
build
)
def
process_build
(
build
)
unless
::
Feature
.
enabled?
(
:cancel_pipelines_prior_to_destroy
,
default_enabled: :yaml
)
::
Ci
::
Minutes
::
UpdateBuildMinutesService
.
new
(
build
.
project
,
nil
).
execute
(
build
)
::
Ci
::
Minutes
::
UpdateBuildMinutesService
.
new
(
build
.
project
,
nil
).
execute
(
build
)
# We need to use `reset` on `project` because their AR associations have been cached
end
# and `Namespace#namespace_statistics` will return stale data.
::
Ci
::
Minutes
::
EmailNotificationService
.
new
(
build
.
project
.
reset
).
execute
if
::
Gitlab
.
com?
unless
build
.
project
.
requirements
.
empty?
unless
build
.
project
.
requirements
.
empty?
RequirementsManagement
::
ProcessRequirementsReportsWorker
.
perform_async
(
build
.
id
)
RequirementsManagement
::
ProcessRequirementsReportsWorker
.
perform_async
(
build
.
id
)
...
...
ee/spec/workers/build_finished_worker_spec.rb
deleted
100644 → 0
View file @
003f4531
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
BuildFinishedWorker
do
let
(
:ci_runner
)
{
create
(
:ci_runner
)
}
let
(
:build
)
{
create
(
:ee_ci_build
,
:success
,
runner:
ci_runner
)
}
let
(
:project
)
{
build
.
project
}
let
(
:namespace
)
{
project
.
shared_runners_limit_namespace
}
subject
do
described_class
.
new
.
perform
(
build
.
id
)
end
def
namespace_stats
namespace
.
namespace_statistics
||
namespace
.
create_namespace_statistics
end
def
project_stats
project
.
statistics
||
project
.
create_statistics
(
namespace:
project
.
namespace
)
end
describe
'#perform'
do
context
'when on .com'
do
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
allow_any_instance_of
(
EE
::
Project
).
to
receive
(
:shared_runners_minutes_limit_enabled?
).
and_return
(
true
)
end
context
'when cancel_pipelines_prior_to_destroy is disabled'
do
before
do
stub_feature_flags
(
cancel_pipelines_prior_to_destroy:
false
)
end
it
'updates the project stats'
do
expect
{
subject
}.
to
change
{
project_stats
.
reload
.
shared_runners_seconds
}
end
it
'updates the namespace stats'
do
expect
{
subject
}.
to
change
{
namespace_stats
.
reload
.
shared_runners_seconds
}
end
it
'notifies the owners of Groups'
do
namespace
.
update_attribute
(
:shared_runners_minutes_limit
,
2000
)
namespace_stats
.
update_attribute
(
:shared_runners_seconds
,
2100
*
60
)
expect
(
CiMinutesUsageMailer
).
to
receive
(
:notify
).
once
.
with
(
namespace
,
[
namespace
.
owner
.
email
]).
and_return
(
spy
)
subject
end
end
end
context
'when not on .com'
do
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
false
)
end
it
'does not notify the owners of Groups'
do
expect
(
::
Ci
::
Minutes
::
EmailNotificationService
).
not_to
receive
(
:new
)
subject
end
end
it
'does not schedule processing of requirement reports by default'
do
expect
(
RequirementsManagement
::
ProcessRequirementsReportsWorker
).
not_to
receive
(
:perform_async
)
subject
end
it
'schedules processing of requirement reports if project has requirements'
do
create
(
:requirement
,
project:
project
)
expect
(
RequirementsManagement
::
ProcessRequirementsReportsWorker
).
to
receive
(
:perform_async
)
subject
end
context
'when token revocation is disabled'
do
before
do
allow_next_instance_of
(
described_class
)
do
|
build_finished_worker
|
allow
(
build_finished_worker
).
to
receive
(
:revoke_secret_detection_token?
)
{
false
}
end
end
it
'does not scan security reports for token revocation'
do
expect
(
ScanSecurityReportSecretsWorker
).
not_to
receive
(
:perform_async
)
subject
end
end
end
end
ee/spec/workers/ee/ci/build_finished_worker_spec.rb
View file @
faac8dbe
...
@@ -27,6 +27,11 @@ RSpec.describe Ci::BuildFinishedWorker do
...
@@ -27,6 +27,11 @@ RSpec.describe Ci::BuildFinishedWorker do
allow_any_instance_of
(
EE
::
Project
).
to
receive
(
:shared_runners_minutes_limit_enabled?
).
and_return
(
true
)
# rubocop:disable RSpec/AnyInstanceOf
allow_any_instance_of
(
EE
::
Project
).
to
receive
(
:shared_runners_minutes_limit_enabled?
).
and_return
(
true
)
# rubocop:disable RSpec/AnyInstanceOf
end
end
context
'when cancel_pipelines_prior_to_destroy is disabled'
do
before
do
stub_feature_flags
(
cancel_pipelines_prior_to_destroy:
false
)
end
it
'updates the project stats'
do
it
'updates the project stats'
do
expect
{
subject
}.
to
change
{
project_stats
.
reload
.
shared_runners_seconds
}
expect
{
subject
}.
to
change
{
project_stats
.
reload
.
shared_runners_seconds
}
end
end
...
@@ -44,6 +49,7 @@ RSpec.describe Ci::BuildFinishedWorker do
...
@@ -44,6 +49,7 @@ RSpec.describe Ci::BuildFinishedWorker do
subject
subject
end
end
end
end
end
context
'when not on .com'
do
context
'when not on .com'
do
before
do
before
do
...
...
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