Commit c21d3f40 authored by anonym's avatar anonym
Browse files

Merge remote-tracking branch 'kytv/test/10116-make-webm-video-test-more-robust' into stable

Fix-committed: #10116

Conflicts:
	features/step_definitions/pidgin.rb
parents 438f5f01 a3326963
......@@ -639,9 +639,22 @@ When /^I open the address "([^"]*)" in the (.*)$/ do |address, browser|
next if @skip_steps_while_restoring_background
step "I open a new tab in the #{browser}"
info = xul_application_info(browser)
@screen.click(info[:address_bar_image])
sleep 0.5
@screen.type(address + Sikuli::Key.ENTER)
open_address = Proc.new do
@screen.click(info[:address_bar_image])
sleep 0.5
@screen.type(address + Sikuli::Key.ENTER)
end
open_address.call
if browser == "Tor Browser"
recovery_on_failure = Proc.new do
@screen.type(Sikuli::Key.ESC)
@screen.waitVanish('BrowserReloadButton.png', 3)
open_address.call
end
retry_tor(recovery_on_failure) do
@screen.wait('BrowserReloadButton.png', 120)
end
end
end
Then /^the (.*) has no plugins installed$/ do |browser|
......@@ -1061,10 +1074,7 @@ When /^I open a page on the LAN web server in the (.*)$/ do |browser|
end
def force_new_tor_circuit(with_vidalia=nil)
assert(!@new_circuit_tries.nil? && @new_circuit_tries >= 0,
'@new_circuit_tries was not initialized before it was used')
@new_circuit_tries += 1
debug_log("Forcing new Tor circuit... (attempt ##{@new_circuit_tries})")
debug_log("Forcing new Tor circuit...")
if with_vidalia
assert_equal('gnome', @theme, "Vidalia is not available in the #{@theme} theme.")
begin
......@@ -1147,6 +1157,5 @@ end
Then /^I force Tor to use a new circuit( in Vidalia)?$/ do |with_vidalia|
next if @skip_steps_while_restoring_background
@new_circuit_tries = 1 if @new_circuit_tries.nil?
force_new_tor_circuit(with_vidalia)
end
......@@ -288,21 +288,21 @@ end
Then /^Pidgin successfully connects to the "([^"]+)" account$/ do |account|
next if @skip_steps_while_restoring_background
expected_channel_entry = chan_image(account, default_chan(account), 'roster')
@new_circuit_tries = 0
until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
# Sometimes the OFTC welcome notice window pops up over the buddy list one...
@vm.focus_window('Buddy List')
# FIXME This should be modified to use waitAny once #9633 is addressed
recovery_on_failure = Proc.new do
@screen.wait_and_click('PidginReconnect.png', 20)
end
retry_tor(recovery_on_failure) do
begin
@screen.wait(expected_channel_entry, 60)
break
rescue FindFailed
force_new_tor_circuit
@screen.wait_and_click('PidginReconnect.png', 20)
@vm.focus_window('Buddy List')
rescue ExecutionFailedInVM
# Sometimes focusing the window with xdotool will fail with the
# conversation window right on top of it. We'll try to close the
# conversation window. At worst, the test will still fail...
close_pidgin_conversation_window(account)
end
# FIXME This should be modified to use waitAny once #9633 is addressed
@screen.wait(expected_channel_entry, 60)
end
@screen.wait(expected_channel_entry, 10)
end
Then /^the "([^"]*)" account only responds to PING and VERSION CTCP requests$/ do |irc_server|
......
......@@ -12,7 +12,8 @@ def seahorse_wait_helper(img, time = 20)
@screen.wait(img, time)
rescue FindFailed => e
if @screen.exists('SeahorseKeyserverError.png')
raise OpenPGPKeyserverCommunicationError
raise OpenPGPKeyserverCommunicationError.new(
"Could not find 'SeahorseKeyserverError.png'")
else
# Seahorse has been known to segfault during tests
syslog = @vm.file_content('/var/log/syslog')
......@@ -50,18 +51,16 @@ When /^I fetch the "([^"]+)" OpenPGP key using the GnuPG CLI( without any signat
else
importopts = ''
end
@new_circuit_tries = 0
until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
begin
@gnupg_recv_key_res = @vm.execute_successfully(
retry_tor do
@gnupg_recv_key_res = @vm.execute_successfully(
"gpg --batch #{importopts} --recv-key '#{keyid}'",
LIVE_USER)
break
rescue ExecutionFailedInVM
force_new_tor_circuit
if @gnupg_recv_key_res.failure?
raise "Fetching keys with the GnuPG CLI failed with:\n" +
"#{@gnupg_recv_key_res.stdout}\n" +
"#{@gnupg_recv_key_res.stderr}"
end
end
assert(@new_circuit_tries < $config["MAX_NEW_TOR_CIRCUIT_RETRIES"], "Fetching keys with the GnuPG CLI did not succeed after retrying #{@new_circuit_tries} times")
end
When /^the GnuPG fetch is successful$/ do
......@@ -110,29 +109,26 @@ end
Then /^I synchronize keys in Seahorse$/ do
next if @skip_steps_while_restoring_background
@new_circuit_tries = 0
until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
begin
step 'process "seahorse" is running'
@screen.wait_and_click("SeahorseWindow.png", 10)
seahorse_menu_click_helper('SeahorseRemoteMenu.png', 'SeahorseRemoteMenuSync.png', 'seahorse')
seahorse_wait_helper('SeahorseSyncKeys.png')
@screen.type("s", Sikuli::KeyModifier.ALT) # Button: Sync
seahorse_wait_helper('SeahorseSynchronizing.png')
seahorse_wait_helper('SeahorseWindow.png', 5*60)
break
rescue OpenPGPKeyserverCommunicationError
force_new_tor_circuit
@screen.wait_and_click('GnomeCloseButton.png', 20)
if @screen.exists('SeahorseSynchronizing.png')
# Seahorse is likely to segfault if we end up here.
@screen.click('SeahorseSynchronizing.png')
@screen.type(Sikuli::Key.ESC)
end
seahorse_wait_helper('SeahorseWindow.png')
recovery_proc = Proc.new do
@screen.wait_and_click('GnomeCloseButton.png', 20)
if @screen.exists('SeahorseSynchronizing.png')
# Seahorse is likely to segfault if we end up here.
@screen.click('SeahorseSynchronizing.png')
@screen.type(Sikuli::Key.ESC)
end
seahorse_wait_helper('SeahorseWindow.png')
end
retry_tor(recovery_proc) do
step 'process "seahorse" is running'
@screen.wait_and_click("SeahorseWindow.png", 10)
seahorse_menu_click_helper('SeahorseRemoteMenu.png',
'SeahorseRemoteMenuSync.png',
'seahorse')
seahorse_wait_helper('SeahorseSyncKeys.png')
@screen.type("s", Sikuli::KeyModifier.ALT) # Button: Sync
seahorse_wait_helper('SeahorseSynchronizing.png')
seahorse_wait_helper('SeahorseWindow.png', 5*60)
end
assert(@new_circuit_tries < $config["MAX_NEW_TOR_CIRCUIT_RETRIES"], "Syncing keys in Seahorse did not succeed after retrying #{@new_circuit_tries} times")
end
When /^I fetch the "([^"]+)" OpenPGP key using Seahorse( via the Tails OpenPGP Applet)?$/ do |keyid, withgpgapplet|
......@@ -143,35 +139,33 @@ When /^I fetch the "([^"]+)" OpenPGP key using Seahorse( via the Tails OpenPGP A
step "I start Seahorse"
end
step "Seahorse has opened"
@new_circuit_tries = 0
until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
recovery_proc = Proc.new do
@screen.wait_and_click('GnomeCloseButton.png', 20)
@screen.type(Sikuli::Key.ESC)
@screen.type("w", Sikuli::KeyModifier.CTRL)
end
retry_tor(recovery_proc) do
@screen.wait_and_click("SeahorseWindow.png", 10)
seahorse_menu_click_helper('SeahorseRemoteMenu.png',
'SeahorseRemoteMenuFind.png',
'seahorse')
seahorse_wait_helper('SeahorseFindKeysWindow.png', 10)
# Seahorse doesn't seem to support searching for fingerprints
@screen.type(keyid + Sikuli::Key.ENTER)
begin
@screen.wait_and_click("SeahorseWindow.png", 10)
seahorse_menu_click_helper('SeahorseRemoteMenu.png', 'SeahorseRemoteMenuFind.png', 'seahorse')
seahorse_wait_helper('SeahorseFindKeysWindow.png', 10)
# Seahorse doesn't seem to support searching for fingerprints
@screen.type(keyid + Sikuli::Key.ENTER)
begin
seahorse_wait_helper('SeahorseFoundKeyResult.png', 5*60)
rescue FindFailed
# We may end up here if Seahorse appears to be "frozen".
# Sometimes--but not always--if we click another window
# the main Seahorse window will unfreeze, allowing us
# to continue normally.
@screen.click("SeahorseSearch.png")
end
@screen.click("SeahorseKeyResultWindow.png")
@screen.click("SeahorseFoundKeyResult.png")
@screen.click("SeahorseImport.png")
break
rescue OpenPGPKeyserverCommunicationError
force_new_tor_circuit
@screen.wait_and_click('GnomeCloseButton.png', 20)
@screen.type(Sikuli::Key.ESC)
@screen.type("w", Sikuli::KeyModifier.CTRL)
seahorse_wait_helper('SeahorseFoundKeyResult.png', 5*60)
rescue FindFailed
# We may end up here if Seahorse appears to be "frozen".
# Sometimes--but not always--if we click another window
# the main Seahorse window will unfreeze, allowing us
# to continue normally.
@screen.click("SeahorseSearch.png")
end
@screen.click("SeahorseKeyResultWindow.png")
@screen.click("SeahorseFoundKeyResult.png")
@screen.click("SeahorseImport.png")
end
assert(@new_circuit_tries < $config["MAX_NEW_TOR_CIRCUIT_RETRIES"], "Fetching keys in Seahorse did not succeed after retrying #{@new_circuit_tries} times")
end
Then /^Seahorse is configured to use the correct keyserver$/ do
......
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
until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
begin
@vm_execute_res = @vm.execute("whois '#{domain}'", LIVE_USER)
if !@vm_execute_res.success? || @vm_execute_res.stdout['LIMIT EXCEEDED']
raise WhoisLookupFailure
end
break
rescue WhoisLookupFailure
if @vm_execute_res.stderr['Timeout'] || \
@vm_execute_res.stderr['Unable to resolve'] || \
@vm_execute_res.stdout['LIMIT EXCEEDED']
force_new_tor_circuit
end
retry_tor do
@vm_execute_res = @vm.execute("whois '#{domain}'", LIVE_USER)
if @vm_execute_res.failure?
raise "Looking up whois info for #{domain} failed with:\n" +
"#{@vm_execute_res.stdout}\n" +
"#{@vm_execute_res.stderr}"
end
end
assert(@new_circuit_tries < $config["MAX_NEW_TOR_CIRCUIT_RETRIES"],
"Looking up whois info for #{domain} did not succeed after retrying #{@new_circuit_tries} times.\n" +
"The output of the last command contains:\n" +
"#{@vm_execute_res.stdout}\n" + "#{@vm_execute_res.stderr}")
end
When /^I wget "([^"]+)" to stdout(?:| with the '([^']+)' options)$/ do |url, options|
next if @skip_steps_while_restoring_background
arguments = "-O - '#{url}'"
arguments = "#{options} #{arguments}" if options
@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
retry_tor do
@vm_execute_res = @vm.execute("wget #{arguments}", LIVE_USER)
if @vm_execute_res.failure?
raise "wget:ing #{url} with options #{options} failed with:\n" +
"#{@vm_execute_res.stdout}\n" +
"#{@vm_execute_res.stderr}"
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|
......
......@@ -56,6 +56,10 @@ class VMCommand
return @returncode == 0
end
def failure?
return not(success?)
end
def to_s
"Return status: #{@returncode}\n" +
"STDOUT:\n" +
......
......@@ -66,6 +66,40 @@ rescue unique_timeout_exception => e
raise Timeout::Error.new(msg)
end
class TorFailure < StandardError
end
# This will retry the block up to MAX_NEW_TOR_CIRCUIT_RETRIES
# times. The block must raise an exception for a run to be considered
# as a failure. After a failure recovery_proc will be called (if
# given) and the intention with it is to bring us back to the state
# expected by the block, so it can be retries.
def retry_tor(recovery_proc = nil, &block)
max_retries = $config["MAX_NEW_TOR_CIRCUIT_RETRIES"]
retries = 1
loop do
begin
block.call
return
rescue Exception => e
if retries <= max_retries
if $config["DEBUG"]
STDERR.puts "Tor operation failed (Tor circuit try #{retries} of " +
"#{max_retries}) with:\n" +
"#{e.class}: #{e.message}"
end
recovery_proc.call if recovery_proc
force_new_tor_circuit
retries += 1
else
raise TorFailure.new("The operation failed (despite forcing " +
"#{max_retries} new Tor circuits) with\n" +
"#{e.class}: #{e.message}")
end
end
end
end
def wait_until_tor_is_working
try_for(270) { @vm.execute(
'. /usr/local/lib/tails-shell-library/tor.sh; tor_is_working').success? }
......
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