Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
7747c98443
commit
7f12b2dc74
|
@ -49,7 +49,7 @@ export default {
|
|||
<div
|
||||
:class="[
|
||||
$options.EXTENSION_ICON_CLASS[iconName],
|
||||
{ 'mr-widget-extension-icon': !isLoading && level === 1 },
|
||||
{ 'mr-widget-extension-icon gl-w-6': !isLoading && level === 1 },
|
||||
{ 'gl-p-2': isLoading || level === 1 },
|
||||
]"
|
||||
class="gl-rounded-full gl-mr-3 gl-relative gl-p-2"
|
||||
|
|
|
@ -34,7 +34,7 @@ module LooseForeignKeys
|
|||
# If two DBs are configured (Main, CI): minute 1 -> Main, minute 2 -> CI
|
||||
def current_connection_name_and_base_model
|
||||
minutes_since_epoch = Time.current.to_i / 60
|
||||
connections_with_name = Gitlab::Database.database_base_models.to_a # this will never be empty
|
||||
connections_with_name = Gitlab::Database.database_base_models_with_gitlab_shared.to_a # this will never be empty
|
||||
connections_with_name[minutes_since_epoch % connections_with_name.count]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,7 @@ Each table of GitLab needs to have a `gitlab_schema` assigned:
|
|||
|
||||
- `gitlab_main`: describes all tables that are being stored in the `main:` database (for example, like `projects`, `users`).
|
||||
- `gitlab_ci`: describes all CI tables that are being stored in the `ci:` database (for example, `ci_pipelines`, `ci_builds`).
|
||||
- `gitlab_geo`: describes all Geo tables that are being stored in the `geo:` database (for example, like `project_registry`, `secondary_usage_data`).
|
||||
- `gitlab_shared`: describe all application tables that contain data across all decomposed databases (for example, `loose_foreign_keys_deleted_records`) for models that inherit from `Gitlab::Database::SharedModel`.
|
||||
- `gitlab_internal`: describe all internal tables of Rails and PostgreSQL (for example, `ar_internal_metadata`, `schema_migrations`, `pg_*`).
|
||||
- `...`: more schemas to be introduced with additional decomposed databases
|
||||
|
@ -34,6 +35,7 @@ The usage of schema enforces the base class to be used:
|
|||
|
||||
- `ApplicationRecord` for `gitlab_main`
|
||||
- `Ci::ApplicationRecord` for `gitlab_ci`
|
||||
- `Geo::TrackingBase` for `gitlab_geo`
|
||||
- `Gitlab::Database::SharedModel` for `gitlab_shared`
|
||||
|
||||
### The impact of `gitlab_schema`
|
||||
|
|
|
@ -63,6 +63,12 @@ The steps can be summed up to:
|
|||
piped script, you can first
|
||||
[check its contents](https://packages.gitlab.com/gitlab/gitlab-ee/install).
|
||||
|
||||
NOTE:
|
||||
If you want to use `dpkg`/`rpm` instead of `apt-get`/`yum`, go through the first
|
||||
step to find the current GitLab version, then follow
|
||||
[Update using a manually-downloaded package](index.md#upgrade-using-a-manually-downloaded-package),
|
||||
and then [add your license](../../user/admin_area/license.md).
|
||||
|
||||
1. Install the `gitlab-ee` package. The install automatically
|
||||
uninstalls the `gitlab-ce` package on your GitLab server. `reconfigure`
|
||||
Omnibus right after the `gitlab-ee` package is installed. **Make sure that you
|
||||
|
@ -91,8 +97,7 @@ The steps can be summed up to:
|
|||
sudo gitlab-ctl reconfigure
|
||||
```
|
||||
|
||||
1. Now go to the GitLab Admin Area of your server (`/admin/subscription`) and
|
||||
[add your license](../../user/admin_area/license.md).
|
||||
1. Now activate GitLab Enterprise Edition by [adding your license](../../user/admin_area/license.md).
|
||||
|
||||
1. After you confirm that GitLab is working as expected, you may remove the old
|
||||
Community Edition repository:
|
||||
|
@ -111,8 +116,3 @@ The steps can be summed up to:
|
|||
|
||||
That's it! You can now use GitLab Enterprise Edition! To update to a newer
|
||||
version, follow [Update using the official repositories](index.md#upgrade-using-the-official-repositories).
|
||||
|
||||
NOTE:
|
||||
If you want to use `dpkg`/`rpm` instead of `apt-get`/`yum`, go through the first
|
||||
step to find the current GitLab version and then follow
|
||||
[Update using a manually-downloaded package](index.md#upgrade-using-a-manually-downloaded-package).
|
||||
|
|
|
@ -372,14 +372,16 @@ The following topics document the **Monitoring** section of the Admin Area.
|
|||
|
||||
### System Information
|
||||
|
||||
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/341248) in GitLab 15.2, support for relative time. "Uptime" statistic was renamed to "System started".
|
||||
|
||||
The **System Info** page provides the following statistics:
|
||||
|
||||
| Field | Description |
|
||||
|:-------------|:------------|
|
||||
| CPU | Number of CPU cores available |
|
||||
| Memory Usage | Memory in use, and total memory available |
|
||||
| Disk Usage | Disk space in use, and total disk space available |
|
||||
| Uptime | Approximate uptime of the GitLab instance |
|
||||
| Field | Description |
|
||||
|:---------------|:--------------------------------------------------|
|
||||
| CPU | Number of CPU cores available |
|
||||
| Memory Usage | Memory in use, and total memory available |
|
||||
| Disk Usage | Disk space in use, and total disk space available |
|
||||
| System started | When the system hosting GitLab was started. In GitLab 15.1 and earlier, this was an uptime statistic. |
|
||||
|
||||
These statistics are updated only when you navigate to the **System Info** page, or you refresh the page in your browser.
|
||||
|
||||
|
|
|
@ -75,12 +75,10 @@ draft merge requests:
|
|||
|
||||
## Pipelines for drafts
|
||||
|
||||
When the [merged results pipelines](../../../ci/pipelines/merged_results_pipelines.md)
|
||||
feature is enabled, draft merge requests run
|
||||
[merge request pipelines](../../../ci/pipelines/merge_request_pipelines.md) only.
|
||||
Draft merge requests run the same pipelines as merge request that are marked as ready.
|
||||
|
||||
To run merged results pipelines, you must
|
||||
[mark the merge request as ready](#mark-merge-requests-as-ready).
|
||||
In GitLab 15.0 and older, you must [mark the merge request as ready](#mark-merge-requests-as-ready)
|
||||
if you want to run [merged results pipelines](../../../ci/pipelines/merged_results_pipelines.md).
|
||||
|
||||
<!-- ## Troubleshooting
|
||||
|
||||
|
|
|
@ -63,13 +63,45 @@ module Gitlab
|
|||
}.compact.with_indifferent_access.freeze
|
||||
end
|
||||
|
||||
# This returns a list of databases that contains all the gitlab_shared schema
|
||||
# tables. We can't reuse database_base_models because Geo does not support
|
||||
# the gitlab_shared tables yet.
|
||||
def self.database_base_models_with_gitlab_shared
|
||||
@database_base_models_with_gitlab_shared ||= {
|
||||
# Note that we use ActiveRecord::Base here and not ApplicationRecord.
|
||||
# This is deliberate, as we also use these classes to apply load
|
||||
# balancing to, and the load balancer must be enabled for _all_ models
|
||||
# that inher from ActiveRecord::Base; not just our own models that
|
||||
# inherit from ApplicationRecord.
|
||||
main: ::ActiveRecord::Base,
|
||||
ci: ::Ci::ApplicationRecord.connection_class? ? ::Ci::ApplicationRecord : nil
|
||||
}.compact.with_indifferent_access.freeze
|
||||
end
|
||||
|
||||
# This returns a list of databases whose connection supports database load
|
||||
# balancing. We can't reuse the database_base_models method because the Geo
|
||||
# database does not support load balancing yet.
|
||||
#
|
||||
# TODO: https://gitlab.com/gitlab-org/geo-team/discussions/-/issues/5032
|
||||
def self.database_base_models_using_load_balancing
|
||||
@database_base_models_with_gitlab_shared ||= {
|
||||
# Note that we use ActiveRecord::Base here and not ApplicationRecord.
|
||||
# This is deliberate, as we also use these classes to apply load
|
||||
# balancing to, and the load balancer must be enabled for _all_ models
|
||||
# that inher from ActiveRecord::Base; not just our own models that
|
||||
# inherit from ApplicationRecord.
|
||||
main: ::ActiveRecord::Base,
|
||||
ci: ::Ci::ApplicationRecord.connection_class? ? ::Ci::ApplicationRecord : nil
|
||||
}.compact.with_indifferent_access.freeze
|
||||
end
|
||||
|
||||
# This returns a list of base models with connection associated for a given gitlab_schema
|
||||
def self.schemas_to_base_models
|
||||
@schemas_to_base_models ||= {
|
||||
gitlab_main: [self.database_base_models.fetch(:main)],
|
||||
gitlab_ci: [self.database_base_models[:ci] || self.database_base_models.fetch(:main)], # use CI or fallback to main
|
||||
gitlab_shared: self.database_base_models.values, # all models
|
||||
gitlab_internal: self.database_base_models.values # all models
|
||||
gitlab_shared: database_base_models_with_gitlab_shared.values, # all models
|
||||
gitlab_internal: database_base_models.values # all models
|
||||
}.with_indifferent_access.freeze
|
||||
end
|
||||
|
||||
|
@ -168,7 +200,7 @@ module Gitlab
|
|||
# can potentially upgrade from read to read-write mode (using a different connection), we specify
|
||||
# up-front that we'll explicitly use the primary for the duration of the operation.
|
||||
Gitlab::Database::LoadBalancing::Session.current.use_primary do
|
||||
base_models = database_base_models.values
|
||||
base_models = database_base_models_using_load_balancing.values
|
||||
base_models.reduce(block) { |blk, model| -> { model.uncached(&blk) } }.call
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,8 +36,7 @@ module Gitlab
|
|||
private
|
||||
|
||||
def select_base_models(names)
|
||||
base_models = Gitlab::Database.database_base_models
|
||||
|
||||
base_models = Gitlab::Database.database_base_models_with_gitlab_shared
|
||||
return base_models if names.empty?
|
||||
|
||||
names.each_with_object(HashWithIndifferentAccess.new) do |name, hash|
|
||||
|
@ -48,7 +47,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def with_shared_model_connections(shared_model, selected_databases, &blk)
|
||||
Gitlab::Database.database_base_models.each_pair do |connection_name, connection_model|
|
||||
Gitlab::Database.database_base_models_with_gitlab_shared.each_pair do |connection_name, connection_model|
|
||||
if shared_model.limit_connection_names
|
||||
next unless shared_model.limit_connection_names.include?(connection_name.to_sym)
|
||||
end
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
module Gitlab
|
||||
module Database
|
||||
module GitlabSchema
|
||||
GITLAB_SCHEMAS_FILE = 'lib/gitlab/database/gitlab_schemas.yml'
|
||||
|
||||
# These tables are deleted/renamed, but still referenced by migrations.
|
||||
# This is needed for now, but should be removed in the future
|
||||
DELETED_TABLES = {
|
||||
|
@ -93,7 +95,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def self.tables_to_schema
|
||||
@tables_to_schema ||= YAML.load_file(Rails.root.join('lib/gitlab/database/gitlab_schemas.yml'))
|
||||
@tables_to_schema ||= YAML.load_file(Rails.root.join(GITLAB_SCHEMAS_FILE))
|
||||
end
|
||||
|
||||
def self.schema_names
|
||||
|
@ -102,3 +104,5 @@ module Gitlab
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
Gitlab::Database::GitlabSchema.prepend_mod
|
||||
|
|
|
@ -19,7 +19,7 @@ module Gitlab
|
|||
].freeze
|
||||
|
||||
def self.base_models
|
||||
@base_models ||= ::Gitlab::Database.database_base_models.values.freeze
|
||||
@base_models ||= ::Gitlab::Database.database_base_models_using_load_balancing.values.freeze
|
||||
end
|
||||
|
||||
def self.each_load_balancer
|
||||
|
|
|
@ -193,6 +193,8 @@ module Gitlab
|
|||
results = redis.hmget(key, file_paths)
|
||||
end
|
||||
|
||||
record_hit_ratio(results)
|
||||
|
||||
results.map! do |result|
|
||||
Gitlab::Json.parse(gzip_decompress(result), symbolize_names: true) unless result.nil?
|
||||
end
|
||||
|
@ -215,6 +217,11 @@ module Gitlab
|
|||
def current_transaction
|
||||
::Gitlab::Metrics::WebTransaction.current
|
||||
end
|
||||
|
||||
def record_hit_ratio(results)
|
||||
current_transaction&.increment(:gitlab_redis_diff_caching_requests_total)
|
||||
current_transaction&.increment(:gitlab_redis_diff_caching_hits_total) if results.any?(&:present?)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -186,7 +186,10 @@ module Gitlab
|
|||
end
|
||||
|
||||
::Gitlab::Database.database_base_models.keys.each do |config_name|
|
||||
counters << compose_metric_key(metric, nil, config_name) # main / ci
|
||||
counters << compose_metric_key(metric, nil, config_name) # main / ci / geo
|
||||
end
|
||||
|
||||
::Gitlab::Database.database_base_models_using_load_balancing.keys.each do |config_name|
|
||||
counters << compose_metric_key(metric, nil, config_name + ::Gitlab::Database::LoadBalancing::LoadBalancer::REPLICA_SUFFIX) # main_replica / ci_replica
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,9 +37,18 @@ module Gitlab
|
|||
].freeze
|
||||
|
||||
CATEGORIES_COLLECTED_FROM_METRICS_DEFINITIONS = %w[
|
||||
ci_users
|
||||
error_tracking
|
||||
ide_edit
|
||||
importer
|
||||
incident_management_alerts
|
||||
pipeline_authoring
|
||||
secure
|
||||
snippets
|
||||
source_code
|
||||
terraform
|
||||
testing
|
||||
work_items
|
||||
].freeze
|
||||
|
||||
# Track event on entity_id
|
||||
|
|
|
@ -9,8 +9,3 @@
|
|||
redis_slot: users
|
||||
aggregation: weekly
|
||||
feature_flag: track_work_items_activity
|
||||
- name: users_updating_weight_estimate
|
||||
category: work_items
|
||||
redis_slot: users
|
||||
aggregation: weekly
|
||||
feature_flag: track_work_items_activity
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace :gitlab do
|
|||
connection = Gitlab::Database.database_base_models['main'].connection
|
||||
databases_loaded << configure_database(connection)
|
||||
else
|
||||
Gitlab::Database.database_base_models.each do |name, model|
|
||||
Gitlab::Database.database_base_models_with_gitlab_shared.each do |name, model|
|
||||
next unless databases_with_tasks.any? { |db_with_tasks| db_with_tasks.name == name }
|
||||
|
||||
databases_loaded << configure_database(model.connection, database_name: name)
|
||||
|
|
|
@ -11,6 +11,9 @@ namespace :gitlab do
|
|||
|
||||
schemas_for_connection = Gitlab::Database.gitlab_schemas_for_connection(connection)
|
||||
Gitlab::Database::GitlabSchema.tables_to_schema.each do |table_name, schema_name|
|
||||
# TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/366834
|
||||
next if schema_name == :gitlab_geo
|
||||
|
||||
if schemas_for_connection.include?(schema_name.to_sym)
|
||||
drop_write_trigger(database_name, connection, table_name)
|
||||
else
|
||||
|
@ -24,6 +27,9 @@ namespace :gitlab do
|
|||
task unlock_writes: :environment do
|
||||
Gitlab::Database::EachDatabase.each_database_connection do |connection, database_name|
|
||||
Gitlab::Database::GitlabSchema.tables_to_schema.each do |table_name, schema_name|
|
||||
# TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/366834
|
||||
next if schema_name == :gitlab_geo
|
||||
|
||||
drop_write_trigger(database_name, connection, table_name)
|
||||
end
|
||||
drop_write_trigger_function(connection)
|
||||
|
|
|
@ -4,8 +4,11 @@ require 'spec_helper'
|
|||
|
||||
RSpec.describe 'Database Documentation' do
|
||||
context 'for each table' do
|
||||
# TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/366834
|
||||
let(:database_base_models) { Gitlab::Database.database_base_models.select { |k, _| k != 'geo' } }
|
||||
|
||||
let(:all_tables) do
|
||||
Gitlab::Database.database_base_models.flat_map { |_, m| m.connection.tables }.sort.uniq
|
||||
database_base_models.flat_map { |_, m| m.connection.tables }.sort.uniq
|
||||
end
|
||||
|
||||
let(:metadata_required_fields) do
|
||||
|
|
|
@ -4,9 +4,10 @@ require 'spec_helper'
|
|||
|
||||
RSpec.describe Gitlab::Database::EachDatabase do
|
||||
describe '.each_database_connection', :add_ci_connection do
|
||||
let(:database_base_models) { { main: ActiveRecord::Base, ci: Ci::ApplicationRecord }.with_indifferent_access }
|
||||
|
||||
before do
|
||||
allow(Gitlab::Database).to receive(:database_base_models)
|
||||
.and_return({ main: ActiveRecord::Base, ci: Ci::ApplicationRecord }.with_indifferent_access)
|
||||
allow(Gitlab::Database).to receive(:database_base_models_with_gitlab_shared).and_return(database_base_models)
|
||||
end
|
||||
|
||||
it 'yields each connection after connecting SharedModel' do
|
||||
|
@ -60,12 +61,20 @@ RSpec.describe Gitlab::Database::EachDatabase do
|
|||
end
|
||||
|
||||
context 'when shared connections are not included' do
|
||||
def clear_memoization(key)
|
||||
Gitlab::Database.remove_instance_variable(key) if Gitlab::Database.instance_variable_defined?(key)
|
||||
end
|
||||
|
||||
before do
|
||||
allow(Gitlab::Database).to receive(:database_base_models).and_return(database_base_models)
|
||||
|
||||
# Clear the memoization because the return of Gitlab::Database#schemas_to_base_models depends stubbed value
|
||||
clear_memoization(:@schemas_to_base_models)
|
||||
clear_memoization(:@schemas_to_base_models_ee)
|
||||
end
|
||||
|
||||
it 'only yields the unshared connections' do
|
||||
if Gitlab::Database.has_config?(:ci)
|
||||
expect(Gitlab::Database).to receive(:db_config_share_with).exactly(3).times.and_return(nil, 'main', 'main')
|
||||
else
|
||||
expect(Gitlab::Database).to receive(:db_config_share_with).twice.and_return(nil, 'main')
|
||||
end
|
||||
expect(Gitlab::Database).to receive(:db_config_share_with).exactly(3).times.and_return(nil, 'main', 'main')
|
||||
|
||||
expect { |b| described_class.each_database_connection(include_shared: false, &b) }
|
||||
.to yield_successive_args([ActiveRecord::Base.connection, 'main'])
|
||||
|
@ -79,7 +88,7 @@ RSpec.describe Gitlab::Database::EachDatabase do
|
|||
let(:model2) { Class.new(Gitlab::Database::SharedModel) }
|
||||
|
||||
before do
|
||||
allow(Gitlab::Database).to receive(:database_base_models)
|
||||
allow(Gitlab::Database).to receive(:database_base_models_with_gitlab_shared)
|
||||
.and_return({ main: ActiveRecord::Base, ci: Ci::ApplicationRecord }.with_indifferent_access)
|
||||
end
|
||||
|
||||
|
@ -136,7 +145,7 @@ RSpec.describe Gitlab::Database::EachDatabase do
|
|||
let(:ci_model) { Class.new(Ci::ApplicationRecord) }
|
||||
|
||||
before do
|
||||
allow(Gitlab::Database).to receive(:database_base_models)
|
||||
allow(Gitlab::Database).to receive(:database_base_models_with_gitlab_shared)
|
||||
.and_return({ main: ActiveRecord::Base, ci: Ci::ApplicationRecord }.with_indifferent_access)
|
||||
|
||||
allow(main_model).to receive_message_chain('connection_db_config.name').and_return('main')
|
||||
|
|
|
@ -3,26 +3,27 @@ require 'spec_helper'
|
|||
|
||||
RSpec.describe Gitlab::Database::GitlabSchema do
|
||||
describe '.tables_to_schema' do
|
||||
subject { described_class.tables_to_schema }
|
||||
|
||||
it 'all tables have assigned a known gitlab_schema' do
|
||||
is_expected.to all(
|
||||
match([be_a(String), be_in([:gitlab_internal, :gitlab_shared, :gitlab_main, :gitlab_ci])])
|
||||
expect(described_class.tables_to_schema).to all(
|
||||
match([be_a(String), be_in(Gitlab::Database.schemas_to_base_models.keys.map(&:to_sym))])
|
||||
)
|
||||
end
|
||||
|
||||
# This being run across different databases indirectly also tests
|
||||
# a general consistency of structure across databases
|
||||
Gitlab::Database.database_base_models.each do |db_config_name, db_class|
|
||||
let(:db_data_sources) { db_class.connection.data_sources }
|
||||
|
||||
Gitlab::Database.database_base_models.select { |k, _| k != 'geo' }.each do |db_config_name, db_class|
|
||||
context "for #{db_config_name} using #{db_class}" do
|
||||
let(:db_data_sources) { db_class.connection.data_sources }
|
||||
|
||||
# The Geo database does not share the same structure as all decomposed databases
|
||||
subject { described_class.tables_to_schema.select { |_, v| v != :gitlab_geo } }
|
||||
|
||||
it 'new data sources are added' do
|
||||
missing_tables = db_data_sources.to_set - subject.keys
|
||||
|
||||
expect(missing_tables).to be_empty, \
|
||||
"Missing table(s) #{missing_tables.to_a} not found in #{described_class}.tables_to_schema. " \
|
||||
"Any new tables must be added to lib/gitlab/database/gitlab_schemas.yml."
|
||||
"Any new tables must be added to #{described_class::GITLAB_SCHEMAS_FILE}."
|
||||
end
|
||||
|
||||
it 'non-existing data sources are removed' do
|
||||
|
@ -30,7 +31,7 @@ RSpec.describe Gitlab::Database::GitlabSchema do
|
|||
|
||||
expect(extra_tables).to be_empty, \
|
||||
"Extra table(s) #{extra_tables.to_a} found in #{described_class}.tables_to_schema. " \
|
||||
"Any removed or renamed tables must be removed from lib/gitlab/database/gitlab_schemas.yml."
|
||||
"Any removed or renamed tables must be removed from #{described_class::GITLAB_SCHEMAS_FILE}."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ RSpec.describe Gitlab::Database::Migrations::ReestablishedConnectionStack do
|
|||
end
|
||||
|
||||
describe '#with_restored_connection_stack' do
|
||||
Gitlab::Database.database_base_models.each do |db_config_name, _|
|
||||
Gitlab::Database.database_base_models_with_gitlab_shared.each do |db_config_name, _|
|
||||
context db_config_name do
|
||||
it_behaves_like "reconfigures connection stack", db_config_name do
|
||||
it 'does restore connection hierarchy' do
|
||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe Gitlab::Database::Reindexing do
|
|||
include Database::DatabaseHelpers
|
||||
|
||||
describe '.invoke' do
|
||||
let(:databases) { Gitlab::Database.database_base_models }
|
||||
let(:databases) { Gitlab::Database.database_base_models_with_gitlab_shared }
|
||||
let(:databases_count) { databases.count }
|
||||
|
||||
it 'cleans up any leftover indexes' do
|
||||
|
|
|
@ -337,7 +337,7 @@ RSpec.describe Gitlab::Database do
|
|||
let(:model2) { Class.new(base_model) }
|
||||
|
||||
before do
|
||||
allow(described_class).to receive(:database_base_models)
|
||||
allow(described_class).to receive(:database_base_models_using_load_balancing)
|
||||
.and_return({ model1: model1, model2: model2 }.with_indifferent_access)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do
|
||||
let(:merge_request) { create(:merge_request_with_diffs) }
|
||||
let_it_be(:merge_request) { create(:merge_request_with_diffs) }
|
||||
|
||||
let(:diff_hash) do
|
||||
{ ".gitignore-false-false-false" =>
|
||||
[{ line_code: nil, rich_text: nil, text: "@@ -17,3 +17,4 @@ rerun.txt", type: "match", index: 0, old_pos: 17, new_pos: 17 },
|
||||
|
@ -229,10 +230,10 @@ RSpec.describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do
|
|||
end
|
||||
|
||||
describe 'metrics' do
|
||||
let(:transaction) { Gitlab::Metrics::WebTransaction.new({} ) }
|
||||
let(:transaction) { Gitlab::Metrics::WebTransaction.new({}) }
|
||||
|
||||
before do
|
||||
allow(cache).to receive(:current_transaction).and_return(transaction)
|
||||
allow(::Gitlab::Metrics::WebTransaction).to receive(:current).and_return(transaction)
|
||||
end
|
||||
|
||||
it 'observes :gitlab_redis_diff_caching_memory_usage_bytes' do
|
||||
|
@ -241,6 +242,18 @@ RSpec.describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do
|
|||
|
||||
cache.write_if_empty
|
||||
end
|
||||
|
||||
it 'records hit ratio metrics' do
|
||||
expect(transaction)
|
||||
.to receive(:increment).with(:gitlab_redis_diff_caching_requests_total).exactly(5).times
|
||||
expect(transaction)
|
||||
.to receive(:increment).with(:gitlab_redis_diff_caching_hits_total).exactly(4).times
|
||||
|
||||
5.times do
|
||||
cache = described_class.new(merge_request.diffs)
|
||||
cache.write_if_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#key' do
|
||||
|
|
|
@ -5,7 +5,7 @@ require 'spec_helper'
|
|||
RSpec.describe WorkItems::TaskListReferenceRemovalService do
|
||||
let_it_be(:developer) { create(:user) }
|
||||
let_it_be(:project) { create(:project, :repository).tap { |project| project.add_developer(developer) } }
|
||||
let_it_be(:task) { create(:work_item, project: project) }
|
||||
let_it_be(:task) { create(:work_item, project: project, title: 'Task title') }
|
||||
let_it_be(:single_line_work_item, refind: true) do
|
||||
create(:work_item, project: project, description: "- [ ] #{task.to_reference}+ single line")
|
||||
end
|
||||
|
@ -82,7 +82,7 @@ RSpec.describe WorkItems::TaskListReferenceRemovalService do
|
|||
let(:line_number_end) { 1 }
|
||||
let(:work_item) { single_line_work_item }
|
||||
|
||||
it_behaves_like 'successful work item task reference removal service', '- [ ] My title 1 single line'
|
||||
it_behaves_like 'successful work item task reference removal service', '- [ ] Task title single line'
|
||||
|
||||
context 'when description does not contain a task' do
|
||||
let_it_be(:no_matching_work_item) { create(:work_item, project: project, description: 'no matching task') }
|
||||
|
@ -103,7 +103,7 @@ RSpec.describe WorkItems::TaskListReferenceRemovalService do
|
|||
|
||||
context 'when task mardown spans multiple lines' do
|
||||
it_behaves_like 'successful work item task reference removal service',
|
||||
"Any text\n\n* [ ] Item to be converted\n My title 1 second line\n third line\n* [x] task\n\nMore text"
|
||||
"Any text\n\n* [ ] Item to be converted\n Task title second line\n third line\n* [x] task\n\nMore text"
|
||||
end
|
||||
|
||||
context 'when updating the work item fails' do
|
||||
|
|
|
@ -23,7 +23,7 @@ RSpec.describe 'dev rake tasks' do
|
|||
|
||||
subject(:setup_task) { run_rake_task('dev:setup') }
|
||||
|
||||
let(:connections) { Gitlab::Database.database_base_models.values.map(&:connection) }
|
||||
let(:connections) { Gitlab::Database.database_base_models_with_gitlab_shared.values.map(&:connection) }
|
||||
|
||||
it 'sets up the development environment', :aggregate_failures do
|
||||
expect(Rake::Task['gitlab:setup']).to receive(:invoke)
|
||||
|
@ -55,7 +55,7 @@ RSpec.describe 'dev rake tasks' do
|
|||
end
|
||||
|
||||
let(:connections) do
|
||||
Gitlab::Database.database_base_models.values.filter_map do |model|
|
||||
Gitlab::Database.database_base_models_with_gitlab_shared.values.filter_map do |model|
|
||||
model.connection if Gitlab::Database.db_config_share_with(model.connection_db_config).nil?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
|
|||
before do
|
||||
skip_unless_ci_uses_database_tasks
|
||||
|
||||
allow(Gitlab::Database).to receive(:database_base_models).and_return(base_models)
|
||||
allow(Gitlab::Database).to receive(:database_base_models_with_gitlab_shared).and_return(base_models)
|
||||
end
|
||||
|
||||
it 'marks the migration complete on each database' do
|
||||
|
@ -90,7 +90,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
|
|||
let(:base_models) { { 'main' => main_model } }
|
||||
|
||||
before do
|
||||
allow(Gitlab::Database).to receive(:database_base_models).and_return(base_models)
|
||||
allow(Gitlab::Database).to receive(:database_base_models_with_gitlab_shared).and_return(base_models)
|
||||
end
|
||||
|
||||
it 'prints a warning message' do
|
||||
|
@ -110,7 +110,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
|
|||
let(:base_models) { { 'main' => main_model } }
|
||||
|
||||
before do
|
||||
allow(Gitlab::Database).to receive(:database_base_models).and_return(base_models)
|
||||
allow(Gitlab::Database).to receive(:database_base_models_with_gitlab_shared).and_return(base_models)
|
||||
end
|
||||
|
||||
it 'prints an error and exits' do
|
||||
|
@ -136,6 +136,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
|
|||
context 'when geo is not configured' do
|
||||
before do
|
||||
allow(ActiveRecord::Base).to receive_message_chain('configurations.configs_for').and_return([main_config])
|
||||
allow(Gitlab::Database).to receive(:has_config?).with(:geo).and_return(false)
|
||||
end
|
||||
|
||||
context 'when the schema is already loaded' do
|
||||
|
@ -260,7 +261,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
|
|||
before do
|
||||
skip_unless_ci_uses_database_tasks
|
||||
|
||||
allow(Gitlab::Database).to receive(:database_base_models).and_return(base_models)
|
||||
allow(Gitlab::Database).to receive(:database_base_models_with_gitlab_shared).and_return(base_models)
|
||||
end
|
||||
|
||||
context 'when geo is not configured' do
|
||||
|
@ -444,7 +445,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
|
|||
before do
|
||||
skip_unless_ci_uses_database_tasks
|
||||
|
||||
allow(Gitlab::Database).to receive(:database_base_models).and_return(base_models)
|
||||
allow(Gitlab::Database).to receive(:database_base_models_with_gitlab_shared).and_return(base_models)
|
||||
|
||||
allow(main_model.connection).to receive(:table_exists?).with('schema_migrations').and_return(true)
|
||||
allow(ci_model.connection).to receive(:table_exists?).with('schema_migrations').and_return(true)
|
||||
|
@ -574,7 +575,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do
|
|||
before do
|
||||
skip_if_multiple_databases_not_setup
|
||||
|
||||
allow(Gitlab::Database).to receive(:database_base_models).and_return(base_models)
|
||||
allow(Gitlab::Database).to receive(:database_base_models_with_gitlab_shared).and_return(base_models)
|
||||
end
|
||||
|
||||
it 'delegates to Gitlab::Database::Reindexing without a specific database' do
|
||||
|
|
|
@ -169,7 +169,7 @@ RSpec.describe LooseForeignKeys::CleanupWorker do
|
|||
let(:expected_connection) { expected_connection_model.constantize.connection }
|
||||
|
||||
before do
|
||||
allow(Gitlab::Database).to receive(:database_base_models).and_return(database_base_models)
|
||||
allow(Gitlab::Database).to receive(:database_base_models_with_gitlab_shared).and_return(database_base_models)
|
||||
|
||||
if database_base_models.has_key?(:ci)
|
||||
Gitlab::Database::SharedModel.using_connection(database_base_models[:ci].connection) do
|
||||
|
|
Loading…
Reference in New Issue