From d2a97f6e5d471e9e894d7dc2b28fb1c13072e2ef Mon Sep 17 00:00:00 2001 From: Dmitry Gruzd <dgruzd@gitlab.com> Date: Fri, 23 Dec 2022 11:51:59 +0100 Subject: [PATCH] Update gitlab-elasticsearch-indexer to 3.2.0 --- GITLAB_ELASTICSEARCH_INDEXER_VERSION | 2 +- ee/lib/gitlab/elastic/indexer.rb | 9 +++--- ee/spec/lib/gitlab/elastic/indexer_spec.rb | 32 +++++++++++----------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/GITLAB_ELASTICSEARCH_INDEXER_VERSION b/GITLAB_ELASTICSEARCH_INDEXER_VERSION index ef538c2810938..944880fa15e85 100644 --- a/GITLAB_ELASTICSEARCH_INDEXER_VERSION +++ b/GITLAB_ELASTICSEARCH_INDEXER_VERSION @@ -1 +1 @@ -3.1.2 +3.2.0 diff --git a/ee/lib/gitlab/elastic/indexer.rb b/ee/lib/gitlab/elastic/indexer.rb index b006a57660003..720ad10a036c3 100644 --- a/ee/lib/gitlab/elastic/indexer.rb +++ b/ee/lib/gitlab/elastic/indexer.rb @@ -84,17 +84,18 @@ def run_indexer!(base_sha, to_sha, target) vars = build_envvars(base_sha, to_sha, target) path_to_indexer = Gitlab.config.elasticsearch.indexer_path + project_id_argument = "--project-id=#{project.id}" timeout_argument = "--timeout=#{TIMEOUT}s" - command = [path_to_indexer, timeout_argument] + command = [path_to_indexer, project_id_argument, timeout_argument] command << "--search-curation" if Feature.enabled?(:search_index_curation) command += if index_wiki? - ["--blob-type=wiki_blob", "--skip-commits", "--project-path=#{project.full_path}"] + ["--blob-type=wiki_blob", "--skip-commits", "--full-path=#{project.full_path}"] else [ - "--project-path=#{project.full_path}", + "--full-path=#{project.full_path}", "--visibility-level=#{project.visibility_level}", "--repository-access-level=#{project.repository_access_level}" ] @@ -104,7 +105,7 @@ def run_indexer!(base_sha, to_sha, target) command << "--traversal-ids=#{project.namespace_ancestry}" end - command += [project.id.to_s, repository_path] + command += [repository_path] output, status = Gitlab::Popen.popen(command, nil, vars) diff --git a/ee/spec/lib/gitlab/elastic/indexer_spec.rb b/ee/spec/lib/gitlab/elastic/indexer_spec.rb index 821e81fa0238a..499862db482c8 100644 --- a/ee/spec/lib/gitlab/elastic/indexer_spec.rb +++ b/ee/spec/lib/gitlab/elastic/indexer_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Gitlab::Elastic::Indexer do +RSpec.describe Gitlab::Elastic::Indexer, feature_category: :global_search do include StubENV before do @@ -118,12 +118,12 @@ expect_popen.with( [ TestEnv.indexer_bin_path, + "--project-id=#{project.id}", "--timeout=#{Gitlab::Elastic::Indexer::TIMEOUT}s", - "--project-path=#{project.full_path}", + "--full-path=#{project.full_path}", "--visibility-level=#{project.visibility_level}", "--repository-access-level=#{project.repository_access_level}", "--traversal-ids=#{project.namespace_ancestry}", - project.id.to_s, "#{project.repository.disk_path}.git" ], nil, @@ -155,12 +155,12 @@ expect_popen.with( [ TestEnv.indexer_bin_path, + "--project-id=#{project.id}", "--timeout=#{Gitlab::Elastic::Indexer::TIMEOUT}s", '--search-curation', - "--project-path=#{project.full_path}", + "--full-path=#{project.full_path}", "--visibility-level=#{project.visibility_level}", "--repository-access-level=#{project.repository_access_level}", - project.id.to_s, "#{project.repository.disk_path}.git" ], nil, @@ -187,13 +187,13 @@ expect_popen.with( [ TestEnv.indexer_bin_path, + "--project-id=#{project.id}", "--timeout=#{Gitlab::Elastic::Indexer::TIMEOUT}s", '--search-curation', - "--project-path=#{project.full_path}", + "--full-path=#{project.full_path}", "--visibility-level=#{project.visibility_level}", "--repository-access-level=#{project.repository_access_level}", "--traversal-ids=#{project.namespace_ancestry}", - project.id.to_s, "#{project.repository.disk_path}.git" ], nil, @@ -280,21 +280,21 @@ def indexed_commits_for(term) context 'when branch is reset to an earlier commit' do it 'reverses already indexed commits' do change_repository_and_index(project) do - project.repository.create_file(user, '12', '', message: '12', branch_name: 'master') + project.repository.create_file(user, '24', '', message: '24', branch_name: 'master') end head = project.repository.commit.sha - expect(indexed_commits_for('12')).to include(head) - expect(indexed_file_paths_for('12')).to include('12') + expect(indexed_commits_for('24')).to include(head) + expect(indexed_file_paths_for('24')).to include('24') # resetting the repository should purge the index of the outstanding commits change_repository_and_index(project) do project.repository.write_ref('master', initial_commit) end - expect(indexed_commits_for('12')).not_to include(head) - expect(indexed_file_paths_for('12')).not_to include('12') + expect(indexed_commits_for('24')).not_to include(head) + expect(indexed_file_paths_for('24')).not_to include('24') end end end @@ -318,12 +318,12 @@ def indexed_commits_for(term) expect_popen.with( [ TestEnv.indexer_bin_path, + "--project-id=#{project.id}", "--timeout=#{Gitlab::Elastic::Indexer::TIMEOUT}s", '--blob-type=wiki_blob', '--skip-commits', - "--project-path=#{project.full_path}", + "--full-path=#{project.full_path}", "--traversal-ids=#{project.namespace_ancestry}", - project.id.to_s, "#{project.wiki.repository.disk_path}.git" ], nil, @@ -343,13 +343,13 @@ def indexed_commits_for(term) expect_popen.with( [ TestEnv.indexer_bin_path, + "--project-id=#{project.id}", "--timeout=#{Gitlab::Elastic::Indexer::TIMEOUT}s", '--search-curation', '--blob-type=wiki_blob', '--skip-commits', - "--project-path=#{project.full_path}", + "--full-path=#{project.full_path}", "--traversal-ids=#{project.namespace_ancestry}", - project.id.to_s, "#{project.wiki.repository.disk_path}.git" ], nil, -- GitLab