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
cb132e38
Commit
cb132e38
authored
Mar 24, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not stick to primary after log jira dvcs usage
Issue
https://gitlab.com/gitlab-org/gitlab/-/issues/325638
parent
eb3a3410
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
4 deletions
+74
-4
app/models/project_feature_usage.rb
app/models/project_feature_usage.rb
+4
-4
ee/app/models/ee/project_feature_usage.rb
ee/app/models/ee/project_feature_usage.rb
+15
-0
ee/spec/models/project_feature_usage_spec.rb
ee/spec/models/project_feature_usage_spec.rb
+55
-0
No files found.
app/models/project_feature_usage.rb
View file @
cb132e38
...
...
@@ -20,12 +20,12 @@ class ProjectFeatureUsage < ApplicationRecord
end
def
log_jira_dvcs_integration_usage
(
cloud:
true
)
transaction
(
requires_new:
true
)
do
save
unless
persisted?
touch
(
self
.
class
.
jira_dvcs_integration_field
(
cloud:
cloud
))
end
assign_attributes
(
self
.
class
.
jira_dvcs_integration_field
(
cloud:
cloud
)
=>
Time
.
current
)
save
rescue
ActiveRecord
::
RecordNotUnique
reset
retry
end
end
ProjectFeatureUsage
.
prepend_if_ee
(
'EE::ProjectFeatureUsage'
)
ee/app/models/ee/project_feature_usage.rb
0 → 100644
View file @
cb132e38
# frozen_string_literal: true
module
EE
module
ProjectFeatureUsage
extend
ActiveSupport
::
Concern
extend
::
Gitlab
::
Utils
::
Override
override
:log_jira_dvcs_integration_usage
def
log_jira_dvcs_integration_usage
(
**
options
)
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
without_sticky_writes
do
super
(
**
options
)
end
end
end
end
ee/spec/models/project_feature_usage_spec.rb
0 → 100644
View file @
cb132e38
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
ProjectFeatureUsage
,
:request_store
do
describe
'#log_jira_dvcs_integration_usage'
do
let!
(
:project
)
{
create
(
:project
)
}
subject
{
project
.
feature_usage
}
context
'database load balancing is configured'
do
before
do
# Do not pollute AR for other tests, but rather simulate effect of configure_proxy.
allow
(
ActiveRecord
::
Base
.
singleton_class
).
to
receive
(
:prepend
)
::
Gitlab
::
Database
::
LoadBalancing
.
configure_proxy
allow
(
ActiveRecord
::
Base
).
to
receive
(
:connection
).
and_return
(
::
Gitlab
::
Database
::
LoadBalancing
.
proxy
)
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
clear_session
end
after
do
::
Gitlab
::
Database
::
LoadBalancing
.
clear_configuration
end
it
'logs Jira DVCS Cloud last sync'
do
freeze_time
do
subject
.
log_jira_dvcs_integration_usage
expect
(
subject
.
jira_dvcs_server_last_sync_at
).
to
be_nil
expect
(
subject
.
jira_dvcs_cloud_last_sync_at
).
to
be_like_time
(
Time
.
current
)
end
end
it
'does not stick to primary'
do
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
not_to
be_performed_write
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
not_to
be_using_primary
subject
.
log_jira_dvcs_integration_usage
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
to
be_performed_write
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
not_to
be_using_primary
end
end
context
'database load balancing is not cofigured'
do
it
'logs Jira DVCS Cloud last sync'
do
freeze_time
do
subject
.
log_jira_dvcs_integration_usage
expect
(
subject
.
jira_dvcs_server_last_sync_at
).
to
be_nil
expect
(
subject
.
jira_dvcs_cloud_last_sync_at
).
to
be_like_time
(
Time
.
current
)
end
end
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