diff options
author | Tomislav Nikic <tnikic@gitlab.com> | 2019-07-30 08:02:27 +0000 |
---|---|---|
committer | Mark Lapierre <mlapierre@gitlab.com> | 2019-07-30 08:02:27 +0000 |
commit | 72b62b51bdf513e2936301cb6c7c91ec27c35b4d (patch) | |
tree | 31e459835fc149b9eb6998e564d4ac5333faf20f /qa | |
parent | a2c5925e137e4e0b485edb17ed00cfa3c67a1ff8 (diff) | |
download | gitlab-ce-72b62b51bdf513e2936301cb6c7c91ec27c35b4d.tar.gz |
Creating a new elasticsearch test
Adding a new elasticsearch test suite with all the changes to views
as well as pageobjects.
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa.rb | 4 | ||||
-rw-r--r-- | qa/qa/ee.rb | 10 | ||||
-rw-r--r-- | qa/qa/ee/page/admin/settings/component/elasticsearch.rb | 43 | ||||
-rw-r--r-- | qa/qa/ee/page/admin/settings/integration.rb | 25 | ||||
-rw-r--r-- | qa/qa/ee/resource/settings/elasticsearch.rb | 64 | ||||
-rw-r--r-- | qa/qa/ee/scenario/test/integration/elasticsearch.rb | 15 | ||||
-rw-r--r-- | qa/qa/page/admin/menu.rb | 12 | ||||
-rw-r--r-- | qa/qa/page/main/menu.rb | 8 | ||||
-rw-r--r-- | qa/qa/page/search/results.rb | 33 | ||||
-rw-r--r-- | qa/qa/specs/features/ee/browser_ui/3_create/elasticsearch/elasticsearch_reindexing_spec.rb | 71 |
10 files changed, 285 insertions, 0 deletions
@@ -314,6 +314,10 @@ module QA autoload :Login, 'qa/page/mattermost/login' end + module Search + autoload :Results, 'qa/page/search/results' + end + ## # Classes describing components that are used by several pages. # diff --git a/qa/qa/ee.rb b/qa/qa/ee.rb index 408820cc676..0af8f0ec39a 100644 --- a/qa/qa/ee.rb +++ b/qa/qa/ee.rb @@ -49,6 +49,11 @@ module QA module Settings autoload :Templates, 'qa/ee/page/admin/settings/templates' + autoload :Integration, 'qa/ee/page/admin/settings/integration' + + module Component + autoload :Elasticsearch, 'qa/ee/page/admin/settings/component/elasticsearch' + end end end @@ -111,6 +116,10 @@ module QA module Geo autoload :Node, 'qa/ee/resource/geo/node' end + + module Settings + autoload :Elasticsearch, 'qa/ee/resource/settings/elasticsearch' + end end module Scenario @@ -118,6 +127,7 @@ module QA autoload :Geo, 'qa/ee/scenario/test/geo' module Integration autoload :GroupSAML, 'qa/ee/scenario/test/integration/group_saml' + autoload :Elasticsearch, 'qa/ee/scenario/test/integration/elasticsearch' end end end diff --git a/qa/qa/ee/page/admin/settings/component/elasticsearch.rb b/qa/qa/ee/page/admin/settings/component/elasticsearch.rb new file mode 100644 index 00000000000..d544260305a --- /dev/null +++ b/qa/qa/ee/page/admin/settings/component/elasticsearch.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module QA + module EE + module Page + module Admin + module Settings + module Component + class Elasticsearch < QA::Page::Base + view 'ee/app/views/admin/application_settings/_elasticsearch_form.html.haml' do + element :indexing_checkbox + element :experimental_indexer_checkbox + element :search_checkbox + element :url_field + element :submit_button + end + + def check_indexing + check_element :indexing_checkbox + end + + def check_new_indexer + check_element :experimental_indexer_checkbox + end + + def check_search + check_element :search_checkbox + end + + def enter_link(link) + fill_element(:url_field, link) + end + + def click_submit + click_element(:submit_button) + end + end + end + end + end + end + end +end diff --git a/qa/qa/ee/page/admin/settings/integration.rb b/qa/qa/ee/page/admin/settings/integration.rb new file mode 100644 index 00000000000..15ac34b6184 --- /dev/null +++ b/qa/qa/ee/page/admin/settings/integration.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module QA + module EE + module Page + module Admin + module Settings + class Integration < 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_section(:elasticsearch_tab) do + Component::Elasticsearch.perform(&block) + end + end + end + end + end + end + end +end diff --git a/qa/qa/ee/resource/settings/elasticsearch.rb b/qa/qa/ee/resource/settings/elasticsearch.rb new file mode 100644 index 00000000000..abe7661a8a4 --- /dev/null +++ b/qa/qa/ee/resource/settings/elasticsearch.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +module QA + module EE + module Resource + module Settings + class Elasticsearch < QA::Resource::Base + attr_accessor :es_enabled + attr_accessor :es_indexing + attr_accessor :es_url + attr_accessor :es_experimental_indexer + + def initialize + @es_enabled = true + @es_indexing = true + @es_experimental_indexer = true + @es_url = 'http://elastic68:9200' + end + + def fabricate! + QA::Page::Main::Menu.perform(&:click_admin_area) + QA::Page::Admin::Menu.perform(&:go_to_integration_settings) + QA::EE::Page::Admin::Settings::Integration.perform do |integration| + integration.expand_elasticsearch do |es| + es.check_indexing if @es_indexing + es.check_new_indexer if @es_experimental_indexer + es.check_search if @es_enabled + es.enter_link(@es_url) + es.click_submit + end + end + end + + def fabricate_via_api! + @es_enabled ? api_post : resource_web_url(api_get) + end + + def resource_web_url(resource) + super + rescue ResourceURLMissingError + # this particular resource does not expose a web_url property + end + + def api_get_path + "/application/settings" + end + + def api_post_path + "/application/settings" + end + + def api_post_body + { + elasticsearch_search: @es_enabled, + elasticsearch_indexing: @es_indexing, + elasticsearch_experimental_indexer: @es_experimental_indexer, + elasticsearch_url: @es_url + } + end + end + end + end + end +end diff --git a/qa/qa/ee/scenario/test/integration/elasticsearch.rb b/qa/qa/ee/scenario/test/integration/elasticsearch.rb new file mode 100644 index 00000000000..9a99c8d9ddf --- /dev/null +++ b/qa/qa/ee/scenario/test/integration/elasticsearch.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module QA + module EE + module Scenario + module Test + module Integration + class Elasticsearch < QA::Scenario::Test::Instance::All + tags :elasticsearch + end + end + end + end + end +end diff --git a/qa/qa/page/admin/menu.rb b/qa/qa/page/admin/menu.rb index 8d5c30bfdcf..38fd5f61bad 100644 --- a/qa/qa/page/admin/menu.rb +++ b/qa/qa/page/admin/menu.rb @@ -15,6 +15,10 @@ module QA element :admin_settings_metrics_and_profiling_item end + view 'app/views/layouts/nav/sidebar/_admin.html.haml' do + element :integration_settings_link + end + def go_to_repository_settings hover_settings do within_submenu do @@ -23,6 +27,14 @@ module QA end end + def go_to_integration_settings + hover_settings do + within_submenu do + click_element :integration_settings_link + end + end + end + def go_to_general_settings hover_settings do within_submenu do diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb index d86d554356e..e3039149ab4 100644 --- a/qa/qa/page/main/menu.rb +++ b/qa/qa/page/main/menu.rb @@ -27,6 +27,10 @@ module QA element :your_projects_link end + view 'app/views/layouts/_search.html.haml' do + element :search_term_field + end + def go_to_groups within_top_menu do click_element :groups_dropdown @@ -71,6 +75,10 @@ module QA click_element :snippets_link end + def search_for(term) + fill_element :search_term_field, "#{term}\n" + end + def has_personal_area?(wait: Capybara.default_max_wait_time) has_element?(:user_avatar, wait: wait) end diff --git a/qa/qa/page/search/results.rb b/qa/qa/page/search/results.rb new file mode 100644 index 00000000000..b9b18abf660 --- /dev/null +++ b/qa/qa/page/search/results.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module QA::Page + module Search + class Results < QA::Page::Base + view 'app/views/search/_category.html.haml' do + element :code_tab + end + + view 'app/views/search/results/_blob_data.html.haml' do + element :result_item_content + element :file_title_content + element :file_text_content + end + + def switch_to_code + click_element(:code_tab) + end + + def has_file_in_project?(file_name, project_name) + has_element? :result_item_content, text: "#{project_name}: #{file_name}" + end + + def has_file_with_content?(file_name, file_text) + within_element_by_index :result_item_content, 0 do + false unless has_element? :file_title_content, text: file_name + + has_element? :file_text_content, text: file_text + end + end + end + end +end diff --git a/qa/qa/specs/features/ee/browser_ui/3_create/elasticsearch/elasticsearch_reindexing_spec.rb b/qa/qa/specs/features/ee/browser_ui/3_create/elasticsearch/elasticsearch_reindexing_spec.rb new file mode 100644 index 00000000000..b180cf7fea0 --- /dev/null +++ b/qa/qa/specs/features/ee/browser_ui/3_create/elasticsearch/elasticsearch_reindexing_spec.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +module QA + context 'Create' do + describe 'Search using Elasticsearch', :orchestrated, :elasticsearch do + include Runtime::Fixtures + + before do + project_name = 'testing_elasticsearch_indexing' + @project_file_name = 'elasticsearch.rb' + @project_file_content = 'elasticsearch: true' + + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.perform(&:sign_in_using_credentials) + + QA::EE::Resource::Settings::Elasticsearch.fabricate_via_browser_ui! + + @project = Resource::Project.fabricate_via_api! do |project| + project.name = project_name + end + + Resource::Repository::ProjectPush.fabricate! do |push| + push.project = @project + push.file_name = @project_file_name + push.file_content = @project_file_content + end + end + + it 'tests reindexing after push' do + QA::Page::Main::Menu.perform do |menu| + menu.search_for(@project_file_content) + end + + Page::Search::Results.perform do |search| + search.switch_to_code + + expect(search).to have_file_with_content @project_file_name, @project_file_content + end + end + + it 'tests reindexing after webIDE' do + template = { + file_name: 'LICENSE', + name: 'Mozilla Public License 2.0', + api_path: 'licenses', + api_key: 'mpl-2.0' + } + content = fetch_template_from_api(template[:api_path], template[:api_key]) + + Page::Project::Show.perform(&:open_web_ide!) + Page::Project::WebIDE::Edit.perform do |ide| + ide.create_new_file_from_template template[:file_name], template[:name] + ide.commit_changes + end + + Page::Main::Menu.perform(&:go_to_groups) + + QA::Page::Main::Menu.perform do |menu| + menu.search_for content[0..33] + end + + Page::Search::Results.perform do |search| + search.switch_to_code + + expect(search).to have_file_in_project template[:file_name], @project.name + expect(search).to have_file_with_content template[:file_name], content[0..33] + end + end + end + end +end |