summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkytv <killyourtv@i2pmail.org>2015-07-09 13:56:16 +0000
committerkytv <killyourtv@i2pmail.org>2015-07-13 15:59:30 +0000
commit4c3a3564799aa6b118e7981c7164656991f0040f (patch)
treec4c2489c011be389269e76bb5ab6ab9542738dda
parentcacd5a4c737829fa2a3793bc305deab5ab82943a (diff)
Retry wget in the test suite on transient failure
Will-fix: #9715
-rw-r--r--features/step_definitions/torified_misc.rb24
1 files changed, 21 insertions, 3 deletions
diff --git a/features/step_definitions/torified_misc.rb b/features/step_definitions/torified_misc.rb
index bd4cd0b..eeca163 100644
--- a/features/step_definitions/torified_misc.rb
+++ b/features/step_definitions/torified_misc.rb
@@ -1,6 +1,9 @@
class WhoisLookupFailure < StandardError
end
+class WgetFailure < StandardError
+end
+
When /^I query the whois directory service for "([^"]+)"$/ do |domain|
next if @skip_steps_while_restoring_background
@new_circuit_tries = 0
@@ -29,9 +32,24 @@ When /^I wget "([^"]+)" to stdout(?:| with the '([^']+)' options)$/ do |url, opt
next if @skip_steps_while_restoring_background
arguments = "-O - '#{url}'"
arguments = "#{options} #{arguments}" if options
- @vm_execute_res = @vm.execute(
- "wget #{arguments}",
- LIVE_USER)
+
+ @new_circuit_tries = 0
+ until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
+ begin
+ @vm_execute_res = @vm.execute("wget #{arguments}", LIVE_USER)
+ raise WgetFailure unless @vm_execute_res.success?
+ break
+ rescue WgetFailure
+ if @vm_execute_res.stderr['Timeout'] || @vm_execute_res.stderr['Unable to resolve']
+ force_new_tor_circuit
+ end
+ end
+ end
+ assert(@new_circuit_tries < $config["MAX_NEW_TOR_CIRCUIT_RETRIES"],
+ "Fetching from #{url} with options #{options} did not succeed after retrying #{@new_circuit_tries} times.\n" +
+ "The output contains:\n" +
+ "#{@vm_execute_res.stdout}\n" +
+ "#{@vm_execute_res.stderr}")
end
Then /^the (wget|whois) command is successful$/ do |command|