Commit 338bb2ac authored by Lin Jen-Shin's avatar Lin Jen-Shin

Remove unused codes and address feedback

parent bc2739a5
...@@ -4,7 +4,7 @@ module QA ...@@ -4,7 +4,7 @@ module QA
module Factory module Factory
module Resource module Resource
class Runner < Factory::Base class Runner < Factory::Base
attr_writer :name, :tags, :image, :executor, :docker_image attr_writer :name, :tags, :image
dependency Factory::Resource::Project, as: :project do |project| dependency Factory::Resource::Project, as: :project do |project|
project.name = 'project-with-ci-cd' project.name = 'project-with-ci-cd'
...@@ -23,14 +23,6 @@ module QA ...@@ -23,14 +23,6 @@ module QA
@image || 'gitlab/gitlab-runner:alpine' @image || 'gitlab/gitlab-runner:alpine'
end end
def executor
@executor || 'shell'
end
def docker_image
@docker_image || 'ubuntu/16.04'
end
def fabricate! def fabricate!
project.visit! project.visit!
...@@ -44,8 +36,6 @@ module QA ...@@ -44,8 +36,6 @@ module QA
runner.address = runners.coordinator_address runner.address = runners.coordinator_address
runner.tags = tags runner.tags = tags
runner.image = image runner.image = image
runner.executor = executor
runner.docker_image = docker_image
runner.register! runner.register!
end end
end end
......
...@@ -6,15 +6,13 @@ module QA ...@@ -6,15 +6,13 @@ module QA
include Scenario::Actable include Scenario::Actable
include Service::Shellout include Service::Shellout
attr_accessor :token, :address, :tags, :image, :executor, :docker_image attr_accessor :token, :address, :tags, :image
def initialize(name) def initialize(name)
@image = 'gitlab/gitlab-runner:alpine'
@name = name || "qa-runner-#{SecureRandom.hex(4)}" @name = name || "qa-runner-#{SecureRandom.hex(4)}"
@network = Runtime::Scenario.attributes[:network] || 'test' @network = Runtime::Scenario.attributes[:network] || 'test'
@tags = %w[qa test] @tags = %w[qa test]
@image = 'gitlab/gitlab-runner:alpine'
@executor = 'shell'
@docker_image = 'ubuntu/16.04'
end end
def pull def pull
...@@ -28,28 +26,16 @@ module QA ...@@ -28,28 +26,16 @@ module QA
-e CI_SERVER_URL=#{@address} -e CI_SERVER_URL=#{@address}
-e REGISTER_NON_INTERACTIVE=true -e REGISTER_NON_INTERACTIVE=true
-e REGISTRATION_TOKEN=#{@token} -e REGISTRATION_TOKEN=#{@token}
-e RUNNER_EXECUTOR=#{@executor} -e RUNNER_EXECUTOR=shell
-e DOCKER_IMAGE=#{@docker_image}
-e RUNNER_TAG_LIST=#{@tags.join(',')} -e RUNNER_TAG_LIST=#{@tags.join(',')}
-e RUNNER_NAME=#{@name} -e RUNNER_NAME=#{@name}
#{@image} -c '#{docker_commands}' #{@image} -c 'gitlab-runner register && gitlab-runner run'
CMD CMD
end end
def remove! def remove!
shell "docker rm -f #{@name}" shell "docker rm -f #{@name}"
end end
private
def docker_commands
commands = [
'gitlab-runner register',
'gitlab-runner run'
]
commands.join(' && ')
end
end end
end end
end end
require 'digest/sha1' require 'digest/sha1'
module QA module QA
feature 'pull codes with a deploy key', :core, :docker do feature 'cloning code using a deploy key', :core, :docker do
let(:runner_name) { "qa-runner-#{Time.now.to_i}" } let(:runner_name) { "qa-runner-#{Time.now.to_i}" }
after do after do
Service::Runner.new(runner_name).remove! Service::Runner.new(runner_name).remove!
end end
scenario 'user setup a deploy key and use it to pull from CI job' do scenario 'user sets up a deploy key to clone code using pipelines' do
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.act { sign_in_using_credentials }
project = Factory::Resource::Project.fabricate! do |resource| project = Factory::Resource::Project.fabricate! do |resource|
resource.name = 'cicd-pull-with-deploy-key' resource.name = 'deploy-key-clone-project'
end end
Factory::Resource::Runner.fabricate! do |runner| Factory::Resource::Runner.fabricate! do |runner|
runner.project = project runner.project = project
runner.name = runner_name runner.name = runner_name
runner.tags = %w[qa docker] runner.tags = %w[qa docker]
runner.executor = 'shell'
runner.image = 'gitlab/gitlab-runner:ubuntu' runner.image = 'gitlab/gitlab-runner:ubuntu'
end end
...@@ -47,8 +46,7 @@ module QA ...@@ -47,8 +46,7 @@ module QA
repository_uri = Git::Repository.parse_uri(repository_url) repository_uri = Git::Repository.parse_uri(repository_url)
gitlab_ci = gitlab_ci = <<~YAML
<<~YAML
cat-config: cat-config:
script: script:
- mkdir -p ~/.ssh - mkdir -p ~/.ssh
......
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