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
- AUTHORITY_CERTIFICATES_PATH =
File.expand_path('../../../../tls_certificates/authority', __dir__)
- GITLAB_CERTIFICATES_PATH =
File.expand_path('../../../../tls_certificates/gitlab', __dir__)
- GITALY_CERTIFICATES_PATH =
File.expand_path('../../../../tls_certificates/gitaly', __dir__)
- SSL_PATH =
'/etc/gitlab/ssl'
- TRUSTED_PATH =
'/etc/gitlab/trusted-certs'
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.
Instance Attribute Details
#name ⇒ Object
55
56
57
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 55
def name
@name ||= "gitlab-#{edition}-#{SecureRandom.hex(4)}"
end
|
#omnibus_configuration ⇒ Object
Returns the value of attribute omnibus_configuration.
15
16
17
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 15
def omnibus_configuration
@omnibus_configuration
end
|
#relative_path ⇒ Object
76
77
78
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 76
def relative_path
@relative_path ||= ''
end
|
#release ⇒ Object
Returns the value of attribute release.
15
16
17
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 15
def release
@release
end
|
#runner_network ⇒ Object
Returns the value of attribute runner_network.
16
17
18
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 16
def runner_network
@runner_network
end
|
#skip_availability_check ⇒ Object
Returns the value of attribute skip_availability_check.
16
17
18
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 16
def skip_availability_check
@skip_availability_check
end
|
#tls ⇒ Object
Returns the value of attribute tls.
16
17
18
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 16
def tls
@tls
end
|
Instance Method Details
#address ⇒ Object
59
60
61
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 59
def address
"#{scheme}://#{hostname}#{relative_path}"
end
|
#elastic_url=(url) ⇒ Object
47
48
49
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 47
def elastic_url=(url)
@environment['ELASTIC_URL'] = url
end
|
#port ⇒ Object
67
68
69
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 67
def port
tls ? '443:443' : '80'
end
|
#prepare ⇒ Object
84
85
86
87
88
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 84
def prepare
prepare_gitlab_omnibus_config
super
end
|
#prepare_gitlab_omnibus_config ⇒ Object
96
97
98
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 96
def prepare_gitlab_omnibus_config
set_formless_login_token
end
|
#pull ⇒ Object
90
91
92
93
94
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 90
def pull
docker.login(**release.login_params) if release.login_params
super
end
|
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 126
def reconfigure
setup_omnibus
@docker.attach(name) do |line, wait|
puts line
break if line =~ /gitlab Reconfigured!/
end
end
|
#scheme ⇒ Object
63
64
65
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 63
def scheme
tls ? 'https' : 'http'
end
|
#set_accept_insecure_certs ⇒ Object
80
81
82
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 80
def set_accept_insecure_certs
Runtime::Env.accept_insecure_certs = 'true'
end
|
41
42
43
44
45
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 41
def set_formless_login_token
return if Runtime::Env.gitlab_qa_formless_login_token.to_s.strip.empty?
@omnibus_configuration << "gitlab_rails['env'] = { 'GITLAB_QA_FORMLESS_LOGIN_TOKEN' => '#{Runtime::Env.gitlab_qa_formless_login_token}' }"
end
|
#sha_version ⇒ Object
148
149
150
151
152
153
154
155
156
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 148
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 100
def start ensure_configured!
docker.run(image: image, tag: 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
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/gitlab/qa/component/gitlab.rb', line 137
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(Runtime::Env.gitlab_availability_timeout)
sleep 12 puts ' -> GitLab is available.'
else
abort ' -> GitLab unavailable!'
end
end
|