Skip to content
Snippets Groups Projects
Commit 8d05291e authored by yliu uc1testing's avatar yliu uc1testing
Browse files

Merge branch 'acunskis-additional-ports' into 'master'

Add port mapping to gitlab docker instance

See merge request gitlab-org/gitlab-qa!1014
parents 8da2826c 43a3c403
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -7,13 +7,14 @@ module Gitlab
include Scenario::Actable
 
attr_reader :docker
attr_accessor :volumes, :network, :environment, :runner_network
attr_accessor :volumes, :ports, :network, :environment, :runner_network
attr_writer :name, :exec_commands
 
def initialize
@docker = Docker::Engine.new
@environment = {}
@volumes = {}
@ports = []
@network_aliases = []
@exec_commands = []
end
Loading
Loading
@@ -85,6 +86,10 @@ module Gitlab
command << "--net #{network}"
command << "--hostname #{hostname}"
 
@ports.each do |mapping|
command.port(mapping)
end
@volumes.to_h.each do |to, from|
command.volume(to, from, 'Z')
end
Loading
Loading
Loading
Loading
@@ -84,8 +84,8 @@ module Gitlab
tls ? 'https' : 'http'
end
 
def port
tls ? '443:443' : '80'
def gitlab_port
tls ? ["443:443"] : ["80"]
end
 
def gitaly_tls
Loading
Loading
@@ -136,11 +136,15 @@ module Gitlab
ensure_configured!
 
docker.run(image: image, tag: tag) do |command|
command << "-d -p #{port}"
command << "-d"
command << "--name #{name}"
command << "--net #{network}"
command << "--hostname #{hostname}"
 
[*@ports, *gitlab_port].each do |mapping|
command.port(mapping)
end
@volumes.to_h.each do |to, from|
command.volume(to, from, 'Z')
end
Loading
Loading
@@ -179,7 +183,7 @@ module Gitlab
name,
relative_path: relative_path,
scheme: scheme,
protocol_port: port.to_i
protocol_port: gitlab_port.first.to_i
)
 
Runtime::Logger.info("Waiting for GitLab to become healthy ...")
Loading
Loading
Loading
Loading
@@ -33,6 +33,10 @@ module Gitlab
tap { @args.push(%(--env #{name}="#{value}")) }
end
 
def port(mapping)
tap { @args.push("-p #{mapping}") }
end
def to_s
"docker #{@args.join(' ')}"
end
Loading
Loading
Loading
Loading
@@ -101,7 +101,7 @@ module Gitlab
it 'should dynamically bind HTTP port' do
subject.start
 
expect(docker).to have_received(:<<).with('-d -p 80')
expect(docker).to have_received(:port).with("80")
end
 
it 'should specify the name' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment