Class: Gitlab::QA::Runtime::OmnibusConfigurations::DecompositionMultipleDb

Inherits:
Default show all
Defined in:
lib/gitlab/qa/runtime/omnibus_configurations/decomposition_multiple_db.rb

Constant Summary collapse

DATABASE_EXISTENCE_CHECK_COMMAND =
<<~CMD.chomp
  gitlab-psql -d gitlabhq_production_ci -c 'select 1' 2>1 > /dev/null
CMD
SCHEMA_EXISTENCE_CHECK_COMMAND =
<<~CMD.chomp
  gitlab-psql -d gitlabhq_production_ci -c "select schema_name from information_schema.schemata where schema_name = 'gitlab_partitions_dynamic'" | grep -q gitlab_partitions_dynamic
CMD

Constants inherited from Gitlab::QA::Runtime::OmnibusConfiguration

Gitlab::QA::Runtime::OmnibusConfiguration::ERB_PATTERN

Instance Method Summary collapse

Methods inherited from Default

configuration

Methods inherited from Gitlab::QA::Runtime::OmnibusConfiguration

#<<, #expand_config_template, #initialize, #prepare, #sanitize!, #to_s

Constructor Details

This class inherits a constructor from Gitlab::QA::Runtime::OmnibusConfiguration

Instance Method Details

#configurationObject



16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/qa/runtime/omnibus_configurations/decomposition_multiple_db.rb', line 16

def configuration
  # HACK: commenting commands out as these commands should be run *after* the first
  # reconfiguration (see first command in #exec_commands)
  <<~OMNIBUS
    #gitlab_rails['databases']['main']['enable'] = true
    #gitlab_rails['databases']['ci']['enable'] = true
    #gitlab_rails['databases']['ci']['db_database'] = 'gitlabhq_production_ci'
  OMNIBUS
end

#exec_commandsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/gitlab/qa/runtime/omnibus_configurations/decomposition_multiple_db.rb', line 26

def exec_commands
  [
    "sed -i 's/#gitlab_rails/gitlab_rails/g' /etc/gitlab/gitlab.rb",
    "gitlab-ctl reconfigure",
    # Create database only if it does not exist.
    "#{DATABASE_EXISTENCE_CHECK_COMMAND} || gitlab-psql -c 'create database gitlabhq_production_ci owner gitlab'",
    "gitlab-psql -d gitlabhq_production_ci -c 'create extension if not exists btree_gist'",
    "gitlab-psql -d gitlabhq_production_ci -c 'create extension if not exists pg_trgm'",
    # Load schema only if it does not exist.
    "#{SCHEMA_EXISTENCE_CHECK_COMMAND} || DISABLE_DATABASE_ENVIRONMENT_CHECK=1 gitlab-rake db:schema:load:ci",
    "gitlab-ctl restart"
  ].freeze
end