Commit fd0eae40 authored by Mark Lapierre's avatar Mark Lapierre Committed by Chloe Liu

Add a test for removing runners

- When cleaning up runners after tests finish, ignore runners if
they've already been removed
parent 0e8352a5
......@@ -47,9 +47,8 @@ module QA
def remove_via_api!
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?}"
end
return if runners.blank?
this_runner = runners.find { |runner| runner[:description] == name }
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