blob: db4383a79d48fed1b8b20e9a8ac25a7e2d003a1b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Database::BackgroundMigration::HealthStatus::Indicators::AutovacuumActiveOnTable do
include Database::DatabaseHelpers
let(:connection) { Gitlab::Database.database_base_models[:main].connection }
around do |example|
Gitlab::Database::SharedModel.using_connection(connection) do
example.run
end
end
describe '#evaluate' do
subject { described_class.new(context).evaluate }
before do
swapout_view_for_table(:postgres_autovacuum_activity)
end
let(:tables) { [table] }
let(:table) { 'users' }
let(:context) { Gitlab::Database::BackgroundMigration::HealthStatus::Context.new(connection, tables) }
context 'without autovacuum activity' do
it 'returns Normal signal' do
expect(subject).to be_a(Gitlab::Database::BackgroundMigration::HealthStatus::Signals::Normal)
end
it 'remembers the indicator class' do
expect(subject.indicator_class).to eq(described_class)
end
end
context 'with autovacuum activity' do
before do
create(:postgres_autovacuum_activity, table: table, table_identifier: "public.#{table}")
end
it 'returns Stop signal' do
expect(subject).to be_a(Gitlab::Database::BackgroundMigration::HealthStatus::Signals::Stop)
end
it 'explains why' do
expect(subject.reason).to include('autovacuum running on: table public.users')
end
it 'remembers the indicator class' do
expect(subject.indicator_class).to eq(described_class)
end
it 'returns NoSignal signal in case the feature flag is disabled' do
stub_feature_flags(batched_migrations_health_status_autovacuum: false)
expect(subject).to be_a(Gitlab::Database::BackgroundMigration::HealthStatus::Signals::NotAvailable)
end
end
end
end
|