blob: 642758552621002cb9021f3e1ba572d4b365b499 (
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
|
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe FixPartitionIdsForCiJobVariables, migration: :gitlab_ci, feature_category: :continuous_integration do
let(:builds) { table(:ci_builds, database: :ci) }
let(:job_variables) { table(:ci_job_variables, database: :ci) }
let(:connection) { job_variables.connection }
around do |example|
connection.execute "ALTER TABLE #{job_variables.quoted_table_name} DISABLE TRIGGER ALL;"
example.run
ensure
connection.execute "ALTER TABLE #{job_variables.quoted_table_name} ENABLE TRIGGER ALL;"
end
before do
job = builds.create!(partition_id: 100)
job_variables.insert_all!([
{ job_id: job.id, partition_id: 100, key: 'variable-100' },
{ job_id: job.id, partition_id: 101, key: 'variable-101' }
])
end
describe '#up', :aggregate_failures do
context 'when on sass' do
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
it 'fixes partition_id' do
expect { migrate! }.not_to raise_error
expect(job_variables.where(partition_id: 100).count).to eq(2)
expect(job_variables.where(partition_id: 101).count).to eq(0)
end
end
context 'when on self managed' do
it 'does not change partition_id' do
expect { migrate! }.not_to raise_error
expect(job_variables.where(partition_id: 100).count).to eq(1)
expect(job_variables.where(partition_id: 101).count).to eq(1)
end
end
end
end
|