Commit 7b82f4ba authored by Tomasz Maczukin's avatar Tomasz Maczukin

Add support for job_upper_timeout in API

parent fb0dec4e
...@@ -153,7 +153,8 @@ Example response: ...@@ -153,7 +153,8 @@ Example response:
"mysql" "mysql"
], ],
"version": null, "version": null,
"access_level": "ref_protected" "access_level": "ref_protected",
"job_upper_timeout": 3600
} }
``` ```
...@@ -174,6 +175,7 @@ PUT /runners/:id ...@@ -174,6 +175,7 @@ PUT /runners/:id
| `run_untagged` | boolean | no | Flag indicating the runner can execute untagged jobs | | `run_untagged` | boolean | no | Flag indicating the runner can execute untagged jobs |
| `locked` | boolean | no | Flag indicating the runner is locked | | `locked` | boolean | no | Flag indicating the runner is locked |
| `access_level` | string | no | The access_level of the runner; `not_protected` or `ref_protected` | | `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" 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: ...@@ -211,7 +213,8 @@ Example response:
"tag2" "tag2"
], ],
"version": null, "version": null,
"access_level": "ref_protected" "access_level": "ref_protected",
"job_upper_timeout": null
} }
``` ```
......
...@@ -951,6 +951,7 @@ module API ...@@ -951,6 +951,7 @@ module API
expose :tag_list expose :tag_list
expose :run_untagged expose :run_untagged
expose :locked expose :locked
expose :job_upper_timeout
expose :access_level expose :access_level
expose :version, :revision, :platform, :architecture expose :version, :revision, :platform, :architecture
expose :contacted_at expose :contacted_at
......
...@@ -14,9 +14,10 @@ module API ...@@ -14,9 +14,10 @@ module API
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 :job_upper_timeout, type: Integer, desc: 'Upper 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]) attributes = attributes_for_keys([:description, :locked, :run_untagged, :tag_list, :job_upper_timeout])
.merge(get_runner_details_from_request) .merge(get_runner_details_from_request)
runner = runner =
......
...@@ -57,6 +57,7 @@ module API ...@@ -57,6 +57,7 @@ module API
optional :locked, type: Boolean, desc: 'Flag indicating the runner is locked' optional :locked, type: Boolean, desc: 'Flag indicating the runner is locked'
optional :access_level, type: String, values: Ci::Runner.access_levels.keys, optional :access_level, type: String, values: Ci::Runner.access_levels.keys,
desc: 'The access_level of the runner' 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 at_least_one_of :description, :active, :tag_list, :run_untagged, :locked, :access_level
end end
put ':id' do put ':id' do
......
...@@ -109,6 +109,16 @@ describe API::Runner do ...@@ -109,6 +109,16 @@ describe API::Runner do
end end
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| %w(name version revision platform architecture).each do |param|
context "when info parameter '#{param}' info is present" do context "when info parameter '#{param}' info is present" do
let(:value) { "#{param}_value" } let(:value) { "#{param}_value" }
......
...@@ -123,6 +123,7 @@ describe API::Runners do ...@@ -123,6 +123,7 @@ describe API::Runners do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(json_response['description']).to eq(shared_runner.description) expect(json_response['description']).to eq(shared_runner.description)
expect(json_response['job_upper_timeout']).to be_nil
end end
end end
...@@ -192,7 +193,8 @@ describe API::Runners do ...@@ -192,7 +193,8 @@ describe API::Runners do
tag_list: ['ruby2.1', 'pgsql', 'mysql'], tag_list: ['ruby2.1', 'pgsql', 'mysql'],
run_untagged: 'false', run_untagged: 'false',
locked: 'true', locked: 'true',
access_level: 'ref_protected') access_level: 'ref_protected',
job_upper_timeout: 1234 )
shared_runner.reload shared_runner.reload
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
...@@ -204,6 +206,7 @@ describe API::Runners do ...@@ -204,6 +206,7 @@ describe API::Runners do
expect(shared_runner.ref_protected?).to be_truthy expect(shared_runner.ref_protected?).to be_truthy
expect(shared_runner.ensure_runner_queue_value) expect(shared_runner.ensure_runner_queue_value)
.not_to eq(runner_queue_value) .not_to eq(runner_queue_value)
expect(shared_runner.job_upper_timeout).to eq(1234)
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