Add support for job_upper_timeout in API

This commit is contained in:
Tomasz Maczukin 2018-02-19 17:21:00 +01:00
parent fb0dec4e00
commit 7b82f4bab1
No known key found for this signature in database
GPG key ID: 7E9EB2E4B0F625CD
6 changed files with 23 additions and 4 deletions

View file

@ -153,7 +153,8 @@ Example response:
"mysql"
],
"version": null,
"access_level": "ref_protected"
"access_level": "ref_protected",
"job_upper_timeout": 3600
}
```
@ -174,6 +175,7 @@ PUT /runners/:id
| `run_untagged` | boolean | no | Flag indicating the runner can execute untagged jobs |
| `locked` | boolean | no | Flag indicating the runner is locked |
| `access_level` | string | no | The access_level of the runner; `not_protected` or `ref_protected` |
| `job_upper_timeout` | integer | no | Upper timeout set when this Runner will handle the job |
```
curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/runners/6" --form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"
@ -211,7 +213,8 @@ Example response:
"tag2"
],
"version": null,
"access_level": "ref_protected"
"access_level": "ref_protected",
"job_upper_timeout": null
}
```

View file

@ -951,6 +951,7 @@ module API
expose :tag_list
expose :run_untagged
expose :locked
expose :job_upper_timeout
expose :access_level
expose :version, :revision, :platform, :architecture
expose :contacted_at

View file

@ -14,9 +14,10 @@ module API
optional :locked, type: Boolean, desc: 'Should Runner be locked for current project'
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 :job_upper_timeout, type: Integer, desc: 'Upper timeout set when this Runner will handle the job'
end
post '/' do
attributes = attributes_for_keys([:description, :locked, :run_untagged, :tag_list])
attributes = attributes_for_keys([:description, :locked, :run_untagged, :tag_list, :job_upper_timeout])
.merge(get_runner_details_from_request)
runner =

View file

@ -57,6 +57,7 @@ module API
optional :locked, type: Boolean, desc: 'Flag indicating the runner is locked'
optional :access_level, type: String, values: Ci::Runner.access_levels.keys,
desc: 'The access_level of the runner'
optional :job_upper_timeout, type: Integer, desc: 'Upper timeout set when this Runner will handle the job'
at_least_one_of :description, :active, :tag_list, :run_untagged, :locked, :access_level
end
put ':id' do

View file

@ -109,6 +109,16 @@ describe API::Runner do
end
end
context 'when job upper timeout is specified' do
it 'creates runner' do
post api('/runners'), token: registration_token,
job_upper_timeout: 7200
expect(response).to have_gitlab_http_status 201
expect(Ci::Runner.first.job_upper_timeout).to eq(7200)
end
end
%w(name version revision platform architecture).each do |param|
context "when info parameter '#{param}' info is present" do
let(:value) { "#{param}_value" }

View file

@ -123,6 +123,7 @@ describe API::Runners do
expect(response).to have_gitlab_http_status(200)
expect(json_response['description']).to eq(shared_runner.description)
expect(json_response['job_upper_timeout']).to be_nil
end
end
@ -192,7 +193,8 @@ describe API::Runners do
tag_list: ['ruby2.1', 'pgsql', 'mysql'],
run_untagged: 'false',
locked: 'true',
access_level: 'ref_protected')
access_level: 'ref_protected',
job_upper_timeout: 1234 )
shared_runner.reload
expect(response).to have_gitlab_http_status(200)
@ -204,6 +206,7 @@ describe API::Runners do
expect(shared_runner.ref_protected?).to be_truthy
expect(shared_runner.ensure_runner_queue_value)
.not_to eq(runner_queue_value)
expect(shared_runner.job_upper_timeout).to eq(1234)
end
end