Support 'active' setting on Runner Registration API endpoint
This commit is contained in:
parent
b63cd070b5
commit
8516e3a4b7
2 changed files with 25 additions and 1 deletions
|
@ -11,13 +11,14 @@ module API
|
||||||
requires :token, type: String, desc: 'Registration token'
|
requires :token, type: String, desc: 'Registration token'
|
||||||
optional :description, type: String, desc: %q(Runner's description)
|
optional :description, type: String, desc: %q(Runner's description)
|
||||||
optional :info, type: Hash, desc: %q(Runner's metadata)
|
optional :info, type: Hash, desc: %q(Runner's metadata)
|
||||||
|
optional :active, type: Boolean, desc: 'Should Runner be active'
|
||||||
optional :locked, type: Boolean, desc: 'Should Runner be locked for current project'
|
optional :locked, type: Boolean, desc: 'Should Runner be locked for current project'
|
||||||
optional :run_untagged, type: Boolean, desc: 'Should Runner handle untagged jobs'
|
optional :run_untagged, type: Boolean, desc: 'Should Runner handle untagged jobs'
|
||||||
optional :tag_list, type: Array[String], desc: %q(List of Runner's tags)
|
optional :tag_list, type: Array[String], desc: %q(List of Runner's tags)
|
||||||
optional :maximum_timeout, type: Integer, desc: 'Maximum timeout set when this Runner will handle the job'
|
optional :maximum_timeout, type: Integer, desc: 'Maximum timeout set when this Runner will handle the job'
|
||||||
end
|
end
|
||||||
post '/' do
|
post '/' do
|
||||||
attributes = attributes_for_keys([:description, :locked, :run_untagged, :tag_list, :maximum_timeout])
|
attributes = attributes_for_keys([:description, :active, :locked, :run_untagged, :tag_list, :maximum_timeout])
|
||||||
.merge(get_runner_details_from_request)
|
.merge(get_runner_details_from_request)
|
||||||
|
|
||||||
runner =
|
runner =
|
||||||
|
|
|
@ -41,6 +41,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
|
||||||
expect(json_response['id']).to eq(runner.id)
|
expect(json_response['id']).to eq(runner.id)
|
||||||
expect(json_response['token']).to eq(runner.token)
|
expect(json_response['token']).to eq(runner.token)
|
||||||
expect(runner.run_untagged).to be true
|
expect(runner.run_untagged).to be true
|
||||||
|
expect(runner.active).to be true
|
||||||
expect(runner.token).not_to eq(registration_token)
|
expect(runner.token).not_to eq(registration_token)
|
||||||
expect(runner).to be_instance_type
|
expect(runner).to be_instance_type
|
||||||
end
|
end
|
||||||
|
@ -129,6 +130,28 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when option for activating a Runner is provided' do
|
||||||
|
context 'when active is set to true' do
|
||||||
|
it 'creates runner' do
|
||||||
|
post api('/runners'), token: registration_token,
|
||||||
|
active: true
|
||||||
|
|
||||||
|
expect(response).to have_gitlab_http_status 201
|
||||||
|
expect(Ci::Runner.first.active).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when active is set to false' do
|
||||||
|
it 'creates runner' do
|
||||||
|
post api('/runners'), token: registration_token,
|
||||||
|
active: false
|
||||||
|
|
||||||
|
expect(response).to have_gitlab_http_status 201
|
||||||
|
expect(Ci::Runner.first.active).to be false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when maximum job timeout is specified' do
|
context 'when maximum job timeout is specified' do
|
||||||
it 'creates runner' do
|
it 'creates runner' do
|
||||||
post api('/runners'), token: registration_token,
|
post api('/runners'), token: registration_token,
|
||||||
|
|
Loading…
Reference in a new issue