Class: Gitlab::QA::Component::Gitlab::Availability

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/qa/component/gitlab.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, relative_path: '', scheme: 'http', protocol_port: 80) ⇒ Availability

Returns a new instance of Availability.



339
340
341
342
343
344
345
346
# File 'lib/gitlab/qa/component/gitlab.rb', line 339

def initialize(name, relative_path: '', scheme: 'http', protocol_port: 80)
  @docker = Docker::Engine.new

  @name = name
  @scheme = scheme
  @relative_path = relative_path
  @protocol_port = protocol_port
end

Instance Method Details

#check(retries) ⇒ Object



348
349
350
351
352
353
354
355
356
# File 'lib/gitlab/qa/component/gitlab.rb', line 348

def check(retries)
  retries.times do
    return true if service_available?

    sleep 1
  end

  false
end

#uriObject



358
359
360
361
362
363
364
# File 'lib/gitlab/qa/component/gitlab.rb', line 358

def uri
  @uri ||= begin
    port = docker.port(name, protocol_port).split(':').last

    URI.join("#{scheme}://#{docker.hostname}:#{port}", relative_path)
  end
end