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:
Diffstat (limited to 'spec/services/projects/destroy_service_spec.rb')
-rw-r--r--spec/services/projects/destroy_service_spec.rb57
1 files changed, 17 insertions, 40 deletions
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb
index cd923720631..c00438199fd 100644
--- a/spec/services/projects/destroy_service_spec.rb
+++ b/spec/services/projects/destroy_service_spec.rb
@@ -9,7 +9,6 @@ RSpec.describe Projects::DestroyService, :aggregate_failures, :event_store_publi
let!(:project) { create(:project, :repository, namespace: user.namespace) }
let(:path) { project.repository.disk_path }
- let(:remove_path) { removal_path(path) }
let(:async) { false } # execute or async_execute
before do
@@ -24,7 +23,6 @@ RSpec.describe Projects::DestroyService, :aggregate_failures, :event_store_publi
expect(Project.unscoped.all).not_to include(project)
expect(project.gitlab_shell.repository_exists?(project.repository_storage, path + '.git')).to be_falsey
- expect(project.gitlab_shell.repository_exists?(project.repository_storage, remove_path + '.git')).to be_falsey
end
it 'publishes a ProjectDeleted event with project id and namespace id' do
@@ -73,6 +71,18 @@ RSpec.describe Projects::DestroyService, :aggregate_failures, :event_store_publi
end
it_behaves_like 'deleting the project'
+
+ context 'when project is undergoing refresh' do
+ let!(:build_artifacts_size_refresh) { create(:project_build_artifacts_size_refresh, :pending, project: project) }
+
+ it 'does not log about artifact deletion but continues to delete artifacts' do
+ expect(Gitlab::ProjectStatsRefreshConflictsLogger).not_to receive(:warn_artifact_deletion_during_stats_refresh)
+
+ expect { destroy_project(project, user, {}) }
+ .to change { Ci::JobArtifact.count }.by(-2)
+ .and change { Projects::BuildArtifactsSizeRefresh.count }.by(-1)
+ end
+ end
end
end
@@ -192,10 +202,6 @@ RSpec.describe Projects::DestroyService, :aggregate_failures, :event_store_publi
it do
expect(project.gitlab_shell.repository_exists?(project.repository_storage, path + '.git')).to be_falsey
end
-
- it do
- expect(project.gitlab_shell.repository_exists?(project.repository_storage, remove_path + '.git')).to be_truthy
- end
end
context 'when flushing caches fail due to Git errors' do
@@ -392,36 +398,13 @@ RSpec.describe Projects::DestroyService, :aggregate_failures, :event_store_publi
end
end
- context 'repository +deleted path removal' do
- context 'regular phase' do
- it 'schedules +deleted removal of existing repos' do
- service = described_class.new(project, user, {})
- allow(service).to receive(:schedule_stale_repos_removal)
-
- expect(Repositories::ShellDestroyService).to receive(:new).and_call_original
- expect(GitlabShellWorker).to receive(:perform_in)
- .with(5.minutes, :remove_repository, project.repository_storage, removal_path(project.disk_path))
-
- service.execute
+ context 'repository removal' do
+ it 'removal of existing repos' do
+ expect_next_instances_of(Repositories::DestroyService, 2) do |instance|
+ expect(instance).to receive(:execute).and_return(status: :success)
end
- end
-
- context 'stale cleanup' do
- let(:async) { true }
-
- it 'schedules +deleted wiki and repo removal' do
- allow(ProjectDestroyWorker).to receive(:perform_async)
-
- expect(Repositories::ShellDestroyService).to receive(:new).with(project.repository).and_call_original
- expect(GitlabShellWorker).to receive(:perform_in)
- .with(10.minutes, :remove_repository, project.repository_storage, removal_path(project.disk_path))
-
- expect(Repositories::ShellDestroyService).to receive(:new).with(project.wiki.repository).and_call_original
- expect(GitlabShellWorker).to receive(:perform_in)
- .with(10.minutes, :remove_repository, project.repository_storage, removal_path(project.wiki.disk_path))
- destroy_project(project, user, {})
- end
+ described_class.new(project, user, {}).execute
end
end
@@ -480,7 +463,6 @@ RSpec.describe Projects::DestroyService, :aggregate_failures, :event_store_publi
expect do
destroy_project(project, user)
end.to change(WebHook, :count).by(-2)
- .and change(WebHookLog, :count).by(-1)
end
context 'when an error is raised deleting webhooks' do
@@ -541,7 +523,6 @@ RSpec.describe Projects::DestroyService, :aggregate_failures, :event_store_publi
expect(Project.unscoped.all).not_to include(project)
expect(project.gitlab_shell.repository_exists?(project.repository_storage, path + '.git')).to be_falsey
- expect(project.gitlab_shell.repository_exists?(project.repository_storage, remove_path + '.git')).to be_falsey
expect(project.all_pipelines).to be_empty
expect(project.builds).to be_empty
end
@@ -550,8 +531,4 @@ RSpec.describe Projects::DestroyService, :aggregate_failures, :event_store_publi
def destroy_project(project, user, params = {})
described_class.new(project, user, params).public_send(async ? :async_execute : :execute)
end
-
- def removal_path(path)
- "#{path}+#{project.id}#{Repositories::DestroyService::DELETED_FLAG}"
- end
end