Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2018-07-19 11:37:46 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2018-07-19 14:34:10 +0300
commitcfbb256b8b755e84f8156bc01bc1ba278eeaafa9 (patch)
tree5a9b7cb5ee5d218bdf7f1490b2009f12d037ff69 /spec/migrations
parent928c81e2598da2a114011549b7aa68fce85fd077 (diff)
MigrateProcessCommitWorkerJobs to use Gitaly
This old migration used Rugged to find a commit, while Gitaly is the prefered way now. By migrating this to Gitaly, Gitaly is now a required running component for this migration. Part of https://gitlab.com/gitlab-org/gitaly/issues/1106
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/migrate_process_commit_worker_jobs_spec.rb63
1 files changed, 21 insertions, 42 deletions
diff --git a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb b/spec/migrations/migrate_process_commit_worker_jobs_spec.rb
index a30e6c23ac9..bbb591281d5 100644
--- a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb
+++ b/spec/migrations/migrate_process_commit_worker_jobs_spec.rb
@@ -4,14 +4,11 @@ require 'spec_helper'
require Rails.root.join('db', 'migrate', '20161124141322_migrate_process_commit_worker_jobs.rb')
describe MigrateProcessCommitWorkerJobs do
- let(:project) { create(:project, :legacy_storage, :repository) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
- let(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
- let(:rugged) do
- Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- project.repository.rugged
- end
+ set(:project) { create(:project, :legacy_storage, :repository) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
+ set(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
+ let(:commit) do
+ Gitlab::Git::Commit.last(project.repository.raw)
end
- let(:commit) { rugged.rev_parse(project.commit.id) }
describe 'Project' do
describe 'find_including_path' do
@@ -29,32 +26,13 @@ describe MigrateProcessCommitWorkerJobs do
end
end
- describe '#repository_storage_path' do
- it 'returns the storage path for the repository' do
- migration_project = described_class::Project
- .find_including_path(project.id)
-
- expect(File.directory?(migration_project.repository_storage_path))
- .to eq(true)
- end
- end
-
- describe '#repository_path' do
- it 'returns the path to the repository' do
- migration_project = described_class::Project
- .find_including_path(project.id)
-
- expect(File.directory?(migration_project.repository_path)).to eq(true)
- end
- end
-
describe '#repository' do
it 'returns a Rugged::Repository' do
migration_project = described_class::Project
.find_including_path(project.id)
- expect(migration_project.repository)
- .to be_an_instance_of(Rugged::Repository)
+ expect(migration_project.repository).to respond_to(:storage)
+ expect(migration_project.repository).to respond_to(:gitaly_repository)
end
end
end
@@ -72,7 +50,7 @@ describe MigrateProcessCommitWorkerJobs do
before do
Sidekiq.redis do |redis|
- job = JSON.dump(args: [project.id, user.id, commit.oid])
+ job = JSON.dump(args: [project.id, user.id, commit.id])
redis.lpush('queue:process_commit', job)
end
end
@@ -88,9 +66,10 @@ describe MigrateProcessCommitWorkerJobs do
end
it 'skips jobs using commits that no longer exist' do
- allow_any_instance_of(Rugged::Repository).to receive(:lookup)
- .with(commit.oid)
- .and_raise(Rugged::OdbError)
+ allow_any_instance_of(Gitlab::GitalyClient::CommitService)
+ .to receive(:find_commit)
+ .with(commit.id)
+ .and_return(nil)
migration.up
@@ -105,7 +84,7 @@ describe MigrateProcessCommitWorkerJobs do
it 'encodes data to UTF-8' do
allow_any_instance_of(Rugged::Repository).to receive(:lookup)
- .with(commit.oid)
+ .with(commit.id)
.and_return(commit)
allow(commit).to receive(:message)
@@ -140,7 +119,7 @@ describe MigrateProcessCommitWorkerJobs do
end
it 'includes the commit ID' do
- expect(commit_hash['id']).to eq(commit.oid)
+ expect(commit_hash['id']).to eq(commit.id)
end
it 'includes the commit message' do
@@ -152,27 +131,27 @@ describe MigrateProcessCommitWorkerJobs do
end
it 'includes the author date' do
- expect(commit_hash['authored_date']).to eq(commit.author[:time].to_s)
+ expect(commit_hash['authored_date']).to eq(commit.authored_date.to_s)
end
it 'includes the author name' do
- expect(commit_hash['author_name']).to eq(commit.author[:name])
+ expect(commit_hash['author_name']).to eq(commit.author_name)
end
it 'includes the author Email' do
- expect(commit_hash['author_email']).to eq(commit.author[:email])
+ expect(commit_hash['author_email']).to eq(commit.author_email)
end
it 'includes the commit date' do
- expect(commit_hash['committed_date']).to eq(commit.committer[:time].to_s)
+ expect(commit_hash['committed_date']).to eq(commit.committed_date.to_s)
end
it 'includes the committer name' do
- expect(commit_hash['committer_name']).to eq(commit.committer[:name])
+ expect(commit_hash['committer_name']).to eq(commit.committer_name)
end
it 'includes the committer Email' do
- expect(commit_hash['committer_email']).to eq(commit.committer[:email])
+ expect(commit_hash['committer_email']).to eq(commit.committer_email)
end
end
end
@@ -186,7 +165,7 @@ describe MigrateProcessCommitWorkerJobs do
before do
Sidekiq.redis do |redis|
- job = JSON.dump(args: [project.id, user.id, commit.oid])
+ job = JSON.dump(args: [project.id, user.id, commit.id])
redis.lpush('queue:process_commit', job)
migration.up
@@ -215,7 +194,7 @@ describe MigrateProcessCommitWorkerJobs do
end
it 'includes the commit SHA' do
- expect(job['args'][2]).to eq(commit.oid)
+ expect(job['args'][2]).to eq(commit.id)
end
end
end