Commit ba8ec598 authored by Changzheng Liu's avatar Changzheng Liu Committed by Patrick Bajao

Move Advanced Search Admin Settings to Top Level

parent 1c326df5
...@@ -104,7 +104,6 @@ ...@@ -104,7 +104,6 @@
= f.submit _('Save changes'), class: "gl-button btn btn-success" = f.submit _('Save changes'), class: "gl-button btn btn-success"
= render_if_exists 'admin/application_settings/maintenance_mode_settings_form' = render_if_exists 'admin/application_settings/maintenance_mode_settings_form'
= render_if_exists 'admin/application_settings/elasticsearch_form'
= render 'admin/application_settings/gitpod' = render 'admin/application_settings/gitpod'
= render 'admin/application_settings/kroki' = render 'admin/application_settings/kroki'
= render 'admin/application_settings/plantuml' = render 'admin/application_settings/plantuml'
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
= sprite_icon('close', css_class: 'gl-icon') = sprite_icon('close', css_class: 'gl-icon')
.gl-alert-body .gl-alert-body
%h4.gl-alert-title= s_('AdminSettings|Some settings have moved') %h4.gl-alert-title= s_('AdminSettings|Some settings have moved')
= html_escape_once(s_('AdminSettings|Elasticsearch, PlantUML, Slack application, Third party offers, Snowplow, Amazon EKS have moved to Settings > General.')).html_safe = html_escape_once(s_('AdminSettings|PlantUML, Slack application, Third party offers, Snowplow, Amazon EKS have moved to Settings > General.')).html_safe
.gl-alert-actions .gl-alert-actions
= link_to s_('AdminSettings|Go to General Settings'), general_admin_application_settings_path, class: 'btn gl-alert-action btn-info new-gl-button' = link_to s_('AdminSettings|Go to General Settings'), general_admin_application_settings_path, class: 'btn gl-alert-action btn-info new-gl-button'
......
...@@ -260,6 +260,9 @@ ...@@ -260,6 +260,9 @@
= link_to general_admin_application_settings_path, title: _('General'), class: 'qa-admin-settings-general-item' do = link_to general_admin_application_settings_path, title: _('General'), class: 'qa-admin-settings-general-item' do
%span %span
= _('General') = _('General')
= render_if_exists 'layouts/nav/sidebar/advanced_search', class: 'qa-admin-settings-advanced-search'
- if instance_level_integrations? - if instance_level_integrations?
= nav_link(path: ['application_settings#integrations', 'integrations#edit']) do = nav_link(path: ['application_settings#integrations', 'integrations#edit']) do
= link_to integrations_admin_application_settings_path, title: _('Integrations'), data: { qa_selector: 'integration_settings_link' } do = link_to integrations_admin_application_settings_path, title: _('Integrations'), data: { qa_selector: 'integration_settings_link' } do
......
...@@ -175,8 +175,7 @@ instances](#indexing-large-instances) below. ...@@ -175,8 +175,7 @@ instances](#indexing-large-instances) below.
To enable Advanced Search, you need to have admin access to GitLab: To enable Advanced Search, you need to have admin access to GitLab:
1. Navigate to **Admin Area**, then **Settings > General** 1. Navigate to **Admin Area**, then **Settings > Advanced Search**.
and expand the **Advanced Search** section.
NOTE: NOTE:
To see the Advanced Search section, you need an active Starter To see the Advanced Search section, you need an active Starter
...@@ -186,7 +185,7 @@ To enable Advanced Search, you need to have admin access to GitLab: ...@@ -186,7 +185,7 @@ To enable Advanced Search, you need to have admin access to GitLab:
your Elasticsearch cluster. Do not enable **Search with Elasticsearch enabled** your Elasticsearch cluster. Do not enable **Search with Elasticsearch enabled**
yet. yet.
1. Now enable **Elasticsearch indexing** in **Admin Area > Settings > 1. Now enable **Elasticsearch indexing** in **Admin Area > Settings >
General > Advanced Search** and click **Save changes**. This will create Advanced Search** and click **Save changes**. This will create
an empty index if one does not already exist. an empty index if one does not already exist.
1. Click **Index all projects**. 1. Click **Index all projects**.
1. Click **Check progress** in the confirmation message to see the status of 1. Click **Check progress** in the confirmation message to see the status of
...@@ -202,7 +201,7 @@ To enable Advanced Search, you need to have admin access to GitLab: ...@@ -202,7 +201,7 @@ To enable Advanced Search, you need to have admin access to GitLab:
``` ```
1. After the indexing has completed, enable **Search with Elasticsearch enabled** in 1. After the indexing has completed, enable **Search with Elasticsearch enabled** in
**Admin Area > Settings > General > Advanced Search** and click **Save **Admin Area > Settings > Advanced Search** and click **Save
changes**. changes**.
NOTE: NOTE:
...@@ -265,8 +264,8 @@ You can improve the language support for Chinese and Japanese languages by utili ...@@ -265,8 +264,8 @@ You can improve the language support for Chinese and Japanese languages by utili
To enable language(s) support: To enable language(s) support:
1. Install the desired plugin(s), please refer to [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/plugins/7.9/installation.html) for plugins installation instructions. The plugin(s) must be installed on every node in the cluster, and each node must be restarted after installation. For a list of plugins, see the table later in this section. 1. Install the desired plugin(s), please refer to [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/plugins/7.9/installation.html) for plugins installation instructions. The plugin(s) must be installed on every node in the cluster, and each node must be restarted after installation. For a list of plugins, see the table later in this section.
1. Navigate to the **Admin Area**, then **Settings > General**.. 1. Navigate to the **Admin Area**, then **Settings > Advanced Search**..
1. Expand the **Advanced Search** section and locate **Custom analyzers: language support**. 1. Locate **Custom analyzers: language support**.
1. Enable plugin(s) support for **Indexing**. 1. Enable plugin(s) support for **Indexing**.
1. Click **Save changes** for the changes to take effect. 1. Click **Save changes** for the changes to take effect.
1. Trigger [Zero downtime reindexing](#zero-downtime-reindexing) or reindex everything from scratch to create a new index with updated mappings. 1. Trigger [Zero downtime reindexing](#zero-downtime-reindexing) or reindex everything from scratch to create a new index with updated mappings.
...@@ -285,9 +284,8 @@ For guidance on what to install, see the following Elasticsearch language plugin ...@@ -285,9 +284,8 @@ For guidance on what to install, see the following Elasticsearch language plugin
To disable the Elasticsearch integration: To disable the Elasticsearch integration:
1. Navigate to the **Admin Area**, then **Settings > General**. 1. Navigate to the **Admin Area**, then **Settings > Advanced Search**.
1. Expand the **Advanced Search** section and uncheck **Elasticsearch indexing** 1. Uncheck **Elasticsearch indexing** and **Search with Elasticsearch enabled**.
and **Search with Elasticsearch enabled**.
1. Click **Save changes** for the changes to take effect. 1. Click **Save changes** for the changes to take effect.
1. (Optional) Delete the existing indexes: 1. (Optional) Delete the existing indexes:
...@@ -315,7 +313,7 @@ used by the GitLab Advanced Search integration. ...@@ -315,7 +313,7 @@ used by the GitLab Advanced Search integration.
### Pause the indexing ### Pause the indexing
In the **Admin Area > Settings > General > Advanced Search** section, select the In the **Admin Area > Settings > Advanced Search** section, select the
**Pause Elasticsearch Indexing** setting, and then save your change. **Pause Elasticsearch Indexing** setting, and then save your change.
With this, all updates that should happen on your Elasticsearch index will be With this, all updates that should happen on your Elasticsearch index will be
buffered and caught up once unpaused. buffered and caught up once unpaused.
...@@ -332,7 +330,7 @@ This process involves several shell commands and curl invocations, so a good ...@@ -332,7 +330,7 @@ This process involves several shell commands and curl invocations, so a good
initial setup will help for later: initial setup will help for later:
```shell ```shell
# You can find this value under Admin Area > Settings > General > Advanced Search > URL # You can find this value under Admin Area > Settings > Advanced Search > URL
export CLUSTER_URL="http://localhost:9200" export CLUSTER_URL="http://localhost:9200"
export PRIMARY_INDEX="gitlab-production" export PRIMARY_INDEX="gitlab-production"
export SECONDARY_INDEX="gitlab-production-$(date +%s)" export SECONDARY_INDEX="gitlab-production-$(date +%s)"
...@@ -433,14 +431,14 @@ To trigger the re-index from `primary` index: ...@@ -433,14 +431,14 @@ To trigger the re-index from `primary` index:
1. Unpause the indexing 1. Unpause the indexing
Under **Admin Area > Settings > General > Advanced Search**, uncheck the **Pause Elasticsearch Indexing** setting and save. Under **Admin Area > Settings > Advanced Search**, uncheck the **Pause Elasticsearch Indexing** setting and save.
### Trigger the reindex via the Advanced Search administration ### Trigger the reindex via the Advanced Search administration
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/34069) in [GitLab Starter](https://about.gitlab.com/pricing/) 13.2. > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/34069) in [GitLab Starter](https://about.gitlab.com/pricing/) 13.2.
> - A scheduled index deletion and the ability to cancel it was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38914) in GitLab Starter 13.3. > - A scheduled index deletion and the ability to cancel it was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38914) in GitLab Starter 13.3.
Under **Admin Area > Settings > General > Advanced Search > Elasticsearch zero-downtime reindexing**, click on **Trigger cluster reindexing**. Under **Admin Area > Settings > Advanced Search > Elasticsearch zero-downtime reindexing**, click on **Trigger cluster reindexing**.
Reindexing can be a lengthy process depending on the size of your Elasticsearch cluster. Reindexing can be a lengthy process depending on the size of your Elasticsearch cluster.
...@@ -463,7 +461,7 @@ Sometimes, you might want to abandon the unfinished reindex job and unpause the ...@@ -463,7 +461,7 @@ Sometimes, you might want to abandon the unfinished reindex job and unpause the
bundle exec rake gitlab:elastic:mark_reindex_failed RAILS_ENV=production bundle exec rake gitlab:elastic:mark_reindex_failed RAILS_ENV=production
``` ```
1. Uncheck the "Pause Elasticsearch indexing" checkbox in **Admin Area > Settings > General > Advanced Search**. 1. Uncheck the "Pause Elasticsearch indexing" checkbox in **Admin Area > Settings > Advanced Search**.
## Background migrations ## Background migrations
...@@ -823,7 +821,7 @@ There are a couple of ways to achieve that: ...@@ -823,7 +821,7 @@ There are a couple of ways to achieve that:
This is always correctly identifying whether the current project/namespace This is always correctly identifying whether the current project/namespace
being searched is using Elasticsearch. being searched is using Elasticsearch.
- From the admin area under **Settings > General > Advanced Search** check that the - From the admin area under **Settings > Advanced Search** check that the
Advanced Search settings are checked. Advanced Search settings are checked.
Those same settings there can be obtained from the Rails console if necessary: Those same settings there can be obtained from the Rails console if necessary:
......
...@@ -59,6 +59,6 @@ class Admin::ElasticsearchController < Admin::ApplicationController ...@@ -59,6 +59,6 @@ class Admin::ElasticsearchController < Admin::ApplicationController
private private
def redirect_path def redirect_path
general_admin_application_settings_path(anchor: 'js-elasticsearch-settings') advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end end
end end
...@@ -7,17 +7,18 @@ module EE ...@@ -7,17 +7,18 @@ module EE
extend ActiveSupport::Concern extend ActiveSupport::Concern
prepended do prepended do
before_action :elasticsearch_reindexing_task, only: [:general] before_action :elasticsearch_reindexing_task, only: [:advanced_search]
feature_category :provision, [:seat_link_payload] feature_category :provision, [:seat_link_payload]
feature_category :source_code_management, [:templates] feature_category :source_code_management, [:templates]
feature_category :global_search, [:advanced_search]
def elasticsearch_reindexing_task def elasticsearch_reindexing_task
@elasticsearch_reindexing_task = Elastic::ReindexingTask.last @elasticsearch_reindexing_task = Elastic::ReindexingTask.last
end end
end end
EE_VALID_SETTING_PANELS = %w(templates).freeze EE_VALID_SETTING_PANELS = %w(advanced_search templates).freeze
EE_VALID_SETTING_PANELS.each do |action| EE_VALID_SETTING_PANELS.each do |action|
define_method(action) { perform_update if submitted? } define_method(action) { perform_update if submitted? }
......
...@@ -3,21 +3,18 @@ ...@@ -3,21 +3,18 @@
- recreate_index_url = help_page_url('integration/elasticsearch.md') - recreate_index_url = help_page_url('integration/elasticsearch.md')
- recreate_index_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: recreate_index_url } - recreate_index_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: recreate_index_url }
- recreate_index_text = _("Changes won't take place until the index is %{link_start}recreated%{link_end}.").html_safe % { link_start: recreate_index_link_start, link_end: '</a>'.html_safe } - recreate_index_text = _("Changes won't take place until the index is %{link_start}recreated%{link_end}.").html_safe % { link_start: recreate_index_link_start, link_end: '</a>'.html_safe }
- expanded = integration_expanded?('elasticsearch_')
- elasticsearch_available = Gitlab::Elastic::Helper.default.client.ping - elasticsearch_available = Gitlab::Elastic::Helper.default.client.ping
%section.settings.as-elasticsearch.no-animate#js-elasticsearch-settings{ class: ('expanded' if expanded), data: { qa_selector: 'elasticsearch_tab' } } %section.settings.expanded.as-elasticsearch.no-animate#js-elasticsearch-settings{ data: { qa_selector: 'elasticsearch_tab' } }
.settings-header .settings-header
%h4 %h4
= _('Advanced Search') = _('Advanced Search')
%button.btn.gl-button.js-settings-toggle{ type: 'button' }
= expanded ? 'Collapse' : 'Expand'
%p %p
= _('Advanced Search with Elasticsearch') = _('Advanced Search with Elasticsearch')
.settings-content .settings-content
= form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-elasticsearch-settings'), html: { class: 'fieldset-form' } do |f| = form_for @application_setting, url: advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings'), html: { class: 'fieldset-form' } do |f|
= form_errors(@application_setting) if expanded = form_errors(@application_setting)
%fieldset %fieldset
.sub-section .sub-section
......
- breadcrumb_title _("Advanced Search")
- page_title _("Advanced Search")
- @content_class = "limit-container-width" unless fluid_layout
= render_if_exists 'admin/application_settings/elasticsearch_form'
= feature_entry(_('Advanced Search'), = feature_entry(_('Advanced Search'),
href: general_admin_application_settings_path(anchor: 'js-elasticsearch-settings'), href: advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings'),
doc_href: help_page_path('integration/elasticsearch'), doc_href: help_page_path('integration/elasticsearch'),
enabled: Gitlab::CurrentSettings.elasticsearch_search?) enabled: Gitlab::CurrentSettings.elasticsearch_search?)
......
- return unless License.feature_available?(:elastic_search)
= nav_link(path: 'application_settings#advanced_search') do
= link_to advanced_search_admin_application_settings_path, title: _('Advanced Search'), class: 'qa-admin-settings-advanced-search' do
%span
= _('Advanced Search')
---
title: Move Advanced Search Admin Settings to Top Level
merge_request: 51026
author:
type: changed
...@@ -35,7 +35,7 @@ namespace :admin do ...@@ -35,7 +35,7 @@ namespace :admin do
# using `only: []` to keep duplicate routes from being created # using `only: []` to keep duplicate routes from being created
resource :application_settings, only: [] do resource :application_settings, only: [] do
get :seat_link_payload get :seat_link_payload
match :templates, via: [:get, :patch] match :templates, :advanced_search, via: [:get, :patch]
get :geo, to: "geo/settings#show" get :geo, to: "geo/settings#show"
end end
......
...@@ -11,25 +11,6 @@ RSpec.describe Admin::ApplicationSettingsController do ...@@ -11,25 +11,6 @@ RSpec.describe Admin::ApplicationSettingsController do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
end end
describe 'GET #general' do
before do
sign_in(admin)
end
context 'zero-downtime elasticsearch reindexing' do
render_views
let!(:task) { create(:elastic_reindexing_task) }
it 'assigns elasticsearch reindexing task' do
get :general
expect(assigns(:elasticsearch_reindexing_task)).to eq(task)
expect(response.body).to include("Reindexing Status: #{task.state}")
end
end
end
describe 'PUT #update' do describe 'PUT #update' do
before do before do
sign_in(admin) sign_in(admin)
...@@ -38,13 +19,6 @@ RSpec.describe Admin::ApplicationSettingsController do ...@@ -38,13 +19,6 @@ RSpec.describe Admin::ApplicationSettingsController do
it 'updates the EE specific application settings' do it 'updates the EE specific application settings' do
settings = { settings = {
help_text: 'help_text', help_text: 'help_text',
elasticsearch_url: 'http://my-elastic.search:9200',
elasticsearch_indexing: false,
elasticsearch_aws: true,
elasticsearch_aws_access_key: 'elasticsearch_aws_access_key',
elasticsearch_aws_secret_access_key: 'elasticsearch_aws_secret_access_key',
elasticsearch_aws_region: 'elasticsearch_aws_region',
elasticsearch_search: true,
repository_size_limit: 1024, repository_size_limit: 1024,
shared_runners_minutes: 60, shared_runners_minutes: 60,
geo_status_timeout: 30, geo_status_timeout: 30,
...@@ -62,25 +36,10 @@ RSpec.describe Admin::ApplicationSettingsController do ...@@ -62,25 +36,10 @@ RSpec.describe Admin::ApplicationSettingsController do
put :update, params: { application_setting: settings } put :update, params: { application_setting: settings }
expect(response).to redirect_to(general_admin_application_settings_path) expect(response).to redirect_to(general_admin_application_settings_path)
settings.except(:elasticsearch_url, :repository_size_limit).each do |setting, value| settings.except(:repository_size_limit).each do |setting, value|
expect(ApplicationSetting.current.public_send(setting)).to eq(value) expect(ApplicationSetting.current.public_send(setting)).to eq(value)
end end
expect(ApplicationSetting.current.repository_size_limit).to eq(settings[:repository_size_limit].megabytes) expect(ApplicationSetting.current.repository_size_limit).to eq(settings[:repository_size_limit].megabytes)
expect(ApplicationSetting.current.elasticsearch_url).to contain_exactly(settings[:elasticsearch_url])
end
context 'elasticsearch_aws_secret_access_key setting is blank' do
let(:settings) do
{
elasticsearch_aws_access_key: 'elasticsearch_aws_access_key',
elasticsearch_aws_secret_access_key: ''
}
end
it 'does not update the elasticsearch_aws_secret_access_key setting' do
expect { put :update, params: { application_setting: settings } }
.not_to change { ApplicationSetting.current.reload.elasticsearch_aws_secret_access_key }
end
end end
shared_examples 'settings for licensed features' do shared_examples 'settings for licensed features' do
...@@ -323,6 +282,62 @@ RSpec.describe Admin::ApplicationSettingsController do ...@@ -323,6 +282,62 @@ RSpec.describe Admin::ApplicationSettingsController do
end end
end end
describe '#advanced_search' do
before do
sign_in(admin)
@request.env['HTTP_REFERER'] = advanced_search_admin_application_settings_path
end
context 'advanced search settings' do
it 'updates the advanced search settings' do
settings = {
elasticsearch_url: 'http://my-elastic.search:9200',
elasticsearch_indexing: false,
elasticsearch_aws: true,
elasticsearch_aws_access_key: 'elasticsearch_aws_access_key',
elasticsearch_aws_secret_access_key: 'elasticsearch_aws_secret_access_key',
elasticsearch_aws_region: 'elasticsearch_aws_region',
elasticsearch_search: true
}
patch :advanced_search, params: { application_setting: settings }
expect(response).to redirect_to(advanced_search_admin_application_settings_path)
settings.except(:elasticsearch_url).each do |setting, value|
expect(ApplicationSetting.current.public_send(setting)).to eq(value)
end
expect(ApplicationSetting.current.elasticsearch_url).to contain_exactly(settings[:elasticsearch_url])
end
end
context 'zero-downtime elasticsearch reindexing' do
render_views
let!(:task) { create(:elastic_reindexing_task) }
it 'assigns elasticsearch reindexing task' do
get :advanced_search
expect(assigns(:elasticsearch_reindexing_task)).to eq(task)
expect(response.body).to include("Reindexing Status: #{task.state}")
end
end
context 'elasticsearch_aws_secret_access_key setting is blank' do
let(:settings) do
{
elasticsearch_aws_access_key: 'elasticsearch_aws_access_key',
elasticsearch_aws_secret_access_key: ''
}
end
it 'does not update the elasticsearch_aws_secret_access_key setting' do
expect { patch :advanced_search, params: { application_setting: settings } }
.not_to change { ApplicationSetting.current.reload.elasticsearch_aws_secret_access_key }
end
end
end
describe 'GET #seat_link_payload' do describe 'GET #seat_link_payload' do
context 'when a non-admin user attempts a request' do context 'when a non-admin user attempts a request' do
before do before do
......
...@@ -21,7 +21,7 @@ RSpec.describe Admin::ElasticsearchController do ...@@ -21,7 +21,7 @@ RSpec.describe Admin::ElasticsearchController do
post :enqueue_index post :enqueue_index
expect(controller).to set_flash[:notice].to include('/admin/sidekiq/queues/elastic_commit_indexer') expect(controller).to set_flash[:notice].to include('/admin/sidekiq/queues/elastic_commit_indexer')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings') expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end end
context 'without an index' do context 'without an index' do
...@@ -35,7 +35,7 @@ RSpec.describe Admin::ElasticsearchController do ...@@ -35,7 +35,7 @@ RSpec.describe Admin::ElasticsearchController do
post :enqueue_index post :enqueue_index
expect(controller).to set_flash[:warning].to include('create an index before enabling indexing') expect(controller).to set_flash[:warning].to include('create an index before enabling indexing')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings') expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end end
end end
end end
...@@ -51,7 +51,7 @@ RSpec.describe Admin::ElasticsearchController do ...@@ -51,7 +51,7 @@ RSpec.describe Admin::ElasticsearchController do
post :trigger_reindexing post :trigger_reindexing
expect(controller).to set_flash[:notice].to include('reindexing triggered') expect(controller).to set_flash[:notice].to include('reindexing triggered')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings') expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end end
it 'does not create a reindexing task if there is another one' do it 'does not create a reindexing task if there is another one' do
...@@ -61,7 +61,7 @@ RSpec.describe Admin::ElasticsearchController do ...@@ -61,7 +61,7 @@ RSpec.describe Admin::ElasticsearchController do
post :trigger_reindexing post :trigger_reindexing
expect(controller).to set_flash[:warning].to include('already in progress') expect(controller).to set_flash[:warning].to include('already in progress')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings') expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end end
end end
...@@ -77,7 +77,7 @@ RSpec.describe Admin::ElasticsearchController do ...@@ -77,7 +77,7 @@ RSpec.describe Admin::ElasticsearchController do
expect(task.reload.delete_original_index_at).to be_nil expect(task.reload.delete_original_index_at).to be_nil
expect(controller).to set_flash[:notice].to include('deletion is canceled') expect(controller).to set_flash[:notice].to include('deletion is canceled')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings') expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end end
end end
...@@ -100,7 +100,7 @@ RSpec.describe Admin::ElasticsearchController do ...@@ -100,7 +100,7 @@ RSpec.describe Admin::ElasticsearchController do
expect(Elastic::DataMigrationService.halted_migrations?).to be_falsey expect(Elastic::DataMigrationService.halted_migrations?).to be_falsey
expect(controller).to set_flash[:notice].to include('Migration has been scheduled to be retried') expect(controller).to set_flash[:notice].to include('Migration has been scheduled to be retried')
expect(response).to redirect_to general_admin_application_settings_path(anchor: 'js-elasticsearch-settings') expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-settings')
end end
end end
end end
...@@ -53,11 +53,11 @@ RSpec.describe 'Admin updates EE-only settings' do ...@@ -53,11 +53,11 @@ RSpec.describe 'Admin updates EE-only settings' do
end end
context 'Elasticsearch settings' do context 'Elasticsearch settings' do
let(:elastic_search_license) { true }
before do before do
visit general_admin_application_settings_path stub_licensed_features(elastic_search: elastic_search_license)
page.within('.as-elasticsearch') do visit advanced_search_admin_application_settings_path
click_button 'Expand'
end
end end
it 'changes elasticsearch settings' do it 'changes elasticsearch settings' do
...@@ -138,14 +138,12 @@ RSpec.describe 'Admin updates EE-only settings' do ...@@ -138,14 +138,12 @@ RSpec.describe 'Admin updates EE-only settings' do
namespace = create(:elasticsearch_indexed_namespace).namespace namespace = create(:elasticsearch_indexed_namespace).namespace
project = create(:elasticsearch_indexed_project).project project = create(:elasticsearch_indexed_project).project
visit general_admin_application_settings_path visit advanced_search_admin_application_settings_path
expect(ElasticsearchIndexedNamespace.count).to be > 0 expect(ElasticsearchIndexedNamespace.count).to be > 0
expect(ElasticsearchIndexedProject.count).to be > 0 expect(ElasticsearchIndexedProject.count).to be > 0
page.within('.as-elasticsearch') do page.within('.as-elasticsearch') do
click_button 'Expand'
expect(page).to have_content('Namespaces to index') expect(page).to have_content('Namespaces to index')
expect(page).to have_content('Projects to index') expect(page).to have_content('Projects to index')
expect(page).to have_content(namespace.full_path) expect(page).to have_content(namespace.full_path)
...@@ -175,6 +173,14 @@ RSpec.describe 'Admin updates EE-only settings' do ...@@ -175,6 +173,14 @@ RSpec.describe 'Admin updates EE-only settings' do
expect(text).to eq 'Are you sure you want to reindex?' expect(text).to eq 'Are you sure you want to reindex?'
page.driver.browser.switch_to.alert.accept page.driver.browser.switch_to.alert.accept
end end
context 'when not licensed' do
let(:elastic_search_license) { false }
it 'cannot access the page' do
expect(page).not_to have_content("Advanced Search with Elasticsearch")
end
end
end end
it 'enable Slack application' do it 'enable Slack application' do
......
...@@ -105,5 +105,10 @@ RSpec.describe 'EE-specific admin routing' do ...@@ -105,5 +105,10 @@ RSpec.describe 'EE-specific admin routing' do
expect(get('/admin/application_settings/templates')).to route_to('admin/application_settings#templates') expect(get('/admin/application_settings/templates')).to route_to('admin/application_settings#templates')
expect(patch('/admin/application_settings/templates')).to route_to('admin/application_settings#templates') expect(patch('/admin/application_settings/templates')).to route_to('admin/application_settings#templates')
end end
it 'redirects /advanced_search to to #advanced_search' do
expect(get('/admin/application_settings/advanced_search')).to route_to('admin/application_settings#advanced_search')
expect(patch('/admin/application_settings/advanced_search')).to route_to('admin/application_settings#advanced_search')
end
end end
end end
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'layouts/nav/sidebar/_admin' do RSpec.describe 'layouts/nav/sidebar/_admin' do
context 'on settings' do context 'on templates settings' do
before do before do
stub_licensed_features(custom_file_templates: custom_file_templates) stub_licensed_features(custom_file_templates: custom_file_templates)
...@@ -26,4 +26,28 @@ RSpec.describe 'layouts/nav/sidebar/_admin' do ...@@ -26,4 +26,28 @@ RSpec.describe 'layouts/nav/sidebar/_admin' do
end end
end end
end end
context 'on advanced search settings' do
before do
stub_licensed_features(elastic_search: elastic_search_license)
render
end
context 'license with elastic_search feature' do
let(:elastic_search_license) { true }
it 'includes Advanced Search link' do
expect(rendered).to have_link('Advanced Search', href: '/admin/application_settings/advanced_search')
end
end
context 'license without elastic_search feature' do
let(:elastic_search_license) { false }
it 'includes Advanced Search link' do
expect(rendered).not_to have_link('Advanced Search', href: '/admin/application_settings/advanced_search')
end
end
end
end end
...@@ -2023,9 +2023,6 @@ msgstr "" ...@@ -2023,9 +2023,6 @@ msgstr ""
msgid "AdminSettings|Disable feed token" msgid "AdminSettings|Disable feed token"
msgstr "" msgstr ""
msgid "AdminSettings|Elasticsearch, PlantUML, Slack application, Third party offers, Snowplow, Amazon EKS have moved to Settings &gt; General."
msgstr ""
msgid "AdminSettings|Enable shared runners for new projects" msgid "AdminSettings|Enable shared runners for new projects"
msgstr "" msgstr ""
...@@ -2047,6 +2044,9 @@ msgstr "" ...@@ -2047,6 +2044,9 @@ msgstr ""
msgid "AdminSettings|No required pipeline" msgid "AdminSettings|No required pipeline"
msgstr "" msgstr ""
msgid "AdminSettings|PlantUML, Slack application, Third party offers, Snowplow, Amazon EKS have moved to Settings &gt; General."
msgstr ""
msgid "AdminSettings|Required pipeline configuration" msgid "AdminSettings|Required pipeline configuration"
msgstr "" msgstr ""
......
...@@ -81,7 +81,6 @@ module QA ...@@ -81,7 +81,6 @@ module QA
module Settings module Settings
autoload :Templates, 'qa/ee/page/admin/settings/templates' autoload :Templates, 'qa/ee/page/admin/settings/templates'
autoload :Elasticsearch, 'qa/ee/page/admin/settings/elasticsearch'
autoload :Preferences, 'qa/ee/page/admin/settings/preferences' autoload :Preferences, 'qa/ee/page/admin/settings/preferences'
module Component module Component
......
...@@ -13,6 +13,7 @@ module QA ...@@ -13,6 +13,7 @@ module QA
base.class_eval do base.class_eval do
view 'app/views/layouts/nav/sidebar/_admin.html.haml' do view 'app/views/layouts/nav/sidebar/_admin.html.haml' do
element :admin_settings_template_item element :admin_settings_template_item
element :admin_settings_advanced_search
end end
view 'ee/app/views/layouts/nav/ee/admin/_geo_sidebar.html.haml' do view 'ee/app/views/layouts/nav/ee/admin/_geo_sidebar.html.haml' do
...@@ -52,6 +53,14 @@ module QA ...@@ -52,6 +53,14 @@ module QA
end end
end end
end end
def go_to_advanced_search
hover_element(:admin_settings_item) do
within_submenu(:admin_sidebar_settings_submenu_content) do
click_element :admin_settings_advanced_search
end
end
end
end end
end end
end end
......
# frozen_string_literal: true
module QA
module EE
module Page
module Admin
module Settings
class Elasticsearch < QA::Page::Base
include QA::Page::Settings::Common
view 'ee/app/views/admin/application_settings/_elasticsearch_form.html.haml' do
element :elasticsearch_tab
end
def expand_elasticsearch(&block)
expand_content(:elasticsearch_tab) do
Component::Elasticsearch.perform(&block)
end
end
end
end
end
end
end
end
...@@ -17,15 +17,14 @@ module QA ...@@ -17,15 +17,14 @@ module QA
def fabricate! def fabricate!
QA::Page::Main::Menu.perform(&:go_to_admin_area) QA::Page::Main::Menu.perform(&:go_to_admin_area)
QA::Page::Admin::Menu.perform(&:go_to_general_settings) QA::Page::Admin::Menu.perform(&:go_to_advanced_search)
QA::EE::Page::Admin::Settings::Elasticsearch.perform do |settings| QA::EE::Page::Admin::Settings::Component::Elasticsearch.perform do |es|
settings.expand_elasticsearch do |es| es.check_indexing if @es_indexing
es.check_indexing if @es_indexing es.check_search if @es_enabled
es.check_search if @es_enabled es.enter_link(@es_url)
es.enter_link(@es_url) es.click_submit
es.click_submit
end
end end
sleep(90) sleep(90)
# wait for the change to propagate before inserting records or else # wait for the change to propagate before inserting records or else
# Gitlab::CurrentSettings.elasticsearch_indexing and # Gitlab::CurrentSettings.elasticsearch_indexing and
......
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