summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 18:08:45 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 18:08:45 +0000
commit26a50872e9da9509c52c70f74dc21698fec906db (patch)
treeb1bd36bd72e701e346ef880fc7a905f6186525e7 /qa
parentb3a736ed88a1db0391cd9881e70b987bab7d89d1 (diff)
downloadgitlab-ce-26a50872e9da9509c52c70f74dc21698fec906db.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb38
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_remove_ci_variable_spec.rb59
-rw-r--r--qa/qa/support/repeater.rb4
-rw-r--r--qa/qa/support/wait_for_requests.rb2
-rw-r--r--qa/qa/support/waiter.rb25
-rw-r--r--qa/spec/support/repeater_spec.rb30
-rw-r--r--qa/spec/support/waiter_spec.rb5
7 files changed, 111 insertions, 52 deletions
diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb
deleted file mode 100644
index c813484347e..00000000000
--- a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-module QA
- context 'Verify' do
- describe 'CI variable support' do
- it 'user adds a CI variable', :smoke do
- Flow::Login.sign_in
-
- project = Resource::Project.fabricate_via_api! do |project|
- project.name = 'project-with-ci-variables'
- project.description = 'project with CI variables'
- end
-
- Resource::CiVariable.fabricate_via_api! do |resource|
- resource.project = project
- resource.key = 'VARIABLE_KEY'
- resource.value = 'some_CI_variable'
- resource.masked = false
- end
-
- project.visit!
-
- Page::Project::Menu.perform(&:go_to_ci_cd_settings)
-
- Page::Project::Settings::CICD.perform do |settings|
- settings.expand_ci_variables do |page|
- expect(page).to have_field(with: 'VARIABLE_KEY')
- expect(page).not_to have_field(with: 'some_CI_variable')
-
- page.reveal_variables
-
- expect(page).to have_field(with: 'some_CI_variable')
- end
- end
- end
- end
- end
-end
diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_remove_ci_variable_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_remove_ci_variable_spec.rb
new file mode 100644
index 00000000000..9dad5ad8fb5
--- /dev/null
+++ b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_remove_ci_variable_spec.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+module QA
+ context 'Verify' do
+ describe 'Add or Remove CI variable via UI', :smoke do
+ let!(:project) do
+ Resource::Project.fabricate_via_api! do |project|
+ project.name = 'project-with-ci-variables'
+ project.description = 'project with CI variables'
+ end
+ end
+
+ before do
+ Flow::Login.sign_in
+ add_ci_variable
+ open_ci_cd_settings
+ end
+
+ it 'user adds a CI variable' do
+ Page::Project::Settings::CICD.perform do |settings|
+ settings.expand_ci_variables do |page|
+ expect(page).to have_field(with: 'VARIABLE_KEY')
+ expect(page).not_to have_field(with: 'some_CI_variable')
+
+ page.reveal_variables
+
+ expect(page).to have_field(with: 'some_CI_variable')
+ end
+ end
+ end
+
+ it 'user removes a CI variable' do
+ Page::Project::Settings::CICD.perform do |settings|
+ settings.expand_ci_variables do |page|
+ page.remove_variable
+
+ expect(page).not_to have_field(with: 'VARIABLE_KEY')
+ end
+ end
+ end
+
+ private
+
+ def add_ci_variable
+ Resource::CiVariable.fabricate_via_browser_ui! do |ci_variable|
+ ci_variable.project = project
+ ci_variable.key = 'VARIABLE_KEY'
+ ci_variable.value = 'some_CI_variable'
+ ci_variable.masked = false
+ end
+ end
+
+ def open_ci_cd_settings
+ project.visit!
+ Page::Project::Menu.perform(&:go_to_ci_cd_settings)
+ end
+ end
+ end
+end
diff --git a/qa/qa/support/repeater.rb b/qa/qa/support/repeater.rb
index 53d72f2f410..14771243beb 100644
--- a/qa/qa/support/repeater.rb
+++ b/qa/qa/support/repeater.rb
@@ -10,13 +10,13 @@ module QA
RetriesExceededError = Class.new(RuntimeError)
WaitExceededError = Class.new(RuntimeError)
- def repeat_until(max_attempts: nil, max_duration: nil, reload_page: nil, sleep_interval: 0, raise_on_failure: true, retry_on_exception: false)
+ def repeat_until(max_attempts: nil, max_duration: nil, reload_page: nil, sleep_interval: 0, raise_on_failure: true, retry_on_exception: false, log: true)
attempts = 0
start = Time.now
begin
while remaining_attempts?(attempts, max_attempts) && remaining_time?(start, max_duration)
- QA::Runtime::Logger.debug("Attempt number #{attempts + 1}") if max_attempts
+ QA::Runtime::Logger.debug("Attempt number #{attempts + 1}") if max_attempts && log
result = yield
return result if result
diff --git a/qa/qa/support/wait_for_requests.rb b/qa/qa/support/wait_for_requests.rb
index 5d5ba70a0c2..c58882a11ea 100644
--- a/qa/qa/support/wait_for_requests.rb
+++ b/qa/qa/support/wait_for_requests.rb
@@ -6,7 +6,7 @@ module QA
module_function
def wait_for_requests
- Waiter.wait_until do
+ Waiter.wait_until(log: false) do
finished_all_ajax_requests? && finished_all_axios_requests?
end
end
diff --git a/qa/qa/support/waiter.rb b/qa/qa/support/waiter.rb
index 18ccee80074..9ccc0d9484f 100644
--- a/qa/qa/support/waiter.rb
+++ b/qa/qa/support/waiter.rb
@@ -7,15 +7,17 @@ module QA
module_function
- def wait_until(max_duration: singleton_class::DEFAULT_MAX_WAIT_TIME, reload_page: nil, sleep_interval: 0.1, raise_on_failure: true, retry_on_exception: false)
- QA::Runtime::Logger.debug(
- <<~MSG.tr("\n", ' ')
- with wait_until: max_duration: #{max_duration};
- reload_page: #{reload_page};
- sleep_interval: #{sleep_interval};
- raise_on_failure: #{raise_on_failure}
- MSG
- )
+ def wait_until(max_duration: singleton_class::DEFAULT_MAX_WAIT_TIME, reload_page: nil, sleep_interval: 0.1, raise_on_failure: true, retry_on_exception: false, log: true)
+ if log
+ QA::Runtime::Logger.debug(
+ <<~MSG.tr("\n", ' ')
+ with wait_until: max_duration: #{max_duration};
+ reload_page: #{reload_page};
+ sleep_interval: #{sleep_interval};
+ raise_on_failure: #{raise_on_failure}
+ MSG
+ )
+ end
result = nil
self.repeat_until(
@@ -23,11 +25,12 @@ module QA
reload_page: reload_page,
sleep_interval: sleep_interval,
raise_on_failure: raise_on_failure,
- retry_on_exception: retry_on_exception
+ retry_on_exception: retry_on_exception,
+ log: log
) do
result = yield
end
- QA::Runtime::Logger.debug("ended wait_until")
+ QA::Runtime::Logger.debug("ended wait_until") if log
result
end
diff --git a/qa/spec/support/repeater_spec.rb b/qa/spec/support/repeater_spec.rb
index 20dca6608f6..b5d5058ef49 100644
--- a/qa/spec/support/repeater_spec.rb
+++ b/qa/spec/support/repeater_spec.rb
@@ -381,5 +381,35 @@ describe QA::Support::Repeater do
end
end
end
+
+ it 'logs attempts' do
+ attempted = false
+
+ expect do
+ subject.repeat_until(max_attempts: 1) do
+ unless attempted
+ attempted = true
+ break false
+ end
+
+ true
+ end
+ end.to output(/Attempt number/).to_stdout_from_any_process
+ end
+
+ it 'allows logging to be silenced' do
+ attempted = false
+
+ expect do
+ subject.repeat_until(max_attempts: 1, log: false) do
+ unless attempted
+ attempted = true
+ break false
+ end
+
+ true
+ end
+ end.not_to output.to_stdout_from_any_process
+ end
end
end
diff --git a/qa/spec/support/waiter_spec.rb b/qa/spec/support/waiter_spec.rb
index 40abf0d72a2..35f1e01289a 100644
--- a/qa/spec/support/waiter_spec.rb
+++ b/qa/spec/support/waiter_spec.rb
@@ -34,6 +34,11 @@ describe QA::Support::Waiter do
end
end
+ it 'allows logs to be silenced' do
+ expect { subject.wait_until(max_duration: 0, raise_on_failure: false, log: false) { false } }
+ .not_to output.to_stdout_from_any_process
+ end
+
it 'sets max_duration to 60 by default' do
expect(subject).to receive(:repeat_until).with(hash_including(max_duration: 60))