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
- CERTIFICATES_PATH =
File.expand_path('../../../../tls_certificates/gitlab'.freeze, __dir__)
- SSL_PATH =
'/etc/gitlab/ssl'.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_image, #prepare_network, #process_exec_commands, #restart, #tag, #teardown, #teardown!
#act, included
Constructor Details
#initialize ⇒ Gitlab
Returns a new instance of Gitlab.
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 22
def initialize
super
@disable_animations = true
@skip_availability_check = false
@volumes[CERTIFICATES_PATH] = SSL_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
51
52
53
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 51
def name
@name ||= "gitlab-#{edition}-#{SecureRandom.hex(4)}"
end
|
#relative_path ⇒ Object
67
68
69
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 67
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
55
56
57
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 55
def address
"#{scheme}://#{hostname}#{relative_path}"
end
|
#elastic_url=(url) ⇒ Object
43
44
45
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 43
def elastic_url=(url)
@environment['ELASTIC_URL'] = url
end
|
#omnibus_config=(config) ⇒ Object
33
34
35
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 33
def omnibus_config=(config)
@environment['GITLAB_OMNIBUS_CONFIG'] = config.tr("\n", ' ')
end
|
#port ⇒ Object
63
64
65
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 63
def port
tls ? '443' : '80'
end
|
#prepare ⇒ Object
75
76
77
78
79
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 75
def prepare
prepare_gitlab_omnibus_config
super
end
|
#prepare_gitlab_omnibus_config ⇒ Object
87
88
89
90
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 87
def prepare_gitlab_omnibus_config
setup_disable_animations if disable_animations
set_formless_login_token
end
|
#pull ⇒ Object
81
82
83
84
85
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 81
def pull
docker.login(**release.login_params) if release.login_params
super
end
|
122
123
124
125
126
127
128
129
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 122
def reconfigure
@docker.attach(name) do |line, wait|
puts line
Process.kill('INT', wait.pid) if line =~ /gitlab Reconfigured!/
end
end
|
#scheme ⇒ Object
59
60
61
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 59
def scheme
tls ? 'https' : 'http'
end
|
#set_accept_insecure_certs ⇒ Object
71
72
73
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 71
def set_accept_insecure_certs
Runtime::Env.accept_insecure_certs = 'true'
end
|
37
38
39
40
41
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 37
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
92
93
94
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 92
def setup_disable_animations
@environment['GITLAB_OMNIBUS_CONFIG'] = "gitlab_rails['gitlab_disable_animations'] = true; #{@environment['GITLAB_OMNIBUS_CONFIG'] || ''}"
end
|
#sha_version ⇒ Object
142
143
144
145
146
147
148
149
150
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 142
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 96
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 ⇒ Object
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 131
def wait
return if skip_availability_check
if Availability.new(name, relative_path: relative_path, scheme: scheme, protocol_port: port.to_i).check(180)
sleep 12
puts ' -> GitLab is available.'
else
abort ' -> GitLab unavailable!'
end
end
|