Add spec that proves trace can be recovered even if it had redis outage
This commit is contained in:
parent
eaf29ccec0
commit
aaff5e452e
|
@ -52,6 +52,7 @@ module API
|
||||||
end
|
end
|
||||||
|
|
||||||
def job_token_valid?(job)
|
def job_token_valid?(job)
|
||||||
|
# binding.pry
|
||||||
token = (params[JOB_TOKEN_PARAM] || env[JOB_TOKEN_HEADER]).to_s
|
token = (params[JOB_TOKEN_PARAM] || env[JOB_TOKEN_HEADER]).to_s
|
||||||
token && job.valid_token?(token)
|
token && job.valid_token?(token)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe API::Runner, :clean_gitlab_redis_shared_state do
|
describe API::Runner, :clean_gitlab_redis_shared_state do
|
||||||
include StubGitlabCalls
|
include StubGitlabCalls
|
||||||
|
include ChunkedIOHelpers
|
||||||
|
|
||||||
let(:registration_token) { 'abcdefg123456' }
|
let(:registration_token) { 'abcdefg123456' }
|
||||||
|
|
||||||
|
@ -865,6 +866,29 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
|
||||||
expect(response.status).to eq(403)
|
expect(response.status).to eq(403)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when redis had an outage' do
|
||||||
|
it "recovers" do
|
||||||
|
# GitLab-Runner patchs
|
||||||
|
patch_the_trace
|
||||||
|
expect(job.reload.trace.raw).to eq 'BUILD TRACE appended appended'
|
||||||
|
|
||||||
|
# GitLab-Rails enxounters an outage on Redis
|
||||||
|
redis_shared_state_outage!
|
||||||
|
expect(job.reload.trace.raw).to eq ''
|
||||||
|
|
||||||
|
# GitLab-Runner patchs
|
||||||
|
patch_the_trace('hello', headers.merge({ 'Content-Range' => "28-32" }))
|
||||||
|
expect(response.status).to eq 202
|
||||||
|
expect(response.header).to have_key 'Range'
|
||||||
|
expect(response.header['Range']).to eq '0-0'
|
||||||
|
expect(job.reload.trace.raw).to eq ''
|
||||||
|
|
||||||
|
# GitLab-Runner re-patchs
|
||||||
|
patch_the_trace('BUILD TRACE appended appended hello')
|
||||||
|
expect(job.reload.trace.raw).to eq 'BUILD TRACE appended appended hello'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when Runner makes a force-patch' do
|
context 'when Runner makes a force-patch' do
|
||||||
|
|
|
@ -8,4 +8,9 @@ module ChunkedIOHelpers
|
||||||
stub_const('Ci::JobTraceChunk::CHUNK_SIZE', size)
|
stub_const('Ci::JobTraceChunk::CHUNK_SIZE', size)
|
||||||
stub_const('Gitlab::Ci::Trace::ChunkedIO::CHUNK_SIZE', size)
|
stub_const('Gitlab::Ci::Trace::ChunkedIO::CHUNK_SIZE', size)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def redis_shared_state_outage!
|
||||||
|
Gitlab::Redis::SharedState.with(&:flushall)
|
||||||
|
Sidekiq.redis(&:flushall)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue