Commit ce903c1a authored by Chloe Liu's avatar Chloe Liu

Merge branch 'ml-update-runner-cleanup' into 'master'

Add a test for removing runners

See merge request gitlab-org/gitlab!82366
parents d0f5408d fd0eae40
...@@ -47,9 +47,8 @@ module QA ...@@ -47,9 +47,8 @@ module QA
def remove_via_api! def remove_via_api!
runners = project.runners(tag_list: @tags) runners = project.runners(tag_list: @tags)
unless runners && !runners.empty?
raise "Project #{project.path_with_namespace} has no runners#{" with tags #{@tags}." if @tags&.any?}" return if runners.blank?
end
this_runner = runners.find { |runner| runner[:description] == name } this_runner = runners.find { |runner| runner[:description] == name }
unless this_runner unless this_runner
......
# frozen_string_literal: true
module QA
RSpec.describe 'Verify', :runner do
describe 'Runner removal' do
include Support::API
let(:api_client) { Runtime::API::Client.new(:gitlab) }
let(:executor) { "qa-runner-#{Time.now.to_i}" }
let(:runner_tags) { ['runner-registration-e2e-test'] }
let!(:runner) do
Resource::Runner.fabricate! do |runner|
runner.name = executor
runner.tags = runner_tags
end
end
before do
sleep 5 # Runner should register within 5 seconds
end
# Removing a runner via the UI is covered by `spec/features/runners_spec.rb``
it 'removes the runner' do
expect(runner.project.runners.size).to eq(1)
expect(runner.project.runners.first[:description]).to eq(executor)
request = Runtime::API::Request.new(api_client, "runners/#{runner.project.runners.first[:id]}")
response = delete(request.url)
expect(response.code).to eq(Support::API::HTTP_STATUS_NO_CONTENT)
expect(response.body).to be_empty
expect(runner.project.runners).to be_empty
end
end
end
end
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