class Gitlab::QA::Component::Gitlab::Availability
def check(retries)
def check(retries) retries.times do return true if service_available? sleep 1 end false end
def initialize(name, relative_path: '', scheme: 'http', protocol_port: 80)
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
def service_available?
def service_available? output = docker.inspect(name) { |command| command << "--format='{{json .State.Health.Status}}'" } output == '"healthy"' rescue Docker::Shellout::StatusError false end
def uri
def uri @uri ||= begin port = docker.port(name, protocol_port).split(':').last URI.join("#{scheme}://#{docker.hostname}:#{port}", relative_path) end end