Commit 21158b9d authored by Nick Thomas's avatar Nick Thomas

Merge branch 'bw-fix-job-artifacts-table' into 'master'

fix spelling of fdw table name that caused 500 error

See merge request gitlab-org/gitlab-ee!5040
parents 87f19344 7bb1227f
...@@ -76,7 +76,7 @@ module Geo ...@@ -76,7 +76,7 @@ module Geo
# #
def fdw_find_job_artifacts def fdw_find_job_artifacts
fdw_job_artifacts.joins("INNER JOIN file_registry ON file_registry.file_id = #{fdw_jobs_artifacts_table}.id") fdw_job_artifacts.joins("INNER JOIN file_registry ON file_registry.file_id = #{fdw_job_artifacts_table}.id")
.with_files_stored_locally .with_files_stored_locally
.merge(Geo::FileRegistry.job_artifacts) .merge(Geo::FileRegistry.job_artifacts)
end end
......
...@@ -21,45 +21,76 @@ describe Geo::JobArtifactRegistryFinder, :geo do ...@@ -21,45 +21,76 @@ describe Geo::JobArtifactRegistryFinder, :geo do
describe '#count_synced_job_artifacts' do describe '#count_synced_job_artifacts' do
it 'delegates to #legacy_find_synced_job_artifacts' do it 'delegates to #legacy_find_synced_job_artifacts' do
allow(subject).to receive(:aggregate_pushdown_supported?).and_return(false)
expect(subject).to receive(:legacy_find_synced_job_artifacts).and_call_original expect(subject).to receive(:legacy_find_synced_job_artifacts).and_call_original
subject.count_synced_job_artifacts subject.count_synced_job_artifacts
end end
it 'counts job artifacts that has been synced' do it 'delegates to #find_synced_job_artifacts for PostgreSQL 10' do
create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id, success: false) allow(subject).to receive(:aggregate_pushdown_supported?).and_return(true)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id) expect(subject).to receive(:find_synced_job_artifacts).and_call_original
subject.count_synced_job_artifacts
end
end
describe '#count_failed_job_artifacts' do
it 'delegates to #legacy_find_failed_job_artifacts' do
allow(subject).to receive(:aggregate_pushdown_supported?).and_return(false)
expect(subject).to receive(:legacy_find_failed_job_artifacts).and_call_original
expect(subject.count_synced_job_artifacts).to eq 2 subject.count_failed_job_artifacts
end end
it 'ignores remote job artifacts' do it 'delegates to #find_failed_job_artifacts' do
create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id) allow(subject).to receive(:aggregate_pushdown_supported?).and_return(true)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id) expect(subject).to receive(:find_failed_job_artifacts).and_call_original
job_artifact_1.update!(file_store: ObjectStorage::Store::REMOTE)
expect(subject.count_synced_job_artifacts).to eq 2 subject.count_failed_job_artifacts
end end
end
context 'with selective sync' do shared_examples 'counts all the things' do
before do describe '#count_job_artifacts' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group]) it 'counts job artifacts' do
expect(subject.count_job_artifacts).to eq 4
end end
it 'delegates to #legacy_find_synced_job_artifacts' do it 'ignores remote job artifacts' do
expect(subject).to receive(:legacy_find_synced_job_artifacts).and_call_original job_artifact_1.update!(file_store: ObjectStorage::Store::REMOTE)
expect(subject.count_job_artifacts).to eq 3
end
context 'with selective sync' do
before do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end
it 'counts job artifacts' do
expect(subject.count_job_artifacts).to eq 2
end
subject.count_synced_job_artifacts it 'ignores remote job artifacts' do
job_artifact_1.update!(file_store: ObjectStorage::Store::REMOTE)
expect(subject.count_job_artifacts).to eq 1
end
end end
end
it 'counts job artifacts that has been synced' do describe '#count_synced_job_artifacts' do
it 'counts job artifacts that have been synced' do
create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id, success: false) create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id, success: false)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id) create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id) create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id)
expect(subject.count_synced_job_artifacts).to eq 1 expect(subject.count_synced_job_artifacts).to eq 2
end end
it 'ignores remote job artifacts' do it 'ignores remote job artifacts' do
...@@ -68,57 +99,46 @@ describe Geo::JobArtifactRegistryFinder, :geo do ...@@ -68,57 +99,46 @@ describe Geo::JobArtifactRegistryFinder, :geo do
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id) create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id)
job_artifact_1.update!(file_store: ObjectStorage::Store::REMOTE) job_artifact_1.update!(file_store: ObjectStorage::Store::REMOTE)
expect(subject.count_synced_job_artifacts).to eq 1 expect(subject.count_synced_job_artifacts).to eq 2
end end
end
end
describe '#count_failed_job_artifacts' do context 'with selective sync' do
it 'delegates to #legacy_find_failed_job_artifacts' do before do
expect(subject).to receive(:legacy_find_failed_job_artifacts).and_call_original secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end
subject.count_failed_job_artifacts it 'delegates to #legacy_find_synced_job_artifacts' do
end expect(subject).to receive(:legacy_find_synced_job_artifacts).and_call_original
it 'counts job artifacts that sync has failed' do subject.count_synced_job_artifacts
create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id, success: false) end
create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id, success: false)
expect(subject.count_failed_job_artifacts).to eq 2
end
it 'ignores remote job artifacts' do it 'counts job artifacts that has been synced' do
create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id, success: false) create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id, success: false)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id, success: false) create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id, success: false) create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id)
job_artifact_1.update!(file_store: ObjectStorage::Store::REMOTE)
expect(subject.count_failed_job_artifacts).to eq 2 expect(subject.count_synced_job_artifacts).to eq 1
end end
context 'with selective sync' do
before do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end
it 'delegates to #legacy_find_failed_job_artifacts' do it 'ignores remote job artifacts' do
expect(subject).to receive(:legacy_find_failed_job_artifacts).and_call_original create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id)
job_artifact_1.update!(file_store: ObjectStorage::Store::REMOTE)
subject.count_failed_job_artifacts expect(subject.count_synced_job_artifacts).to eq 1
end
end end
end
describe '#count_failed_job_artifacts' do
it 'counts job artifacts that sync has failed' do it 'counts job artifacts that sync has failed' do
create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id, success: false) create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id, success: false)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id) create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id, success: false)
expect(subject.count_failed_job_artifacts).to eq 1
end
it 'does not count job artifacts of unsynced projects' do
create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id, success: false)
expect(subject.count_failed_job_artifacts).to eq 0 expect(subject.count_failed_job_artifacts).to eq 2
end end
it 'ignores remote job artifacts' do it 'ignores remote job artifacts' do
...@@ -127,7 +147,41 @@ describe Geo::JobArtifactRegistryFinder, :geo do ...@@ -127,7 +147,41 @@ describe Geo::JobArtifactRegistryFinder, :geo do
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id, success: false) create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id, success: false)
job_artifact_1.update!(file_store: ObjectStorage::Store::REMOTE) job_artifact_1.update!(file_store: ObjectStorage::Store::REMOTE)
expect(subject.count_failed_job_artifacts).to eq 1 expect(subject.count_failed_job_artifacts).to eq 2
end
context 'with selective sync' do
before do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end
it 'delegates to #legacy_find_failed_job_artifacts' do
expect(subject).to receive(:legacy_find_failed_job_artifacts).and_call_original
subject.count_failed_job_artifacts
end
it 'counts job artifacts that sync has failed' do
create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id, success: false)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id)
expect(subject.count_failed_job_artifacts).to eq 1
end
it 'does not count job artifacts of unsynced projects' do
create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id, success: false)
expect(subject.count_failed_job_artifacts).to eq 0
end
it 'ignores remote job artifacts' do
create(:geo_file_registry, :job_artifact, file_id: job_artifact_1.id, success: false)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_2.id, success: false)
create(:geo_file_registry, :job_artifact, file_id: job_artifact_3.id, success: false)
job_artifact_1.update!(file_store: ObjectStorage::Store::REMOTE)
expect(subject.count_failed_job_artifacts).to eq 1
end
end end
end end
end end
...@@ -167,6 +221,8 @@ describe Geo::JobArtifactRegistryFinder, :geo do ...@@ -167,6 +221,8 @@ describe Geo::JobArtifactRegistryFinder, :geo do
skip('FDW is not configured') if Gitlab::Database.postgresql? && !Gitlab::Geo::Fdw.enabled? skip('FDW is not configured') if Gitlab::Database.postgresql? && !Gitlab::Geo::Fdw.enabled?
end end
include_examples 'counts all the things'
include_examples 'finds all the things' do include_examples 'finds all the things' do
let(:method_prefix) { 'fdw' } let(:method_prefix) { 'fdw' }
end end
...@@ -177,6 +233,8 @@ describe Geo::JobArtifactRegistryFinder, :geo do ...@@ -177,6 +233,8 @@ describe Geo::JobArtifactRegistryFinder, :geo do
allow(Gitlab::Geo::Fdw).to receive(:enabled?).and_return(false) allow(Gitlab::Geo::Fdw).to receive(:enabled?).and_return(false)
end end
include_examples 'counts all the things'
include_examples 'finds all the things' do include_examples 'finds all the things' do
let(:method_prefix) { 'legacy' } let(:method_prefix) { 'legacy' }
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