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
8bfe94c0
Commit
8bfe94c0
authored
Jan 21, 2021
by
Mike Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Package File verification status in rake tasks
Add test the verification count methods.
parent
44621b2c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
158 additions
and
69 deletions
+158
-69
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+3
-3
ee/lib/gitlab/geo/geo_node_status_check.rb
ee/lib/gitlab/geo/geo_node_status_check.rb
+9
-9
ee/spec/fixtures/api/schemas/public_api/v4/geo_node_status.json
...c/fixtures/api/schemas/public_api/v4/geo_node_status.json
+24
-8
ee/spec/lib/gitlab/geo/geo_node_status_check_spec.rb
ee/spec/lib/gitlab/geo/geo_node_status_check_spec.rb
+3
-3
ee/spec/models/geo_node_status_spec.rb
ee/spec/models/geo_node_status_spec.rb
+118
-45
ee/spec/tasks/geo_rake_spec.rb
ee/spec/tasks/geo_rake_spec.rb
+1
-1
No files found.
ee/app/models/geo_node_status.rb
View file @
8bfe94c0
...
...
@@ -377,8 +377,8 @@ class GeoNodeStatus < ApplicationRecord
def
self
.
add_attr_in_percentage_for_replicable_classes
Gitlab
::
Geo
::
REPLICATOR_CLASSES
.
each
do
|
replicator
|
replicable
=
replicator
.
replicable_name_plural
attr_in_percentage
"
#{
replicable
}
_checksummed"
,
"
#{
replicable
}
_checksummed_count"
,
"
#{
replicable
}
_count"
attr_in_percentage
"
#{
replicable
}
_synced"
,
"
#{
replicable
}
_synced_count"
,
"
#{
replicable
}
_registry_count"
attr_in_percentage
"
#{
replicable
}
_verified"
,
"
#{
replicable
}
_verified_count"
,
"
#{
replicable
}
_registry_count"
end
end
...
...
@@ -402,8 +402,8 @@ class GeoNodeStatus < ApplicationRecord
public_send
(
"
#{
replicator_class
.
replicable_name_plural
}
_synced_in_percentage"
)
# rubocop:disable GitlabSecurity/PublicSend
end
def
checksumm
ed_in_percentage_for
(
replicator_class
)
public_send
(
"
#{
replicator_class
.
replicable_name_plural
}
_
checksumm
ed_in_percentage"
)
# rubocop:disable GitlabSecurity/PublicSend
def
verifi
ed_in_percentage_for
(
replicator_class
)
public_send
(
"
#{
replicator_class
.
replicable_name_plural
}
_
verifi
ed_in_percentage"
)
# rubocop:disable GitlabSecurity/PublicSend
end
def
count_for
(
replicator_class
)
...
...
ee/lib/gitlab/geo/geo_node_status_check.rb
View file @
8bfe94c0
...
...
@@ -35,7 +35,7 @@ module Gitlab
print_design_repositories_status
print_replicators_status
print_repositories_checked_status
print_replicators_
checked
_status
print_replicators_
verification
_status
print_sync_settings
print_db_replication_lag
...
...
@@ -57,7 +57,7 @@ module Gitlab
print_design_repositories_status
print_replicators_status
print_repositories_checked_status
print_replicators_
checked
_status
print_replicators_
verification
_status
end
def
replication_verification_complete?
...
...
@@ -104,7 +104,7 @@ module Gitlab
status
.
push
current_node_status
.
synced_in_percentage_for
(
replicator_class
)
if
replicator_class
.
verification_enabled?
status
.
push
current_node_status
.
checksumm
ed_in_percentage_for
(
replicator_class
)
status
.
push
current_node_status
.
verifi
ed_in_percentage_for
(
replicator_class
)
end
end
end
...
...
@@ -301,14 +301,14 @@ module Gitlab
end
end
def
print_replicators_
checked
_status
verifiable_replicator_classes
=
Gitlab
::
Geo
.
enabled_replicator_classes
.
select
(
&
:verification_enabled?
)
def
print_replicators_
verification
_status
verifiable_replicator_classes
=
Gitlab
::
Geo
.
verification_enabled_replicator_classes
verifiable_replicator_classes
.
each
do
|
replicator_class
|
print
"
#{
replicator_class
.
replicable_title_plural
}
Check
ed: "
.
rjust
(
GEO_STATUS_COLUMN_WIDTH
)
show_failed_value
(
replicator_class
.
checksum
_failed_count
)
print
"
#{
replicator_class
.
checksumm
ed_count
}
/
#{
replicator_class
.
registry_count
}
"
puts
using_percentage
(
current_node_status
.
checksumm
ed_in_percentage_for
(
replicator_class
))
print
"
#{
replicator_class
.
replicable_title_plural
}
Verifi
ed: "
.
rjust
(
GEO_STATUS_COLUMN_WIDTH
)
show_failed_value
(
replicator_class
.
verification
_failed_count
)
print
"
#{
replicator_class
.
verifi
ed_count
}
/
#{
replicator_class
.
registry_count
}
"
puts
using_percentage
(
current_node_status
.
verifi
ed_in_percentage_for
(
replicator_class
))
end
end
...
...
ee/spec/fixtures/api/schemas/public_api/v4/geo_node_status.json
View file @
8bfe94c0
...
...
@@ -48,36 +48,44 @@
"wikis_checksummed_in_percentage"
,
"merge_request_diffs_count"
,
"merge_request_diffs_checksum_failed_count"
,
"merge_request_diffs_checksummed_in_percentage"
,
"merge_request_diffs_checksummed_count"
,
"merge_request_diffs_registry_count"
,
"merge_request_diffs_failed_count"
,
"merge_request_diffs_synced_count"
,
"merge_request_diffs_synced_in_percentage"
,
"merge_request_diffs_verification_failed_count"
,
"merge_request_diffs_verified_count"
,
"merge_request_diffs_verified_in_percentage"
,
"package_files_count"
,
"package_files_checksum_failed_count"
,
"package_files_checksummed_in_percentage"
,
"package_files_checksummed_count"
,
"package_files_registry_count"
,
"package_files_failed_count"
,
"package_files_synced_count"
,
"package_files_synced_in_percentage"
,
"package_files_verification_failed_count"
,
"package_files_verified_count"
,
"package_files_verified_in_percentage"
,
"terraform_state_versions_count"
,
"terraform_state_versions_checksum_failed_count"
,
"terraform_state_versions_checksummed_in_percentage"
,
"terraform_state_versions_checksummed_count"
,
"terraform_state_versions_registry_count"
,
"terraform_state_versions_failed_count"
,
"terraform_state_versions_synced_count"
,
"terraform_state_versions_synced_in_percentage"
,
"terraform_state_versions_verification_failed_count"
,
"terraform_state_versions_verified_count"
,
"terraform_state_versions_verified_in_percentage"
,
"snippet_repositories_count"
,
"snippet_repositories_checksum_failed_count"
,
"snippet_repositories_checksummed_in_percentage"
,
"snippet_repositories_checksummed_count"
,
"snippet_repositories_registry_count"
,
"snippet_repositories_failed_count"
,
"snippet_repositories_synced_count"
,
"snippet_repositories_synced_in_percentage"
,
"snippet_repositories_verification_failed_count"
,
"snippet_repositories_verified_count"
,
"snippet_repositories_verified_in_percentage"
,
"repositories_verified_count"
,
"repositories_verification_failed_count"
,
"repositories_verified_in_percentage"
,
...
...
@@ -166,7 +174,9 @@
"merge_request_diffs_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"merge_request_diffs_synced_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"merge_request_diffs_synced_in_percentage"
:
{
"type"
:
"string"
},
"merge_request_diffs_checksummed_in_percentage"
:
{
"type"
:
"string"
},
"merge_request_diffs_verification_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"merge_request_diffs_verified_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"merge_request_diffs_verified_in_percentage"
:
{
"type"
:
"string"
},
"package_files_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"package_files_checksummed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"package_files_checksum_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
...
...
@@ -174,7 +184,9 @@
"package_files_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"package_files_synced_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"package_files_synced_in_percentage"
:
{
"type"
:
"string"
},
"package_files_checksummed_in_percentage"
:
{
"type"
:
"string"
},
"package_files_verification_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"package_files_verified_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"package_files_verified_in_percentage"
:
{
"type"
:
"string"
},
"terraform_state_versions_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"terraform_state_versions_checksummed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"terraform_state_versions_checksum_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
...
...
@@ -182,7 +194,9 @@
"terraform_state_versions_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"terraform_state_versions_synced_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"terraform_state_versions_synced_in_percentage"
:
{
"type"
:
"string"
},
"terraform_state_versions_checksummed_in_percentage"
:
{
"type"
:
"string"
},
"terraform_state_versions_verification_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"terraform_state_versions_verified_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"terraform_state_versions_verified_in_percentage"
:
{
"type"
:
"string"
},
"snippet_repositories_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"snippet_repositories_checksummed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"snippet_repositories_checksum_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
...
...
@@ -190,7 +204,9 @@
"snippet_repositories_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"snippet_repositories_synced_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"snippet_repositories_synced_in_percentage"
:
{
"type"
:
"string"
},
"snippet_repositories_checksummed_in_percentage"
:
{
"type"
:
"string"
},
"snippet_repositories_verification_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"snippet_repositories_verified_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"snippet_repositories_verified_in_percentage"
:
{
"type"
:
"string"
},
"repositories_verified_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"repositories_verification_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"repositories_verified_in_percentage"
:
{
"type"
:
"string"
},
...
...
ee/spec/lib/gitlab/geo/geo_node_status_check_spec.rb
View file @
8bfe94c0
...
...
@@ -36,9 +36,8 @@ RSpec.describe Gitlab::Geo::GeoNodeStatusCheck do
end
context
'replicators'
do
let
(
:replicators
)
{
Gitlab
::
Geo
.
enabled_replicator_classes
}
context
'replication'
do
let
(
:replicators
)
{
Gitlab
::
Geo
.
enabled_replicator_classes
}
let
(
:checks
)
do
replicators
.
map
{
|
k
|
/
#{
k
.
replicable_title_plural
}
:/
}
end
...
...
@@ -51,8 +50,9 @@ RSpec.describe Gitlab::Geo::GeoNodeStatusCheck do
end
context
'verification'
do
let
(
:replicators
)
{
Gitlab
::
Geo
.
verification_enabled_replicator_classes
}
let
(
:checks
)
do
replicators
.
map
{
|
k
|
/
#{
k
.
replicable_title_plural
}
Check
ed:/
}
replicators
.
map
{
|
k
|
/
#{
k
.
replicable_title_plural
}
Verifi
ed:/
}
end
context
'when verification is enabled'
do
...
...
ee/spec/models/geo_node_status_spec.rb
View file @
8bfe94c0
...
...
@@ -1200,15 +1200,18 @@ RSpec.describe GeoNodeStatus, :geo do
end
context
'verification'
do
context
'on the primary'
do
let
(
:checksummed_count_method
)
{
"
#{
replicable_name
}
_checksummed_count"
}
let
(
:checksum_failed_count_method
)
{
"
#{
replicable_name
}
_checksum_failed_count"
}
let
(
:checksummed_in_percentage_method
)
{
"
#{
replicable_name
}
_checksummed_in_percentage"
}
before
do
stub_current_geo_node
(
primary
)
end
context
'when verification is enabled'
do
before
do
skip
"
#{
replicator
.
model
}
does not include the VerificationState concern yet"
unless
replicator
.
model
.
respond_to?
(
:verification_state
)
stub_current_geo_node
(
primary
)
allow
(
replicator
).
to
receive
(
:verification_enabled?
).
and_return
(
true
)
end
...
...
@@ -1230,12 +1233,6 @@ RSpec.describe GeoNodeStatus, :geo do
expect
(
subject
.
send
(
checksum_failed_count_method
)).
to
eq
(
1
)
end
end
describe
'#<replicable_name>_checksummed_in_percentage'
do
it
'returns the right percentage'
do
expect
(
subject
.
send
(
checksummed_in_percentage_method
)).
to
be_within
(
0.01
).
of
(
66.67
)
end
end
end
context
'when there are no replicables'
do
...
...
@@ -1250,18 +1247,11 @@ RSpec.describe GeoNodeStatus, :geo do
expect
(
subject
.
send
(
checksum_failed_count_method
)).
to
eq
(
0
)
end
end
describe
'#<replicable_name>_checksummed_in_percentage'
do
it
'returns 0'
do
expect
(
subject
.
send
(
checksummed_in_percentage_method
)).
to
eq
(
0
)
end
end
end
end
context
'when verification is disabled'
do
before
do
stub_current_geo_node
(
primary
)
allow
(
replicator
).
to
receive
(
:verification_enabled?
).
and_return
(
false
)
end
...
...
@@ -1276,10 +1266,93 @@ RSpec.describe GeoNodeStatus, :geo do
expect
(
subject
.
send
(
checksum_failed_count_method
)).
to
be_nil
end
end
end
end
context
'on the secondary'
do
let
(
:verified_count_method
)
{
"
#{
replicable_name
}
_verified_count"
}
let
(
:verification_failed_count_method
)
{
"
#{
replicable_name
}
_verification_failed_count"
}
let
(
:verified_in_percentage_method
)
{
"
#{
replicable_name
}
_verified_in_percentage"
}
before
do
stub_current_geo_node
(
secondary
)
end
context
'when verification is enabled'
do
before
do
skip
"
#{
replicator
.
registry_class
}
does not include the VerificationState concern yet"
unless
replicator
.
registry_class
.
respond_to?
(
:verification_state
)
allow
(
replicator
).
to
receive
(
:verification_enabled?
).
and_return
(
true
)
end
context
'when there are replicables'
do
before
do
create
(
model_factory
,
:verification_succeeded
)
create
(
model_factory
,
:verification_succeeded
)
create
(
model_factory
,
:verification_failed
)
end
describe
'#<replicable_name>_verified_count'
do
it
'returns the right number of checksummed replicables'
do
expect
(
subject
.
send
(
verified_count_method
)).
to
eq
(
2
)
end
end
describe
'#<replicable_name>_verification_failed_count'
do
it
'returns the right number of failed replicables'
do
expect
(
subject
.
send
(
verification_failed_count_method
)).
to
eq
(
1
)
end
end
describe
'#<replicable_name>_verified_in_percentage'
do
it
'returns the right percentage'
do
expect
(
subject
.
send
(
verified_in_percentage_method
)).
to
be_within
(
0.01
).
of
(
66.67
)
end
end
end
describe
'#<replicable_name>_checksummed_in_percentage'
do
context
'when there are no replicables'
do
describe
'#<replicable_name>_verified_count'
do
it
'returns 0'
do
expect
(
subject
.
send
(
verified_count_method
)).
to
eq
(
0
)
end
end
describe
'#<replicable_name>_verification_failed_count'
do
it
'returns 0'
do
expect
(
subject
.
send
(
checksummed_in_percentage_method
)).
to
eq
(
0
)
expect
(
subject
.
send
(
verification_failed_count_method
)).
to
eq
(
0
)
end
end
describe
'#<replicable_name>_verified_in_percentage'
do
it
'returns 0'
do
expect
(
subject
.
send
(
verified_in_percentage_method
)).
to
eq
(
0
)
end
end
end
end
context
'when verification is disabled'
do
before
do
allow
(
replicator
).
to
receive
(
:verification_enabled?
).
and_return
(
false
)
end
describe
'#<replicable_name>_verified_count'
do
it
'returns nil'
do
expect
(
subject
.
send
(
verified_count_method
)).
to
be_nil
end
end
describe
'#<replicable_name>_verification_failed_count'
do
it
'returns nil'
do
expect
(
subject
.
send
(
verification_failed_count_method
)).
to
be_nil
end
end
describe
'#<replicable_name>_verified_in_percentage'
do
it
'returns 0'
do
expect
(
subject
.
send
(
verified_in_percentage_method
)).
to
eq
(
0
)
end
end
end
end
...
...
ee/spec/tasks/geo_rake_spec.rb
View file @
8bfe94c0
...
...
@@ -364,7 +364,7 @@ RSpec.describe 'geo rake tasks', :geo do
/Repositories Checked: /
,
/Last event ID seen from primary: /
,
/Last status report was: /
]
+
Gitlab
::
Geo
.
enabled_replicator_classes
.
map
{
|
k
|
/
#{
k
.
replicable_title_plural
}
Check
ed:/
}
+
]
+
Gitlab
::
Geo
.
verification_enabled_replicator_classes
.
map
{
|
k
|
/
#{
k
.
replicable_title_plural
}
Verifi
ed:/
}
+
Gitlab
::
Geo
.
enabled_replicator_classes
.
map
{
|
k
|
/
#{
k
.
replicable_title_plural
}
:/
}
checks
.
each
do
|
text
|
...
...
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