Commit 9490c0dc authored by Mark Lapierre's avatar Mark Lapierre

Merge branch '336314-fix-alpine-docker-permission' into 'master'

Fix alpine permission and refactor test

See merge request gitlab-org/gitlab!66579
parents d6f264fc 767d9169
...@@ -5,27 +5,31 @@ require 'digest/sha1' ...@@ -5,27 +5,31 @@ require 'digest/sha1'
module QA module QA
RSpec.describe 'Release', :runner do RSpec.describe 'Release', :runner do
describe 'Git clone using a deploy key' do describe 'Git clone using a deploy key' do
before do let(:runner_name) { "qa-runner-#{SecureRandom.hex(4)}" }
Flow::Login.sign_in let(:repository_location) { project.repository_ssh_location }
@runner_name = "qa-runner-#{Time.now.to_i}"
@project = Resource::Project.fabricate_via_api! do |project| let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'deploy-key-clone-project' project.name = 'deploy-key-clone-project'
end end
end
@repository_location = @project.repository_ssh_location let!(:runner) do
Resource::Runner.fabricate_via_api! do |resource|
@runner = Resource::Runner.fabricate_via_api! do |resource| resource.project = project
resource.project = @project resource.name = runner_name
resource.name = @runner_name resource.tags = [runner_name]
resource.tags = %w[qa docker]
resource.image = 'gitlab/gitlab-runner:alpine' resource.image = 'gitlab/gitlab-runner:alpine'
end end
end end
before do
Flow::Login.sign_in
end
after do after do
@runner.remove_via_api! runner.remove_via_api!
project.remove_via_api!
end end
keys = [ keys = [
...@@ -39,7 +43,7 @@ module QA ...@@ -39,7 +43,7 @@ module QA
key = key_class.new(*bits) key = key_class.new(*bits)
Resource::DeployKey.fabricate_via_browser_ui! do |resource| Resource::DeployKey.fabricate_via_browser_ui! do |resource|
resource.project = @project resource.project = project
resource.title = "deploy key #{key.name}(#{key.bits})" resource.title = "deploy key #{key.name}(#{key.bits})"
resource.key = key.public_key resource.key = key.public_key
end end
...@@ -51,23 +55,21 @@ module QA ...@@ -51,23 +55,21 @@ module QA
gitlab_ci = <<~YAML gitlab_ci = <<~YAML
cat-config: cat-config:
script: script:
- apk add --update --no-cache openssh-client - which ssh-agent || ( apk --update add openssh-client )
- mkdir -p ~/.ssh - mkdir -p ~/.ssh
- ssh-keyscan -p #{@repository_location.port} #{@repository_location.host} >> ~/.ssh/known_hosts - ssh-keyscan -p #{repository_location.port} #{repository_location.host} >> ~/.ssh/known_hosts
- eval $(ssh-agent -s) - eval $(ssh-agent -s)
- ssh-add -D - ssh-add -D
- echo "$#{deploy_key_name}" | ssh-add - - echo "$#{deploy_key_name}" | ssh-add -
- git clone #{@repository_location.git_uri} - git clone #{repository_location.git_uri}
- cd #{@project.name} - cd #{project.name}
- git checkout #{deploy_key_name} - git checkout #{deploy_key_name}
- sha1sum .gitlab-ci.yml - sha1sum .gitlab-ci.yml
tags: tags: [#{runner_name}]
- qa
- docker
YAML YAML
Resource::Repository::ProjectPush.fabricate! do |resource| Resource::Repository::ProjectPush.fabricate! do |resource|
resource.project = @project resource.project = project
resource.file_name = '.gitlab-ci.yml' resource.file_name = '.gitlab-ci.yml'
resource.commit_message = 'Add .gitlab-ci.yml' resource.commit_message = 'Add .gitlab-ci.yml'
resource.file_content = gitlab_ci resource.file_content = gitlab_ci
...@@ -81,16 +83,18 @@ module QA ...@@ -81,16 +83,18 @@ module QA
Page::Project::Pipeline::Show.perform(&:click_on_first_job) Page::Project::Pipeline::Show.perform(&:click_on_first_job)
Page::Project::Job::Show.perform do |job| Page::Project::Job::Show.perform do |job|
aggregate_failures 'job succeeds and has correct sha1sum' do
expect(job).to be_successful expect(job).to be_successful
expect(job.output).to include(sha1sum) expect(job.output).to include(sha1sum)
end end
end end
end
private private
def make_ci_variable(key_name, key) def make_ci_variable(key_name, key)
Resource::CiVariable.fabricate_via_api! do |resource| Resource::CiVariable.fabricate_via_api! do |resource|
resource.project = @project resource.project = project
resource.key = key_name resource.key = key_name
resource.value = key.private_key resource.value = key.private_key
resource.masked = false resource.masked = false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment