summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2015-07-16 10:14:57 +0000
committerintrigeri <intrigeri@boum.org>2015-07-16 10:14:57 +0000
commit5be4ca90036865f7fc3040c02dda558fb2779557 (patch)
tree5465605e82712e6f92b3629409e7d9d4d9a5834a
parente2b338cc6c224d49929edfda17184d82a4b48900 (diff)
parent4c3a3564799aa6b118e7981c7164656991f0040f (diff)
Merge remote-tracking branch 'kytv/test/9715-wget' into devel
Fix-committed: #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|