Class: Gitlab::QA::Component::Gitlab
- Inherits:
-
Base
- Object
- Base
- Gitlab::QA::Component::Gitlab
show all
- Extended by:
- Forwardable
- Defined in:
- lib/gitlab/qa/component/gitlab.rb
Defined Under Namespace
Classes: Availability
Constant Summary
collapse
- GITLAB_CERTIFICATES_PATH =
File.expand_path('../../../../tls_certificates/gitlab'.freeze, __dir__)
- GITALY_CERTIFICATES_PATH =
File.expand_path('../../../../tls_certificates/gitaly/ssl'.freeze, __dir__)
- TRUSTED_CERTIFICATES_PATH =
File.expand_path('../../../../tls_certificates/gitaly/trusted-certs'.freeze, __dir__)
- SSL_PATH =
'/etc/gitlab/ssl'.freeze
- TRUSTED_PATH =
'/etc/gitlab/trusted-certs'.freeze
Instance Attribute Summary collapse
Attributes inherited from Base
#docker, #environment, #network, #volumes
Instance Method Summary
collapse
Methods inherited from Base
#add_network_alias, #hostname, #image, #instance, #prepare_docker_container, #prepare_docker_image, #prepare_network, #process_exec_commands, #restart, #tag, #teardown, #teardown!
#act, included
Constructor Details
#initialize ⇒ Gitlab
Returns a new instance of Gitlab.
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 26
def initialize
super
@disable_animations = true
@skip_availability_check = false
@volumes[GITLAB_CERTIFICATES_PATH] = SSL_PATH
@volumes[TRUSTED_CERTIFICATES_PATH] = TRUSTED_PATH
self.release = 'CE'
end
|
Instance Attribute Details
#disable_animations ⇒ Object
Returns the value of attribute disable_animations.
14
15
16
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 14
def disable_animations
@disable_animations
end
|
#name ⇒ Object
56
57
58
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 56
def name
@name ||= "gitlab-#{edition}-#{SecureRandom.hex(4)}"
end
|
#relative_path ⇒ Object
77
78
79
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 77
def relative_path
@relative_path ||= ''
end
|
#release ⇒ Object
Returns the value of attribute release.
13
14
15
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 13
def release
@release
end
|
#runner_network ⇒ Object
Returns the value of attribute runner_network.
14
15
16
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 14
def runner_network
@runner_network
end
|
#skip_availability_check ⇒ Object
Returns the value of attribute skip_availability_check.
14
15
16
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 14
def skip_availability_check
@skip_availability_check
end
|
#tls ⇒ Object
Returns the value of attribute tls.
14
15
16
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 14
def tls
@tls
end
|
Instance Method Details
#address ⇒ Object
60
61
62
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 60
def address
"#{scheme}://#{hostname}#{relative_path}"
end
|
#elastic_url=(url) ⇒ Object
48
49
50
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 48
def elastic_url=(url)
@environment['ELASTIC_URL'] = url
end
|
#mtls ⇒ Object
72
73
74
75
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 72
def mtls
@volumes.delete(GITLAB_CERTIFICATES_PATH)
@volumes[GITALY_CERTIFICATES_PATH] = SSL_PATH
end
|
#omnibus_config=(config) ⇒ Object
38
39
40
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 38
def omnibus_config=(config)
@environment['GITLAB_OMNIBUS_CONFIG'] = config.tr("\n", ' ')
end
|
#port ⇒ Object
68
69
70
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 68
def port
tls ? '443' : '80'
end
|
#prepare ⇒ Object
85
86
87
88
89
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 85
def prepare
prepare_gitlab_omnibus_config
super
end
|
#prepare_gitlab_omnibus_config ⇒ Object
97
98
99
100
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 97
def prepare_gitlab_omnibus_config
setup_disable_animations if disable_animations
set_formless_login_token
end
|
#pull ⇒ Object
91
92
93
94
95
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 91
def pull
docker.login(**release.login_params) if release.login_params
super
end
|
132
133
134
135
136
137
138
139
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 132
def reconfigure
@docker.attach(name) do |line, wait|
puts line
Process.kill('INT', wait.pid) if line =~ /gitlab Reconfigured!/
end
end
|
#scheme ⇒ Object
64
65
66
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 64
def scheme
tls ? 'https' : 'http'
end
|
#set_accept_insecure_certs ⇒ Object
81
82
83
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 81
def set_accept_insecure_certs
Runtime::Env.accept_insecure_certs = 'true'
end
|
42
43
44
45
46
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 42
def set_formless_login_token
return if Runtime::Env.gitlab_qa_formless_login_token.to_s.strip.empty?
@environment['GITLAB_OMNIBUS_CONFIG'] = "gitlab_rails['env'] = { 'GITLAB_QA_FORMLESS_LOGIN_TOKEN' => '#{Runtime::Env.gitlab_qa_formless_login_token}' }; #{@environment['GITLAB_OMNIBUS_CONFIG'] || ''}"
end
|
#setup_disable_animations ⇒ Object
102
103
104
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 102
def setup_disable_animations
@environment['GITLAB_OMNIBUS_CONFIG'] = "gitlab_rails['gitlab_disable_animations'] = true; #{@environment['GITLAB_OMNIBUS_CONFIG'] || ''}"
end
|
#sha_version ⇒ Object
152
153
154
155
156
157
158
159
160
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 152
def sha_version
json = @docker.read_file(
@release.image, @release.tag,
'/opt/gitlab/version-manifest.json'
)
manifest = JSON.parse(json)
manifest['software']['gitlab-rails']['locked_version']
end
|
#start ⇒ Object
rubocop:disable Metrics/AbcSize
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 106
def start
ensure_configured!
docker.run(image, tag) do |command|
command << "-d -p #{port}"
command << "--name #{name}"
command << "--net #{network}"
command << "--hostname #{hostname}"
@volumes.to_h.each do |to, from|
command.volume(to, from, 'Z')
end
command.volume(File.join(Runtime::Env.host_artifacts_dir, name, 'logs'), '/var/log/gitlab', 'Z')
@environment.to_h.each do |key, value|
command.env(key, value)
end
@network_aliases.to_a.each do |network_alias|
command << "--network-alias #{network_alias}"
end
end
Docker::Command.execute("network connect --alias #{name}.#{network} --alias #{name}.#{runner_network} #{runner_network} #{name}") if runner_network
end
|
#wait_until_ready ⇒ Object
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 141
def wait_until_ready
return if skip_availability_check
if Availability.new(name, relative_path: relative_path, scheme: scheme, protocol_port: port.to_i).check(300)
sleep 12
puts ' -> GitLab is available.'
else
abort ' -> GitLab unavailable!'
end
end
|