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

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

Constant Summary

Constants inherited from Base

Base::CERTIFICATES_PATH

Instance Attribute Summary collapse

Attributes inherited from Base

#additional_hosts, #airgapped_network, #docker, #environment, #logger, #network, #network_aliases, #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, #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 = 'CE'
  @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



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/gitlab/qa/component/gitaly.rb', line 61

def gitaly_omnibus_configuration
  <<~OMNIBUS
    #{GitalyCluster.disable_other_omnibus_services}
    praefect['enable'] = false;
    prometheus['enable'] = true;
    gitaly['enable'] = true;
    gitaly['configuration'] = {
      'listen_addr': '0.0.0.0:#{gitaly_port}',
      'prometheus_listen_addr': '0.0.0.0:9236',
      '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({
      '#{name}' => {
        'path' => '/var/opt/gitlab/git-data'
      }
    });
  OMNIBUS
end

#process_exec_commandsObject



51
52
53
54
55
56
57
58
59
# File 'lib/gitlab/qa/component/gitaly.rb', line 51

def process_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

#pullObject



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

def pull
  docker.(**release.) if release.

  super
end

#reconfigureObject



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

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

#setup_omnibusObject



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

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