summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-24 18:07:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-24 18:07:55 +0000
commit603c7d4cac5e28bc1c75e50c23ed2cbe56f1aafc (patch)
tree907f5b8ee1b6f5aad396e95e3327a08400b9e8ea /qa
parent120f4aaedc8fe830a3f572491d240d8ee6addefb (diff)
downloadgitlab-ce-603c7d4cac5e28bc1c75e50c23ed2cbe56f1aafc.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r--qa/qa.rb1
-rw-r--r--qa/qa/runtime/project.rb35
-rw-r--r--qa/qa/runtime/search.rb16
3 files changed, 52 insertions, 0 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index 2cf6e02c2aa..b26d926436b 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -39,6 +39,7 @@ module QA
autoload :MailHog, 'qa/runtime/mail_hog'
autoload :IPAddress, 'qa/runtime/ip_address'
autoload :Search, 'qa/runtime/search'
+ autoload :Project, 'qa/runtime/project'
autoload :ApplicationSettings, 'qa/runtime/application_settings'
module API
diff --git a/qa/qa/runtime/project.rb b/qa/qa/runtime/project.rb
new file mode 100644
index 00000000000..89edfee1fbe
--- /dev/null
+++ b/qa/qa/runtime/project.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+module QA
+ module Runtime
+ module Project
+ extend self
+ extend Support::Api
+
+ def create_project(project_name, api_client, project_description = 'default')
+ project = Resource::Project.fabricate_via_api! do |project|
+ project.add_name_uuid = false
+ project.name = project_name
+ project.description = project_description
+ project.api_client = api_client
+ project.visibility = 'public'
+ end
+ project
+ end
+
+ def push_file_to_project(target_project, file_name, file_content)
+ Resource::Repository::ProjectPush.fabricate! do |push|
+ push.project = target_project
+ push.file_name = file_name
+ push.file_content = file_content
+ end
+ end
+
+ def set_project_visibility(api_client, project_id, visibility)
+ request = Runtime::API::Request.new(api_client, "/projects/#{project_id}")
+ response = put request.url, visibility: visibility
+ response.code.equal?(QA::Support::Api::HTTP_STATUS_OK)
+ end
+ end
+ end
+end
diff --git a/qa/qa/runtime/search.rb b/qa/qa/runtime/search.rb
index 29a71b2815c..f7f87d96e68 100644
--- a/qa/qa/runtime/search.rb
+++ b/qa/qa/runtime/search.rb
@@ -42,6 +42,22 @@ module QA
end
end
+ def elasticsearch_on?(api_client)
+ elasticsearch_state_request = Runtime::API::Request.new(api_client, '/application/settings')
+ response = get elasticsearch_state_request.url
+
+ parse_body(response)[:elasticsearch_search] && parse_body(response)[:elasticsearch_indexing]
+ end
+
+ def disable_elasticsearch(api_client)
+ disable_elasticsearch_request = Runtime::API::Request.new(api_client, '/application/settings')
+ put disable_elasticsearch_request.url, elasticsearch_search: false, elasticsearch_indexing: false
+ end
+
+ def create_search_request(api_client, scope, search_term)
+ Runtime::API::Request.new(api_client, '/search', scope: scope, search: search_term)
+ end
+
def find_code(file_name, search_term)
find_target_in_scope('blobs', search_term) do |record|
record[:filename] == file_name && record[:data].include?(search_term)