summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-10-05 10:23:43 +0000
committerRémy Coutable <remy@rymai.me>2016-10-05 10:23:43 +0000
commit6d74e474aba6f1480ae3ba69aa4e29f1e033bc60 (patch)
tree441d2cab2015270003aee31e873c93816202259d /spec
parent4dc61dc7128608ce5eca4b0911d7174a1ab2aea4 (diff)
parentaa1ab8aa1786517544d0a5c1a4217f98d37ea58f (diff)
downloadgitlab-ce-6d74e474aba6f1480ae3ba69aa4e29f1e033bc60.tar.gz
Merge branch 'update-runner-information' into 'master'
Update runner version only when updating contacted_at ## What does this MR do? Improves how we update runners table, especially the version. This is another round of improvements to reduce number of `ci_runners` updates. I did make `contacted_at` to be updated more often (on average every 15 minutes). We will also update version information in one go to solve: https://gitlab.com/gitlab-org/gitlab-ce/issues/22206 Improves: https://gitlab.com/gitlab-org/gitlab-ce/issues/22590 Solves: https://gitlab.com/gitlab-org/gitlab-ce/issues/22206 See merge request !6537
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/ci/api/builds_spec.rb43
1 files changed, 27 insertions, 16 deletions
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb
index df97f1bf7b6..7b7d62feb2c 100644
--- a/spec/requests/ci/api/builds_spec.rb
+++ b/spec/requests/ci/api/builds_spec.rb
@@ -35,18 +35,24 @@ describe Ci::API::API do
end
end
- it "starts a build" do
- register_builds info: { platform: :darwin }
-
- expect(response).to have_http_status(201)
- expect(json_response['sha']).to eq(build.sha)
- expect(runner.reload.platform).to eq("darwin")
- expect(json_response["options"]).to eq({ "image" => "ruby:2.1", "services" => ["postgres"] })
- expect(json_response["variables"]).to include(
- { "key" => "CI_BUILD_NAME", "value" => "spinach", "public" => true },
- { "key" => "CI_BUILD_STAGE", "value" => "test", "public" => true },
- { "key" => "DB_NAME", "value" => "postgres", "public" => true }
- )
+ context 'when there is a pending build' do
+ it 'starts a build' do
+ register_builds info: { platform: :darwin }
+
+ expect(response).to have_http_status(201)
+ expect(json_response['sha']).to eq(build.sha)
+ expect(runner.reload.platform).to eq("darwin")
+ expect(json_response["options"]).to eq({ "image" => "ruby:2.1", "services" => ["postgres"] })
+ expect(json_response["variables"]).to include(
+ { "key" => "CI_BUILD_NAME", "value" => "spinach", "public" => true },
+ { "key" => "CI_BUILD_STAGE", "value" => "test", "public" => true },
+ { "key" => "DB_NAME", "value" => "postgres", "public" => true }
+ )
+ end
+
+ it 'updates runner info' do
+ expect { register_builds }.to change { runner.reload.contacted_at }
+ end
end
context 'when builds are finished' do
@@ -159,13 +165,18 @@ describe Ci::API::API do
end
context 'when runner is paused' do
- let(:inactive_runner) { create(:ci_runner, :inactive, token: "InactiveRunner") }
+ let(:runner) { create(:ci_runner, :inactive, token: 'InactiveRunner') }
- before do
- register_builds inactive_runner.token
+ it 'responds with 404' do
+ register_builds
+
+ expect(response).to have_http_status 404
end
- it { expect(response).to have_http_status 404 }
+ it 'does not update runner info' do
+ expect { register_builds }
+ .not_to change { runner.reload.contacted_at }
+ end
end
def register_builds(token = runner.token, **params)