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
1bcf6be2
Commit
1bcf6be2
authored
Mar 03, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
427f46fe
5cbdfdbd
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
255 additions
and
97 deletions
+255
-97
Gemfile
Gemfile
+3
-0
Gemfile.lock
Gemfile.lock
+44
-0
app/assets/stylesheets/framework/variables.scss
app/assets/stylesheets/framework/variables.scss
+2
-2
app/controllers/admin/application_settings_controller.rb
app/controllers/admin/application_settings_controller.rb
+2
-3
app/helpers/application_settings_helper.rb
app/helpers/application_settings_helper.rb
+2
-7
app/models/application_setting.rb
app/models/application_setting.rb
+1
-11
app/models/application_setting_implementation.rb
app/models/application_setting_implementation.rb
+10
-9
app/views/admin/application_settings/_repository_storage.html.haml
.../admin/application_settings/_repository_storage.html.haml
+5
-4
changelogs/unreleased/297020-linux-distribution-details-in-usage-ping.yml
...eased/297020-linux-distribution-details-in-usage-ping.yml
+5
-0
changelogs/unreleased/fix_repo_storage_weights_admin.yml
changelogs/unreleased/fix_repo_storage_weights_admin.yml
+5
-0
config/feature_flags/development/ci_reduce_queries_when_ticking_runner_queue.yml
...velopment/ci_reduce_queries_when_ticking_runner_queue.yml
+1
-1
config/metrics/settings/20210225045628_operating_system.yml
config/metrics/settings/20210225045628_operating_system.yml
+20
-0
doc/development/usage_ping/dictionary.md
doc/development/usage_ping/dictionary.md
+20
-0
ee/app/assets/stylesheets/pages/groups.scss
ee/app/assets/stylesheets/pages/groups.scss
+14
-4
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+13
-1
locale/gitlab.pot
locale/gitlab.pot
+9
-0
rubocop/rubocop-usage-data.yml
rubocop/rubocop-usage-data.yml
+1
-0
spec/controllers/admin/application_settings_controller_spec.rb
...controllers/admin/application_settings_controller_spec.rb
+2
-2
spec/features/admin/admin_settings_spec.rb
spec/features/admin/admin_settings_spec.rb
+14
-1
spec/helpers/application_settings_helper_spec.rb
spec/helpers/application_settings_helper_spec.rb
+5
-10
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+28
-0
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+8
-21
spec/support/shared_examples/models/application_setting_shared_examples.rb
...ed_examples/models/application_setting_shared_examples.rb
+10
-5
spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb
...pplication_settings/_repository_storage.html.haml_spec.rb
+31
-16
No files found.
Gemfile
View file @
1bcf6be2
...
...
@@ -74,6 +74,9 @@ gem 'acme-client', '~> 2.0', '>= 2.0.6'
# Browser detection
gem
'
browser
'
,
'~> 4.2'
# OS detection for usage ping
gem
'
ohai
'
,
'~> 16.10'
# GPG
gem
'
gpgme
'
,
'~> 2.0.19'
...
...
Gemfile.lock
View file @
1bcf6be2
...
...
@@ -172,6 +172,14 @@ GEM
cbor (0.5.9.6)
character_set (1.4.0)
charlock_holmes (0.7.7)
chef-config (16.10.17)
addressable
chef-utils (= 16.10.17)
fuzzyurl
mixlib-config (>= 2.2.12, < 4.0)
mixlib-shellout (>= 2.0, < 4.0)
tomlrb (~> 1.2)
chef-utils (16.10.17)
childprocess (3.0.0)
chunky_png (1.3.5)
citrus (3.0.2)
...
...
@@ -348,6 +356,8 @@ GEM
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
ffi-yajl (2.3.4)
libyajl2 (~> 1.2)
flipper (0.17.1)
flipper-active_record (0.17.1)
activerecord (>= 4.2, < 7)
...
...
@@ -403,6 +413,7 @@ GEM
fuubar (2.2.0)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
fuzzyurl (0.9.0)
gemoji (3.0.1)
gemojione (3.3.0)
json
...
...
@@ -668,6 +679,7 @@ GEM
actionmailer (>= 3.2)
letter_opener (~> 1.0)
railties (>= 3.2)
libyajl2 (1.2.0)
license_finder (6.0.0)
bundler
rubyzip (>= 1, < 3)
...
...
@@ -717,6 +729,12 @@ GEM
mini_mime (1.0.2)
mini_portile2 (2.5.0)
minitest (5.11.3)
mixlib-cli (2.1.8)
mixlib-config (3.0.9)
tomlrb
mixlib-log (3.0.9)
mixlib-shellout (3.2.5)
chef-utils
ms_rest (0.7.6)
concurrent-ruby (~> 1.0)
faraday (>= 0.9, < 2.0.0)
...
...
@@ -741,6 +759,8 @@ GEM
connection_pool (~> 2.2)
net-ldap (0.16.3)
net-ntp (2.1.3)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.0.0)
netrc (0.11.0)
nio4r (2.5.4)
...
...
@@ -764,6 +784,19 @@ GEM
octokit (4.20.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
ohai (16.10.6)
chef-config (>= 12.8, < 17)
chef-utils (>= 16.0, < 17)
ffi (~> 1.9)
ffi-yajl (~> 2.2)
ipaddress
mixlib-cli (>= 1.7.0)
mixlib-config (>= 2.0, < 4.0)
mixlib-log (>= 2.0.1, < 4.0)
mixlib-shellout (>= 2.0, < 4.0)
plist (~> 3.1)
train-core
wmi-lite (~> 1.0)
oj (3.10.6)
omniauth (1.9.0)
hashie (>= 3.4.6, < 3.7.0)
...
...
@@ -857,6 +890,7 @@ GEM
railties (>= 4.0.0)
pg (1.2.3)
pg_query (1.3.0)
plist (3.6.0)
png_quantizator (0.2.1)
po_to_json (1.0.1)
json (>= 1.6.0)
...
...
@@ -1196,9 +1230,17 @@ GEM
parslet (~> 1.8.0)
toml-rb (1.0.0)
citrus (~> 3.0, > 3.0)
tomlrb (1.3.0)
tpm-key_attestation (0.9.0)
bindata (~> 2.4)
openssl-signature_algorithm (~> 0.4.0)
train-core (3.4.9)
addressable (~> 2.5)
ffi (!= 1.13.0)
json (>= 1.8, < 3.0)
mixlib-shellout (>= 2.0, < 4.0)
net-scp (>= 1.2, < 4.0)
net-ssh (>= 2.9, < 7.0)
truncato (0.7.11)
htmlentities (~> 4.3.1)
nokogiri (>= 1.7.0, <= 2.0)
...
...
@@ -1271,6 +1313,7 @@ GEM
expression_parser
rinku
with_env (1.1.0)
wmi-lite (1.0.5)
xml-simple (1.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
...
...
@@ -1443,6 +1486,7 @@ DEPENDENCIES
nokogiri (~> 1.11.1)
oauth2 (~> 1.4)
octokit (~> 4.15)
ohai (~> 16.10)
oj (~> 3.10.6)
omniauth (~> 1.8)
omniauth-atlassian-oauth2 (~> 0.2.0)
...
...
app/assets/stylesheets/framework/variables.scss
View file @
1bcf6be2
...
...
@@ -830,8 +830,8 @@ $ci-variable-remove-button-width: calc(1em + #{2 * $gl-padding});
/*
GitLab Plans
*/
$gl-
gold
-plan
:
#d4af37
;
$gl-
silver
-plan
:
#91a1ab
;
$gl-
ultimate
-plan
:
#d4af37
;
$gl-
premium
-plan
:
#91a1ab
;
$gl-bronze-plan
:
#cd7f32
;
/*
...
...
app/controllers/admin/application_settings_controller.rb
View file @
1bcf6be2
...
...
@@ -237,7 +237,6 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
[
*::
ApplicationSettingsHelper
.
visible_attributes
,
*::
ApplicationSettingsHelper
.
external_authorization_service_attributes
,
*
ApplicationSetting
.
repository_storages_weighted_attributes
,
*
ApplicationSetting
.
kroki_formats_attributes
.
keys
.
map
{
|
key
|
"kroki_formats_
#{
key
}
"
.
to_sym
},
:lets_encrypt_notification_email
,
:lets_encrypt_terms_of_service_accepted
,
...
...
@@ -248,8 +247,8 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:default_branch_name
,
disabled_oauth_sign_in_sources:
[],
import_sources:
[],
re
pository_storage
s:
[],
re
stricted_visibility_levels:
[]
re
stricted_visibility_level
s:
[],
re
pository_storages_weighted:
{}
]
end
...
...
app/helpers/application_settings_helper.rb
View file @
1bcf6be2
...
...
@@ -37,13 +37,8 @@ module ApplicationSettingsHelper
end
def
storage_weights
ApplicationSetting
.
repository_storages_weighted_attributes
.
map
do
|
attribute
|
storage
=
attribute
.
to_s
.
delete_prefix
(
'repository_storages_weighted_'
)
{
name:
attribute
,
label:
storage
,
value:
@application_setting
.
repository_storages_weighted
[
storage
]
||
0
}
Gitlab
.
config
.
repositories
.
storages
.
keys
.
each_with_object
(
OpenStruct
.
new
)
do
|
storage
,
weights
|
weights
[
storage
.
to_sym
]
=
@application_setting
.
repository_storages_weighted
[
storage
]
||
0
end
end
...
...
app/models/application_setting.rb
View file @
1bcf6be2
...
...
@@ -25,10 +25,6 @@ class ApplicationSetting < ApplicationRecord
alias_attribute
:instance_group_id
,
:instance_administrators_group_id
alias_attribute
:instance_administrators_group
,
:instance_group
def
self
.
repository_storages_weighted_attributes
@repository_storages_weighted_atributes
||=
Gitlab
.
config
.
repositories
.
storages
.
keys
.
map
{
|
k
|
"repository_storages_weighted_
#{
k
}
"
.
to_sym
}.
freeze
end
def
self
.
kroki_formats_attributes
{
blockdiag:
{
...
...
@@ -44,7 +40,6 @@ class ApplicationSetting < ApplicationRecord
end
store_accessor
:kroki_formats
,
*
ApplicationSetting
.
kroki_formats_attributes
.
keys
,
prefix:
true
store_accessor
:repository_storages_weighted
,
*
Gitlab
.
config
.
repositories
.
storages
.
keys
,
prefix:
true
# Include here so it can override methods from
# `add_authentication_token_field`
...
...
@@ -502,6 +497,7 @@ class ApplicationSetting < ApplicationRecord
inclusion:
{
in:
[
true
,
false
],
message:
_
(
'must be a boolean value'
)
}
before_validation
:ensure_uuid!
before_validation
:coerce_repository_storages_weighted
,
if: :repository_storages_weighted_changed?
before_save
:ensure_runners_registration_token
before_save
:ensure_health_check_access_token
...
...
@@ -582,12 +578,6 @@ class ApplicationSetting < ApplicationRecord
recaptcha_enabled
||
login_recaptcha_protection_enabled
end
repository_storages_weighted_attributes
.
each
do
|
attribute
|
define_method
:"
#{
attribute
}
="
do
|
value
|
super
(
value
.
to_i
)
end
end
kroki_formats_attributes
.
keys
.
each
do
|
key
|
define_method
:"kroki_formats_
#{
key
}
="
do
|
value
|
super
(
::
Gitlab
::
Utils
.
to_boolean
(
value
))
...
...
app/models/application_setting_implementation.rb
View file @
1bcf6be2
...
...
@@ -293,10 +293,6 @@ module ApplicationSettingImplementation
Array
(
read_attribute
(
:repository_storages
))
end
def
repository_storages_weighted
read_attribute
(
:repository_storages_weighted
)
end
def
commit_email_hostname
super
.
presence
||
self
.
class
.
default_commit_email_hostname
end
...
...
@@ -328,9 +324,10 @@ module ApplicationSettingImplementation
def
normalized_repository_storage_weights
strong_memoize
(
:normalized_repository_storage_weights
)
do
weights_total
=
repository_storages_weighted
.
values
.
reduce
(:
+
)
repository_storages_weights
=
repository_storages_weighted
.
slice
(
*
Gitlab
.
config
.
repositories
.
storages
.
keys
)
weights_total
=
repository_storages_weights
.
values
.
reduce
(:
+
)
repository_storages_weight
ed
.
transform_values
do
|
w
|
repository_storages_weight
s
.
transform_values
do
|
w
|
next
w
if
weights_total
==
0
w
.
to_f
/
weights_total
...
...
@@ -468,16 +465,20 @@ module ApplicationSettingImplementation
invalid
.
empty?
end
def
coerce_repository_storages_weighted
repository_storages_weighted
.
transform_values!
(
&
:to_i
)
end
def
check_repository_storages_weighted
invalid
=
repository_storages_weighted
.
keys
-
Gitlab
.
config
.
repositories
.
storages
.
keys
errors
.
add
(
:repository_storages_weighted
,
"can't include: %{invalid_storages}"
%
{
invalid_storages:
invalid
.
join
(
", "
)
})
unless
errors
.
add
(
:repository_storages_weighted
,
_
(
"can't include: %{invalid_storages}"
)
%
{
invalid_storages:
invalid
.
join
(
", "
)
})
unless
invalid
.
empty?
repository_storages_weighted
.
each
do
|
key
,
val
|
next
unless
val
.
present?
errors
.
add
(
:
"repository_storages_weighted_
#{
key
}
"
,
"value must be an integer"
)
unless
val
.
is_a?
(
Integer
)
errors
.
add
(
:
"repository_storages_weighted_
#{
key
}
"
,
"value must be between 0 and 100"
)
unless
val
.
between?
(
0
,
100
)
errors
.
add
(
:
repository_storages_weighted
,
_
(
"value for '%{storage}' must be an integer"
)
%
{
storage:
key
}
)
unless
val
.
is_a?
(
Integer
)
errors
.
add
(
:
repository_storages_weighted
,
_
(
"value for '%{storage}' must be between 0 and 100"
)
%
{
storage:
key
}
)
unless
val
.
between?
(
0
,
100
)
end
end
...
...
app/views/admin/application_settings/_repository_storage.html.haml
View file @
1bcf6be2
...
...
@@ -18,8 +18,9 @@
=
_
(
'Enter weights for storages for new repositories.'
)
=
link_to
sprite_icon
(
'question-o'
),
help_page_path
(
'administration/repository_storage_paths'
)
.form-check
-
storage_weights
.
each
do
|
attribute
|
=
f
.
text_field
attribute
[
:name
],
class:
'form-text-input'
,
value:
attribute
[
:value
]
=
f
.
label
attribute
[
:label
],
attribute
[
:label
],
class:
'label-bold form-check-label'
%br
=
f
.
fields_for
:repository_storages_weighted
,
storage_weights
do
|
storage_form
|
-
Gitlab
.
config
.
repositories
.
storages
.
keys
.
each
do
|
storage
|
=
storage_form
.
text_field
storage
,
class:
'form-text-input'
=
storage_form
.
label
storage
,
storage
,
class:
'label-bold form-check-label'
%br
=
f
.
submit
_
(
'Save changes'
),
class:
"gl-button btn btn-success qa-save-changes-button"
changelogs/unreleased/297020-linux-distribution-details-in-usage-ping.yml
0 → 100644
View file @
1bcf6be2
---
title
:
Add Operating System details to usage ping
merge_request
:
54778
author
:
type
:
added
changelogs/unreleased/fix_repo_storage_weights_admin.yml
0 → 100644
View file @
1bcf6be2
---
title
:
Allow saving repository weights after a storage has been removed
merge_request
:
53803
author
:
type
:
fixed
config/feature_flags/development/ci_reduce_queries_when_ticking_runner_queue.yml
View file @
1bcf6be2
---
name
:
ci_reduce_queries_when_ticking_runner_queue
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55496
rollout_issue_url
:
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/323328
milestone
:
'
13.10'
type
:
development
group
:
group::continuous integration
...
...
config/metrics/settings/20210225045628_operating_system.yml
0 → 100644
View file @
1bcf6be2
---
key_path
:
settings.operating_system
description
:
Information about the operating system running GitLab
product_section
:
enablement
product_stage
:
enablement
product_group
:
group::distribution
product_category
:
collection
value_type
:
string
status
:
implemented
milestone
:
"
13.10"
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54778
time_frame
:
none
data_source
:
ruby
distribution
:
-
ce
-
ee
tier
:
-
free
-
premium
-
ultimate
doc/development/usage_ping/dictionary.md
View file @
1bcf6be2
...
...
@@ -20846,6 +20846,26 @@ Is encrypted LDAP secrets configured?
|
`tier`
| free, premium, ultimate |
|
`skip_validation`
| true |
## `settings.operating_system`
Information about the operating system running GitLab
| field | value |
| --- | --- |
|
`key_path`
|
**`settings.operating_system`**
|
|
`product_section`
| enablement |
|
`product_stage`
| enablement |
|
`product_group`
|
`group::distribution`
|
|
`product_category`
|
`collection`
|
|
`value_type`
| string |
|
`status`
| implemented |
|
`milestone`
| 13.10 |
|
`introduced_by_url`
|
[
Introduced by
](
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54778
)
|
|
`time_frame`
| none |
|
`data_source`
| Ruby |
|
`distribution`
| ce, ee |
|
`tier`
| free, premium, ultimate |
## `signup_enabled`
Whether public signup is enabled
...
...
ee/app/assets/stylesheets/pages/groups.scss
View file @
1bcf6be2
...
...
@@ -14,13 +14,23 @@
}
&
[
data-plan
=
'gold'
]
{
color
:
darken
(
$gl-gold-plan
,
20%
);
svg
g
{
fill
:
$gl-gold-plan
;
}
color
:
darken
(
$gl-ultimate-plan
,
20%
);
svg
g
{
fill
:
$gl-ultimate-plan
;
}
}
&
[
data-plan
=
'ultimate'
]
{
color
:
darken
(
$gl-ultimate-plan
,
20%
);
svg
g
{
fill
:
$gl-ultimate-plan
;
}
}
&
[
data-plan
=
'silver'
]
{
color
:
darken
(
$gl-silver-plan
,
20%
);
svg
g
{
fill
:
$gl-silver-plan
;
}
color
:
darken
(
$gl-premium-plan
,
20%
);
svg
g
{
fill
:
$gl-premium-plan
;
}
}
&
[
data-plan
=
'premium'
]
{
color
:
darken
(
$gl-premium-plan
,
20%
);
svg
g
{
fill
:
$gl-premium-plan
;
}
}
&
[
data-plan
=
'bronze'
]
{
...
...
lib/gitlab/usage_data.rb
View file @
1bcf6be2
...
...
@@ -242,7 +242,8 @@ module Gitlab
def
system_usage_data_settings
{
settings:
{
ldap_encrypted_secrets_enabled:
alt_usage_data
(
fallback:
nil
)
{
Gitlab
::
Auth
::
Ldap
::
Config
.
encrypted_secrets
.
active?
}
ldap_encrypted_secrets_enabled:
alt_usage_data
(
fallback:
nil
)
{
Gitlab
::
Auth
::
Ldap
::
Config
.
encrypted_secrets
.
active?
},
operating_system:
alt_usage_data
(
fallback:
nil
)
{
operating_system
}
}
}
end
...
...
@@ -505,6 +506,17 @@ module Gitlab
end
end
def
operating_system
ohai_data
=
Ohai
::
System
.
new
.
tap
do
|
oh
|
oh
.
all_plugins
([
'platform'
])
end
.
data
platform
=
ohai_data
[
'platform'
]
platform
=
'raspbian'
if
ohai_data
[
'platform'
]
==
'debian'
&&
/armv/
.
match?
(
ohai_data
[
'kernel'
][
'machine'
])
"
#{
platform
}
-
#{
ohai_data
[
'platform_version'
]
}
"
end
def
last_28_days_time_period
(
column: :created_at
)
{
column
=>
30
.
days
.
ago
..
2
.
days
.
ago
}
end
...
...
locale/gitlab.pot
View file @
1bcf6be2
...
...
@@ -34920,6 +34920,9 @@ msgstr ""
msgid "can't be enabled because signed commits are required for this project"
msgstr ""
msgid "can't include: %{invalid_storages}"
msgstr ""
msgid "cannot be a date in the past"
msgstr ""
...
...
@@ -36326,6 +36329,12 @@ msgstr ""
msgid "v%{version} published %{timeAgo}"
msgstr ""
msgid "value for '%{storage}' must be an integer"
msgstr ""
msgid "value for '%{storage}' must be between 0 and 100"
msgstr ""
msgid "verify ownership"
msgstr ""
...
...
rubocop/rubocop-usage-data.yml
View file @
1bcf6be2
...
...
@@ -30,6 +30,7 @@ UsageData/LargeTable:
-
:Settings
-
:CE_MEMOIZED_VALUES
-
:EE_MEMOIZED_VALUES
-
:Ohai::System
CountMethods
:
-
:count
-
:distinct_count
...
...
spec/controllers/admin/application_settings_controller_spec.rb
View file @
1bcf6be2
...
...
@@ -144,10 +144,10 @@ RSpec.describe Admin::ApplicationSettingsController do
end
it
'updates repository_storages_weighted setting'
do
put
:update
,
params:
{
application_setting:
{
repository_storages_weighted
_default:
75
}
}
put
:update
,
params:
{
application_setting:
{
repository_storages_weighted
:
{
default:
75
}
}
}
expect
(
response
).
to
redirect_to
(
general_admin_application_settings_path
)
expect
(
ApplicationSetting
.
current
.
repository_storages_weighted
_default
).
to
eq
(
75
)
expect
(
ApplicationSetting
.
current
.
repository_storages_weighted
).
to
eq
(
'default'
=>
75
)
end
it
'updates kroki_formats setting'
do
...
...
spec/features/admin/admin_settings_spec.rb
View file @
1bcf6be2
...
...
@@ -384,7 +384,20 @@ RSpec.describe 'Admin updates settings' do
click_button
'Save changes'
end
expect
(
current_settings
.
repository_storages_weighted_default
).
to
be
50
expect
(
current_settings
.
repository_storages_weighted
).
to
eq
(
'default'
=>
50
)
end
it
'still saves when settings are outdated'
do
current_settings
.
update_attribute
:repository_storages_weighted
,
{
'default'
=>
100
,
'outdated'
=>
100
}
visit
repository_admin_application_settings_path
page
.
within
(
'.as-repository-storage'
)
do
fill_in
'application_setting_repository_storages_weighted_default'
,
with:
50
click_button
'Save changes'
end
expect
(
current_settings
.
repository_storages_weighted
).
to
eq
(
'default'
=>
50
)
end
end
...
...
spec/helpers/application_settings_helper_spec.rb
View file @
1bcf6be2
...
...
@@ -130,20 +130,15 @@ RSpec.describe ApplicationSettingsHelper do
before
do
helper
.
instance_variable_set
(
:@application_setting
,
application_setting
)
stub_storage_settings
({
'default'
:
{},
'storage_1'
:
{},
'storage_2'
:
{}
})
allow
(
ApplicationSetting
).
to
receive
(
:repository_storages_weighted_attributes
).
and_return
(
[
:repository_storages_weighted_default
,
:repository_storages_weighted_storage_1
,
:repository_storages_weighted_storage_2
])
stub_application_setting
(
repository_storages_weighted:
{
'default'
=>
100
,
'storage_1'
=>
50
,
'storage_2'
=>
nil
})
end
it
'returns storages correctly'
do
expect
(
helper
.
storage_weights
).
to
eq
(
[
{
name: :repository_storages_weighted_default
,
label:
'default'
,
value:
100
}
,
{
name: :repository_storages_weighted_storage_1
,
label:
'storage_1'
,
value:
50
}
,
{
name: :repository_storages_weighted_storage_2
,
label:
'storage_2'
,
value:
0
}
]
)
expect
(
helper
.
storage_weights
).
to
eq
(
OpenStruct
.
new
(
default:
100
,
storage_1:
50
,
storage_2:
0
)
)
end
end
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
1bcf6be2
...
...
@@ -1129,12 +1129,40 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
end
describe
".operating_system"
do
let
(
:ohai_data
)
{
{
"platform"
=>
"ubuntu"
,
"platform_version"
=>
"20.04"
}
}
before
do
allow_next_instance_of
(
Ohai
::
System
)
do
|
ohai
|
allow
(
ohai
).
to
receive
(
:data
).
and_return
(
ohai_data
)
end
end
subject
{
described_class
.
operating_system
}
it
{
is_expected
.
to
eq
(
"ubuntu-20.04"
)
}
context
'when on Debian with armv architecture'
do
let
(
:ohai_data
)
{
{
"platform"
=>
"debian"
,
"platform_version"
=>
"10"
,
'kernel'
=>
{
'machine'
=>
'armv'
}
}
}
it
{
is_expected
.
to
eq
(
"raspbian-10"
)
}
end
end
describe
".system_usage_data_settings"
do
before
do
allow
(
described_class
).
to
receive
(
:operating_system
).
and_return
(
'ubuntu-20.04'
)
end
subject
{
described_class
.
system_usage_data_settings
}
it
'gathers settings usage data'
,
:aggregate_failures
do
expect
(
subject
[
:settings
][
:ldap_encrypted_secrets_enabled
]).
to
eq
(
Gitlab
::
Auth
::
Ldap
::
Config
.
encrypted_secrets
.
active?
)
end
it
'populates operating system information'
do
expect
(
subject
[
:settings
][
:operating_system
]).
to
eq
(
'ubuntu-20.04'
)
end
end
end
...
...
spec/models/application_setting_spec.rb
View file @
1bcf6be2
...
...
@@ -105,14 +105,14 @@ RSpec.describe ApplicationSetting do
it
{
is_expected
.
not_to
allow_value
(
false
).
for
(
:hashed_storage_enabled
)
}
it
{
is_expected
.
not_to
allow_value
(
101
).
for
(
:repository_storages_weighted_default
)
}
it
{
is_expected
.
to
allow_value
(
'
90'
).
for
(
:repository_storages_weighted_default
)
}
it
{
is_expected
.
not_to
allow_value
(
-
1
).
for
(
:repository_storages_weighted_default
)
}
it
{
is_expected
.
to
allow_value
(
100
).
for
(
:repository_storages_weighted_default
)
}
it
{
is_expected
.
to
allow_value
(
0
).
for
(
:repository_storages_weighted_default
)
}
it
{
is_expected
.
to
allow_value
(
50
).
for
(
:repository_storages_weighted_default
)
}
it
{
is_expected
.
to
allow_value
(
nil
).
for
(
:repository_storages_weighted_default
)
}
it
{
is_expected
.
not_to
allow_value
(
{
default:
100
,
shouldntexist:
50
}).
for
(
:repository_storages_weighted
)
}
it
{
is_expected
.
to
allow_value
(
'default'
=>
0
).
for
(
:repository_storages_weighted
)
}
it
{
is_expected
.
to
allow_value
(
'
default'
=>
50
).
for
(
:repository_storages_weighted
)
}
it
{
is_expected
.
to
allow_value
(
'default'
=>
100
).
for
(
:repository_storages_weighted
)
}
it
{
is_expected
.
to
allow_value
(
'default'
=>
'90'
).
for
(
:repository_storages_weighted
)
}
it
{
is_expected
.
to
allow_value
(
'default'
=>
nil
).
for
(
:repository_storages_weighted
)
}
it
{
is_expected
.
not_to
allow_value
(
'default'
=>
-
1
).
for
(
:repository_storages_weighted
).
with_message
(
"value for 'default' must be between 0 and 100"
)
}
it
{
is_expected
.
not_to
allow_value
(
'default'
=>
101
).
for
(
:repository_storages_weighted
).
with_message
(
"value for 'default' must be between 0 and 100"
)
}
it
{
is_expected
.
not_to
allow_value
(
'default'
=>
100
,
shouldntexist:
50
).
for
(
:repository_storages_weighted
).
with_message
(
"can't include: shouldntexist"
)
}
it
{
is_expected
.
to
allow_value
(
400
).
for
(
:notes_create_limit
)
}
it
{
is_expected
.
not_to
allow_value
(
'two'
).
for
(
:notes_create_limit
)
}
...
...
@@ -958,12 +958,6 @@ RSpec.describe ApplicationSetting do
it_behaves_like
'application settings examples'
describe
'repository_storages_weighted_attributes'
do
it
'returns the keys for repository_storages_weighted'
do
expect
(
subject
.
class
.
repository_storages_weighted_attributes
).
to
eq
([
:repository_storages_weighted_default
])
end
end
describe
'kroki_format_supported?'
do
it
'returns true when Excalidraw is enabled'
do
subject
.
kroki_formats_excalidraw
=
true
...
...
@@ -1007,11 +1001,4 @@ RSpec.describe ApplicationSetting do
expect
(
subject
.
kroki_formats_excalidraw
).
to
eq
(
true
)
end
end
it
'does not allow to set weight for non existing storage'
do
setting
.
repository_storages_weighted
=
{
invalid_storage:
100
}
expect
(
setting
).
not_to
be_valid
expect
(
setting
.
errors
.
messages
[
:repository_storages_weighted
]).
to
match_array
([
"can't include: invalid_storage"
])
end
end
spec/support/shared_examples/models/application_setting_shared_examples.rb
View file @
1bcf6be2
...
...
@@ -289,6 +289,7 @@ RSpec.shared_examples 'application settings examples' do
describe
'#pick_repository_storage'
do
before
do
allow
(
Gitlab
.
config
.
repositories
.
storages
).
to
receive
(
:keys
).
and_return
(
%w(default backup)
)
allow
(
setting
).
to
receive
(
:repository_storages_weighted
).
and_return
({
'default'
=>
20
,
'backup'
=>
80
})
end
...
...
@@ -304,15 +305,19 @@ RSpec.shared_examples 'application settings examples' do
describe
'#normalized_repository_storage_weights'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:storages
,
:normalized
)
do
{
'default'
=>
0
,
'backup'
=>
100
}
|
{
'default'
=>
0.0
,
'backup'
=>
1.0
}
{
'default'
=>
100
,
'backup'
=>
100
}
|
{
'default'
=>
0.5
,
'backup'
=>
0.5
}
{
'default'
=>
20
,
'backup'
=>
80
}
|
{
'default'
=>
0.2
,
'backup'
=>
0.8
}
{
'default'
=>
0
,
'backup'
=>
0
}
|
{
'default'
=>
0.0
,
'backup'
=>
0.0
}
where
(
:config_storages
,
:storages
,
:normalized
)
do
%w(default backup)
|
{
'default'
=>
0
,
'backup'
=>
100
}
|
{
'default'
=>
0.0
,
'backup'
=>
1.0
}
%w(default backup)
|
{
'default'
=>
100
,
'backup'
=>
100
}
|
{
'default'
=>
0.5
,
'backup'
=>
0.5
}
%w(default backup)
|
{
'default'
=>
20
,
'backup'
=>
80
}
|
{
'default'
=>
0.2
,
'backup'
=>
0.8
}
%w(default backup)
|
{
'default'
=>
0
,
'backup'
=>
0
}
|
{
'default'
=>
0.0
,
'backup'
=>
0.0
}
%w(default)
|
{
'default'
=>
0
,
'backup'
=>
100
}
|
{
'default'
=>
0.0
}
%w(default)
|
{
'default'
=>
100
,
'backup'
=>
100
}
|
{
'default'
=>
1.0
}
%w(default)
|
{
'default'
=>
20
,
'backup'
=>
80
}
|
{
'default'
=>
1.0
}
end
with_them
do
before
do
allow
(
Gitlab
.
config
.
repositories
.
storages
).
to
receive
(
:keys
).
and_return
(
config_storages
)
allow
(
setting
).
to
receive
(
:repository_storages_weighted
).
and_return
(
storages
)
end
...
...
spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb
View file @
1bcf6be2
...
...
@@ -3,34 +3,49 @@
require
'spec_helper'
RSpec
.
describe
'admin/application_settings/_repository_storage.html.haml'
do
let
(
:app_settings
)
{
create
(
:application_setting
)
}
let
(
:repository_storages_weighted_attributes
)
{
[
:repository_storages_weighted_default
,
:repository_storages_weighted_mepmep
,
:repository_storages_weighted_foobar
]}
let
(
:repository_storages_weighted
)
do
{
"default"
=>
100
,
"mepmep"
=>
50
}
end
let
(
:app_settings
)
{
build
(
:application_setting
,
repository_storages_weighted:
repository_storages_weighted
)
}
before
do
allow
(
app_settings
).
to
receive
(
:repository_storages_weighted
).
and_return
(
repository_storages_weighted
)
allow
(
app_settings
).
to
receive
(
:repository_storages_weighted_mepmep
).
and_return
(
100
)
allow
(
app_settings
).
to
receive
(
:repository_storages_weighted_foobar
).
and_return
(
50
)
stub_storage_settings
({
'default'
:
{},
'mepmep'
:
{},
'foobar'
:
{}
})
assign
(
:application_setting
,
app_settings
)
allow
(
ApplicationSetting
).
to
receive
(
:repository_storages_weighted_attributes
).
and_return
(
repository_storages_weighted_attributes
)
end
context
'when multiple storages are available'
do
context
'additional storage config'
do
let
(
:repository_storages_weighted
)
do
{
'default'
=>
100
,
'mepmep'
=>
50
}
end
it
'lists them all'
do
render
# lists storages that are saved with weights
repository_storages_weighted
.
each
do
|
storage_name
,
storage_weight
|
Gitlab
.
config
.
repositories
.
storages
.
keys
.
each
do
|
storage_name
|
expect
(
rendered
).
to
have_content
(
storage_name
)
end
# lists storage not saved with weight
expect
(
rendered
).
to
have_content
(
'foobar'
)
end
end
context
'fewer storage configs'
do
let
(
:repository_storages_weighted
)
do
{
'default'
=>
100
,
'mepmep'
=>
50
,
'something_old'
=>
100
}
end
it
'lists only configured storages'
do
render
Gitlab
.
config
.
repositories
.
storages
.
keys
.
each
do
|
storage_name
|
expect
(
rendered
).
to
have_content
(
storage_name
)
end
expect
(
rendered
).
not_to
have_content
(
'something_old'
)
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