Skip to content
Snippets Groups Projects
Commit 401da1f8 authored by Mark Lapierre's avatar Mark Lapierre
Browse files

Merge branch 'mount-knapsack-host-path' into 'master'

Mount knapsack reports for all spec runs

See merge request gitlab-org/gitlab-qa!1026
parents 12610d87 b597af0d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -14,8 +14,14 @@ module Gitlab
 
def initialize
@docker = Docker::Engine.new(stream_output: true) # stream test output directly instead of through logger
@volumes = {}
@env = {}
@volumes = {}
@default_volumes = { '/var/run/docker.sock' => '/var/run/docker.sock' }
return if Runtime::Env.qa_knapsack_report_path.blank?
@default_volumes[Runtime::Env.qa_knapsack_report_path] = File.join(
Docker::Volumes::QA_CONTAINER_WORKDIR, 'knapsack'
)
end
 
def perform
Loading
Loading
@@ -59,12 +65,12 @@ module Gitlab
command.env(key, value)
end
 
command.volume('/var/run/docker.sock', '/var/run/docker.sock')
command.volume(File.join(Runtime::Env.host_artifacts_dir, name), File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'tmp'))
command.volume(
File.join(Runtime::Env.host_artifacts_dir, name),
File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'tmp')
)
 
@volumes.to_h.each do |to, from|
command.volume(to, from)
end
volumes.to_h.merge(default_volumes).each { |to, from| command.volume(to, from) }
 
command.name(name)
end
Loading
Loading
@@ -73,6 +79,8 @@ module Gitlab
 
private
 
attr_reader :default_volumes
def docker_pull_qa_image_if_needed
@docker.login(**release.login_params) if release.login_params
 
Loading
Loading
Loading
Loading
@@ -81,6 +81,7 @@ module Gitlab
'KNAPSACK_TEST_FILE_PATTERN' => :knapsack_test_file_pattern,
'KNAPSACK_TEST_DIR' => :knapsack_test_dir,
'QA_KNAPSACK_REPORT_GCS_CREDENTIALS' => :qa_knapsack_report_gcs_credentials,
'QA_KNAPSACK_REPORT_PATH' => :qa_knapsack_report_path,
'CI' => :ci,
'CI_COMMIT_REF_NAME' => :ci_commit_ref_name,
'CI_JOB_NAME' => :ci_job_name,
Loading
Loading
Loading
Loading
@@ -29,7 +29,6 @@ module Gitlab
specs.suite = @suite
specs.release = release
specs.args = non_rspec_args.push(*args)
specs.volumes[host_knapsack_report_path] = "/home/gitlab/qa/knapsack" if host_knapsack_report_path
end
end
 
Loading
Loading
@@ -40,10 +39,6 @@ module Gitlab
def deployment_component
raise NotImplementedError, 'Please define the Component for the deployment environment associated with this scenario.'
end
def host_knapsack_report_path
ENV["QA_KNAPSACK_REPORT_PATH"]
end
end
end
end
Loading
Loading
Loading
Loading
@@ -25,11 +25,14 @@ describe Gitlab::QA::Component::Specs do
.with('/var/run/docker.sock', '/var/run/docker.sock')
end
 
it 'bind-mounds volume with screenshots in an appropriate directory' do
it 'bind-mounds volumes' do
allow(SecureRandom).to receive(:hex).and_return('def456')
allow(Gitlab::QA::Runtime::Env)
.to receive(:host_artifacts_dir)
.and_return('/tmp/gitlab-qa/gitlab-qa-run-2018-07-11-10-00-00-abc123')
allow(Gitlab::QA::Runtime::Env)
.to receive(:qa_knapsack_report_path)
.and_return('/qa/knapsack')
 
release = double('release', edition: :ce, project_name: 'gitlab-ce', qa_image: 'gitlab-ce-qa', qa_tag: 'latest')
allow(release)
Loading
Loading
@@ -45,6 +48,8 @@ describe Gitlab::QA::Component::Specs do
.with('/var/run/docker.sock', '/var/run/docker.sock')
expect(docker_command).to have_received(:volume)
.with('/tmp/gitlab-qa/gitlab-qa-run-2018-07-11-10-00-00-abc123/gitlab-ce-qa-def456', File.join(Gitlab::QA::Docker::Volumes::QA_CONTAINER_WORKDIR, 'tmp'))
expect(docker_command).to have_received(:volume)
.with('/qa/knapsack', File.join(Gitlab::QA::Docker::Volumes::QA_CONTAINER_WORKDIR, 'knapsack'))
end
 
context 'when preparing QA image' 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