BigW Consortium Gitlab

Commit 812dd06d by Shinya Maeda

Introduce Redis helpers. Rename BuildTraceChunkFlushToDbWorker to Ci::BuildTraceChunkFlushWorker.

parent 47c8e06c
......@@ -99,7 +99,7 @@ module Ci
def schedule_to_db
return if db?
BuildTraceChunkFlushToDbWorker.perform_async(id)
Ci::BuildTraceChunkFlushWorker.perform_async(id)
end
def fullfilled?
......
......@@ -66,7 +66,7 @@
- pipeline_processing:pipeline_update
- pipeline_processing:stage_update
- pipeline_processing:update_head_pipeline_for_merge_request
- pipeline_processing:build_trace_chunk_flush_to_db
- pipeline_processing:ci_build_trace_chunk_flush
- repository_check:repository_check_clear
- repository_check:repository_check_single_repository
......
class BuildTraceChunkFlushToDbWorker
include ApplicationWorker
include PipelineQueue
module Ci
class BuildTraceChunkFlushWorker
include ApplicationWorker
queue_namespace :pipeline_processing
queue_namespace :pipeline_processing
def perform(build_trace_chunk_id)
Ci::BuildTraceChunk.find_by(id: build_trace_chunk_id).try do |build_trace_chunk|
build_trace_chunk.use_database!
def perform(build_trace_chunk_id)
::Ci::BuildTraceChunk.find_by(id: build_trace_chunk_id).try do |build_trace_chunk|
build_trace_chunk.use_database!
end
end
end
end
......@@ -75,7 +75,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let(:value) { 'a' * described_class::CHUNK_SIZE }
it 'schedules stashing data' do
expect(BuildTraceChunkFlushToDbWorker).to receive(:perform_async).once
expect(Ci::BuildTraceChunkFlushWorker).to receive(:perform_async).once
subject
end
......@@ -112,7 +112,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
context 'when fullfilled chunk size' do
it 'does not schedule stashing data' do
expect(BuildTraceChunkFlushToDbWorker).not_to receive(:perform_async)
expect(Ci::BuildTraceChunkFlushWorker).not_to receive(:perform_async)
subject
end
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe API::Runner, :clean_gitlab_redis_shared_state do
include StubGitlabCalls
include ChunkedIOHelpers
include RedisHelpers
let(:registration_token) { 'abcdefg123456' }
......@@ -873,8 +873,8 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
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!
# GitLab-Rails encounters an outage on Redis
redis_shared_state_cleanup!
expect(job.reload.trace.raw).to eq ''
# GitLab-Runner patchs
......
......@@ -86,6 +86,7 @@ RSpec.configure do |config|
config.include WaitForRequests, :js
config.include LiveDebugger, :js
config.include MigrationsHelpers, :migration
config.include RedisHelpers
if ENV['CI']
# This includes the first try, i.e. tests will be run 4 times before failing.
......@@ -146,21 +147,27 @@ RSpec.configure do |config|
end
config.around(:each, :clean_gitlab_redis_cache) do |example|
Gitlab::Redis::Cache.with(&:flushall)
redis_cache_cleanup!
example.run
Gitlab::Redis::Cache.with(&:flushall)
redis_cache_cleanup!
end
config.around(:each, :clean_gitlab_redis_shared_state) do |example|
Gitlab::Redis::SharedState.with(&:flushall)
Sidekiq.redis(&:flushall)
redis_shared_state_cleanup!
example.run
Gitlab::Redis::SharedState.with(&:flushall)
Sidekiq.redis(&:flushall)
redis_shared_state_cleanup!
end
config.around(:each, :clean_gitlab_redis_queues) do |example|
redis_queues_cleanup!
example.run
redis_queues_cleanup!
end
# The :each scope runs "inside" the example, so this hook ensures the DB is in the
......
......@@ -8,9 +8,4 @@ module ChunkedIOHelpers
stub_const('Ci::BuildTraceChunk::CHUNK_SIZE', size)
stub_const('Gitlab::Ci::Trace::ChunkedIO::CHUNK_SIZE', size)
end
def redis_shared_state_outage!
Gitlab::Redis::SharedState.with(&:flushall)
Sidekiq.redis(&:flushall)
end
end
module RedisHelpers
# config/README.md
# Usage: performance enhancement
def redis_cache_cleanup!
Gitlab::Redis::Cache.with(&:flushall)
end
# Usage: SideKiq, Mailroom, CI Runner, Workhorse, push services
def redis_queues_cleanup!
Gitlab::Redis::Queues.with(&:flushall)
end
# Usage: session state, rate limiting
def redis_shared_state_cleanup!
Gitlab::Redis::SharedState.with(&:flushall)
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