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
3237f57a
Commit
3237f57a
authored
Nov 24, 2021
by
Max Woolf
Committed by
Alex Pooley
Nov 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix audit event streaming rollout actors
parent
6c981fe6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
3 deletions
+46
-3
ee/app/models/ee/audit_event.rb
ee/app/models/ee/audit_event.rb
+15
-2
ee/spec/models/ee/audit_event_spec.rb
ee/spec/models/ee/audit_event_spec.rb
+30
-0
spec/requests/api/project_import_spec.rb
spec/requests/api/project_import_spec.rb
+1
-1
No files found.
ee/app/models/ee/audit_event.rb
View file @
3237f57a
...
@@ -56,8 +56,8 @@ module EE
...
@@ -56,8 +56,8 @@ module EE
def
stream_to_external_destinations
def
stream_to_external_destinations
return
if
entity
.
nil?
return
if
entity
.
nil?
return
unless
::
Feature
.
enabled?
(
:ff_external_audit_events_namespace
,
entity
)
return
unless
::
Feature
.
enabled?
(
:ff_external_audit_events_namespace
,
group_
entity
)
return
unless
entity
.
licensed_feature_available?
(
:external_audit_events
)
return
unless
group_
entity
.
licensed_feature_available?
(
:external_audit_events
)
AuditEvents
::
AuditEventStreamingWorker
.
perform_async
(
id
)
AuditEvents
::
AuditEventStreamingWorker
.
perform_async
(
id
)
end
end
...
@@ -68,6 +68,19 @@ module EE
...
@@ -68,6 +68,19 @@ module EE
private
private
def
group_entity
case
entity_type
when
'Group'
entity
when
'Project'
# Project events should be sent to the root ancestor's streaming destinations
# Projects without a group root ancestor should be ignored.
entity
.
group
&
.
root_ancestor
else
nil
end
end
def
truncate_fields
def
truncate_fields
TRUNCATED_FIELDS
.
each
do
|
name
,
limit
|
TRUNCATED_FIELDS
.
each
do
|
name
,
limit
|
original
=
self
[
name
]
||
self
.
details
[
name
]
original
=
self
[
name
]
||
self
.
details
[
name
]
...
...
ee/spec/models/ee/audit_event_spec.rb
View file @
3237f57a
...
@@ -86,6 +86,36 @@ RSpec.describe AuditEvent, type: :model do
...
@@ -86,6 +86,36 @@ RSpec.describe AuditEvent, type: :model do
stub_licensed_features
(
external_audit_events:
true
)
stub_licensed_features
(
external_audit_events:
true
)
end
end
context
'entity is a project'
do
let_it_be
(
:group
)
{
create
(
:group
,
:nested
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:event
)
{
create
(
:audit_event
,
:project_event
,
target_project:
project
)
}
context
'when ff_external_audit_events_namespace is enabled'
do
before
do
stub_feature_flags
(
ff_external_audit_events_namespace:
group
.
root_ancestor
)
end
it
'enqueues one worker'
do
expect
(
AuditEvents
::
AuditEventStreamingWorker
).
to
receive
(
:perform_async
).
once
event
.
stream_to_external_destinations
end
end
context
'when ff_external_audit_events_namespace is disabled'
do
before
do
stub_feature_flags
(
ff_external_audit_events_namespace:
false
)
end
it
'enqueues no workers'
do
expect
(
AuditEvents
::
AuditEventStreamingWorker
).
not_to
receive
(
:perform_async
)
event
.
stream_to_external_destinations
end
end
end
it
'enqueues one worker'
do
it
'enqueues one worker'
do
expect
(
AuditEvents
::
AuditEventStreamingWorker
).
to
receive
(
:perform_async
).
once
expect
(
AuditEvents
::
AuditEventStreamingWorker
).
to
receive
(
:perform_async
).
once
...
...
spec/requests/api/project_import_spec.rb
View file @
3237f57a
...
@@ -47,7 +47,7 @@ RSpec.describe API::ProjectImport do
...
@@ -47,7 +47,7 @@ RSpec.describe API::ProjectImport do
it
'executes a limited number of queries'
do
it
'executes a limited number of queries'
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}.
count
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}.
count
expect
(
control_count
).
to
be
<=
10
1
expect
(
control_count
).
to
be
<=
10
2
end
end
it
'schedules an import using a namespace'
do
it
'schedules an import using a namespace'
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