Commit 61e2369d authored by Sean McGivern's avatar Sean McGivern

Make Redis instrumentation spec more robust

When run as the first spec in a run, this would fail. It would then pass
on retry. That was because on the first Redis call, we SELECT the
correct database for the test environment.

To work around this, we perform a Redis command - also doing the SELECT
if needed - and then reset the request store data so that the expected
counts can remain exact.
parent 74729c56
......@@ -28,6 +28,13 @@ RSpec.describe Gitlab::Instrumentation::Redis do
describe '.payload', :request_store do
before do
# If this is the first spec in a spec run that uses Redis, there
# will be an extra SELECT command to choose the right database. We
# don't want to make the spec less precise, so we force that to
# happen (if needed) first, then clear the counts.
Gitlab::Redis::Cache.with { |redis| redis.info }
RequestStore.clear!
Gitlab::Redis::Cache.with { |redis| redis.set('cache-test', 321) }
Gitlab::Redis::SharedState.with { |redis| redis.set('shared-state-test', 123) }
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