diff options
Diffstat (limited to 'spec/lib/gitlab/database/query_analyzers')
-rw-r--r-- | spec/lib/gitlab/database/query_analyzers/gitlab_schemas_metrics_spec.rb | 73 |
1 files changed, 5 insertions, 68 deletions
diff --git a/spec/lib/gitlab/database/query_analyzers/gitlab_schemas_metrics_spec.rb b/spec/lib/gitlab/database/query_analyzers/gitlab_schemas_metrics_spec.rb index 0d687db0f96..62c5ead855a 100644 --- a/spec/lib/gitlab/database/query_analyzers/gitlab_schemas_metrics_spec.rb +++ b/spec/lib/gitlab/database/query_analyzers/gitlab_schemas_metrics_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Gitlab::Database::QueryAnalyzers::GitlabSchemasMetrics, query_ana process_sql(ActiveRecord::Base, "SELECT 1 FROM projects") end - context 'properly observes all queries', :add_ci_connection, :request_store do + context 'properly observes all queries', :add_ci_connection do using RSpec::Parameterized::TableSyntax where do @@ -28,8 +28,7 @@ RSpec.describe Gitlab::Database::QueryAnalyzers::GitlabSchemasMetrics, query_ana expectations: { gitlab_schemas: "gitlab_main", db_config_name: "main" - }, - setup: nil + } }, "for query accessing gitlab_ci and gitlab_main" => { model: ApplicationRecord, @@ -37,8 +36,7 @@ RSpec.describe Gitlab::Database::QueryAnalyzers::GitlabSchemasMetrics, query_ana expectations: { gitlab_schemas: "gitlab_ci,gitlab_main", db_config_name: "main" - }, - setup: nil + } }, "for query accessing gitlab_ci and gitlab_main the gitlab_schemas is always ordered" => { model: ApplicationRecord, @@ -46,8 +44,7 @@ RSpec.describe Gitlab::Database::QueryAnalyzers::GitlabSchemasMetrics, query_ana expectations: { gitlab_schemas: "gitlab_ci,gitlab_main", db_config_name: "main" - }, - setup: nil + } }, "for query accessing CI database" => { model: Ci::ApplicationRecord, @@ -56,62 +53,6 @@ RSpec.describe Gitlab::Database::QueryAnalyzers::GitlabSchemasMetrics, query_ana gitlab_schemas: "gitlab_ci", db_config_name: "ci" } - }, - "for query accessing CI database with re-use and disabled sharing" => { - model: Ci::ApplicationRecord, - sql: "SELECT 1 FROM ci_builds", - expectations: { - gitlab_schemas: "gitlab_ci", - db_config_name: "ci", - ci_dedicated_primary_connection: true - }, - setup: ->(_) do - skip_if_multiple_databases_not_setup - stub_env('GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci', 'main') - stub_feature_flags(force_no_sharing_primary_model: true) - end - }, - "for query accessing CI database with re-use and enabled sharing" => { - model: Ci::ApplicationRecord, - sql: "SELECT 1 FROM ci_builds", - expectations: { - gitlab_schemas: "gitlab_ci", - db_config_name: "ci", - ci_dedicated_primary_connection: false - }, - setup: ->(_) do - skip_if_multiple_databases_not_setup - stub_env('GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci', 'main') - stub_feature_flags(force_no_sharing_primary_model: false) - end - }, - "for query accessing CI database without re-use and disabled sharing" => { - model: Ci::ApplicationRecord, - sql: "SELECT 1 FROM ci_builds", - expectations: { - gitlab_schemas: "gitlab_ci", - db_config_name: "ci", - ci_dedicated_primary_connection: true - }, - setup: ->(_) do - skip_if_multiple_databases_not_setup - stub_env('GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci', nil) - stub_feature_flags(force_no_sharing_primary_model: true) - end - }, - "for query accessing CI database without re-use and enabled sharing" => { - model: Ci::ApplicationRecord, - sql: "SELECT 1 FROM ci_builds", - expectations: { - gitlab_schemas: "gitlab_ci", - db_config_name: "ci", - ci_dedicated_primary_connection: true - }, - setup: ->(_) do - skip_if_multiple_databases_not_setup - stub_env('GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci', nil) - stub_feature_flags(force_no_sharing_primary_model: false) - end } } end @@ -122,15 +63,11 @@ RSpec.describe Gitlab::Database::QueryAnalyzers::GitlabSchemasMetrics, query_ana end it do - stub_env('GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci', nil) - - instance_eval(&setup) if setup - allow(::Ci::ApplicationRecord.load_balancer).to receive(:configuration) .and_return(Gitlab::Database::LoadBalancing::Configuration.for_model(::Ci::ApplicationRecord)) expect(described_class.schemas_metrics).to receive(:increment) - .with({ ci_dedicated_primary_connection: anything }.merge(expectations)).and_call_original + .with(expectations).and_call_original process_sql(model, sql) end |