Commit ea05925d authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'new-loop-runner' into 'master'

Create loop_runner module to run test repeatedly

See merge request gitlab-org/gitlab!18546
parents a3688fcc 7a3b0090
...@@ -419,6 +419,7 @@ module QA ...@@ -419,6 +419,7 @@ module QA
autoload :Config, 'qa/specs/config' autoload :Config, 'qa/specs/config'
autoload :Runner, 'qa/specs/runner' autoload :Runner, 'qa/specs/runner'
autoload :ParallelRunner, 'qa/specs/parallel_runner' autoload :ParallelRunner, 'qa/specs/parallel_runner'
autoload :LoopRunner, 'qa/specs/loop_runner'
module Helpers module Helpers
autoload :Quarantine, 'qa/specs/helpers/quarantine' autoload :Quarantine, 'qa/specs/helpers/quarantine'
......
...@@ -261,6 +261,10 @@ module QA ...@@ -261,6 +261,10 @@ module QA
ENV['QA_RUNTIME_SCENARIO_ATTRIBUTES'] ENV['QA_RUNTIME_SCENARIO_ATTRIBUTES']
end end
def gitlab_qa_loop_runner_minutes
ENV.fetch('GITLAB_QA_LOOP_RUNNER_MINUTES', 1).to_i
end
private private
def remote_grid_credentials def remote_grid_credentials
......
...@@ -8,6 +8,7 @@ module QA ...@@ -8,6 +8,7 @@ module QA
attribute :gitlab_address, '--address URL', 'Address of the instance to test' attribute :gitlab_address, '--address URL', 'Address of the instance to test'
attribute :enable_feature, '--enable-feature FEATURE_FLAG', 'Enable a feature before running tests' attribute :enable_feature, '--enable-feature FEATURE_FLAG', 'Enable a feature before running tests'
attribute :parallel, '--parallel', 'Execute tests in parallel' attribute :parallel, '--parallel', 'Execute tests in parallel'
attribute :loop, '--loop', 'Execute test repeatedly'
end end
end end
end end
# frozen_string_literal: true
module QA
module Specs
module LoopRunner
module_function
def run(args)
start = Time.now
loop_duration = 60 * QA::Runtime::Env.gitlab_qa_loop_runner_minutes
while Time.now - start < loop_duration
RSpec::Core::Runner.run(args.flatten, $stderr, $stdout).tap do |status|
abort if status.nonzero?
end
RSpec.clear_examples
end
end
end
end
end
...@@ -63,6 +63,8 @@ module QA ...@@ -63,6 +63,8 @@ module QA
if Runtime::Scenario.attributes[:parallel] if Runtime::Scenario.attributes[:parallel]
ParallelRunner.run(args.flatten) ParallelRunner.run(args.flatten)
elsif Runtime::Scenario.attributes[:loop]
LoopRunner.run(args.flatten)
else else
RSpec::Core::Runner.run(args.flatten, $stderr, $stdout).tap do |status| RSpec::Core::Runner.run(args.flatten, $stderr, $stdout).tap do |status|
abort if status.nonzero? abort if status.nonzero?
......
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