Class: Gitlab::QA::Component::Gitaly

Inherits:
Base
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gitlab/qa/component/gitaly.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#airgapped_network, #docker, #environment, #network, #ports, #runner_network, #volumes

Instance Method Summary collapse

Methods inherited from Base

#add_network_alias, #hostname, #image, #instance, #ip_address, #prepare, #prepare_airgapped_network, #prepare_docker_container, #prepare_docker_image, #prepare_network, #prepare_runner_network, #pull, #restart, #start, #start_instance, #tag, #teardown, #teardown!

Methods included from Scenario::Actable

#act, included

Constructor Details

#initializeGitaly

Returns a new instance of Gitaly.



15
16
17
18
19
20
21
# File 'lib/gitlab/qa/component/gitaly.rb', line 15

def initialize
  super
  self.release = 'EE'
  @cluster_config = Component::GitalyCluster::GitalyClusterConfig.new
  @gitaly_port = 8075
  @ports = [gitaly_port]
end

Instance Attribute Details

#cluster_configObject

Returns the value of attribute cluster_config.



10
11
12
# File 'lib/gitlab/qa/component/gitaly.rb', line 10

def cluster_config
  @cluster_config
end

#gitaly_portObject

Returns the value of attribute gitaly_port.



10
11
12
# File 'lib/gitlab/qa/component/gitaly.rb', line 10

def gitaly_port
  @gitaly_port
end

#gitlab_nameObject

Returns the value of attribute gitlab_name.



10
11
12
# File 'lib/gitlab/qa/component/gitaly.rb', line 10

def gitlab_name
  @gitlab_name
end

#nameObject



23
24
25
# File 'lib/gitlab/qa/component/gitaly.rb', line 23

def name
  @name || "gitaly-#{SecureRandom.hex(4)}"
end

#releaseObject

Returns the value of attribute release.



9
10
11
# File 'lib/gitlab/qa/component/gitaly.rb', line 9

def release
  @release
end

Instance Method Details

#gitaly_omnibus_configurationObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/gitlab/qa/component/gitaly.rb', line 55

def gitaly_omnibus_configuration
  <<~OMNIBUS
    #{GitalyCluster.disable_other_omnibus_services}
    praefect['enable'] = false;
    prometheus['enable'] = true;
    gitaly['enable'] = true;
    gitaly['listen_addr'] = '0.0.0.0:#{gitaly_port}';
    gitaly['prometheus_listen_addr'] = '0.0.0.0:9236';
    gitaly['auth_token'] = 'PRAEFECT_INTERNAL_TOKEN';
    gitlab_shell['secret_token'] = 'GITLAB_SHELL_SECRET_TOKEN';
    gitlab_rails['internal_api_url'] = 'http://#{cluster_config.gitlab_name}.#{cluster_config.network}';
    git_data_dirs({
      '#{cluster_config.primary_node_name}' => {
        'path' => '/var/opt/gitlab/git-data'
      },
      '#{cluster_config.secondary_node_name}' => {
        'path' => '/var/opt/gitlab/git-data'
      },
      '#{cluster_config.tertiary_node_name}' => {
        'path' => '/var/opt/gitlab/git-data'
      }
    });
  OMNIBUS
end

#process_exec_commandsObject



45
46
47
48
49
50
51
52
53
# File 'lib/gitlab/qa/component/gitaly.rb', line 45

def process_exec_commands
  exec_commands << Support::ConfigScripts.add_git_server_hooks(docker, name)

  commands = exec_commands.flatten.uniq
  return if commands.empty?

  Runtime::Logger.info("Running exec_commands...")
  commands.each { |command| docker.exec(name, command) }
end

#reconfigureObject



31
32
33
34
35
36
37
# File 'lib/gitlab/qa/component/gitaly.rb', line 31

def reconfigure
  setup_omnibus
  @docker.attach(name) do |line, wait|
    # TODO, workaround which allows to detach from the container
    break if /gitlab Reconfigured!/.match?(line)
  end
end

#setup_omnibusObject



39
40
41
42
43
# File 'lib/gitlab/qa/component/gitaly.rb', line 39

def setup_omnibus
  @docker.write_files(name) do |f|
    f.write('/etc/gitlab/gitlab.rb', gitaly_omnibus_configuration)
  end
end