Commit d9800fc7 authored by intrigeri's avatar intrigeri
Browse files

Merge remote-tracking branch 'kytv/test/9517-retry-oftc' into stable

Fix-committed: #9517
parents d7b9c001 6f3f2e41
DEBUG: false
PAUSE_ON_FAIL: false
SIKULI_RETRY_FINDFAILED: false
MAX_NEW_TOR_CIRCUIT_RETRIES: 5
TMPDIR: "/tmp/TailsToaster"
Unsafe_SSH_private_key: |
......
......@@ -1004,3 +1004,35 @@ When /^I accept to import the key with Seahorse$/ do
next if @skip_steps_while_restoring_background
@screen.wait_and_click("TorBrowserOkButton.png", 10)
end
Then /^I force Tor to use a new circuit( in Vidalia)?$/ do |with_vidalia|
if with_vidalia
assert_equal('gnome', @theme, "Vidalia is not available in the #{@theme} theme.")
begin
step 'process "vidalia" is running'
rescue Test::Unit::AssertionFailedError
STDERR.puts "Vidalia was not running. Attempting to start Vidalia..." if $config["DEBUG"]
@vm.spawn('restart-vidalia')
step 'process "vidalia" is running within 15 seconds'
end
# Sometimes Sikuli gets confused and recognizes the yellow-colored vidalia systray
# icon as the green one. This has been seen when Vidalia needed to be
# restarted in the above 'begin' block.
#
# try_for is used here for that reason, otherwise this step may fail
# because sikuli presumaturely right-clicked the Vidalia icon and the 'New
# Identity' option isn't clickable yet..
try_for(3 * 60) do
# Let's be *sure* that vidalia is still running. I'd hate to spend up to
# three minutes waiting for an icon that isn't there because Vidalia, for
# whatever reason, is no longer running...
step 'process "vidalia" is running'
@screen.wait_and_right_click('VidaliaSystrayReady.png', 10)
@screen.wait_and_click('VidaliaMenuNewIdentity.png', 10)
end
@screen.wait('VidaliaNewIdentityNotification.png', 20)
@screen.waitVanish('VidaliaNewIdentityNotification.png', 60)
else
@vm.execute_successfully('. /usr/local/lib/tails-shell-library/tor.sh; tor_control_send "signal NEWNYM"')
end
end
......@@ -18,6 +18,19 @@ EOF
return account
end
def focus_pidgin_irc_conversation_window(account)
account = account.sub(/^irc\./, '')
@vm.focus_window(".*#{Regexp.escape(account)}$")
end
def close_pidgin_conversation_window(account)
focus_pidgin_irc_conversation_window(account)
@screen.type(Sikuli::Key.F4, Sikuli::KeyModifier.ALT)
if @screen.exists('PidginConfirmationIcon.png')
@screen.click('GnomeCloseButton.png')
end
end
When /^I create my XMPP account$/ do
next if @skip_steps_while_restoring_background
account = xmpp_account("Tails_account")
......@@ -283,9 +296,30 @@ 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')
# Sometimes the OFTC welcome notice window pops up over the buddy list one...
@vm.focus_window('Buddy List')
@screen.wait(expected_channel_entry, 60)
tries = 0
until tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
# Sometimes the OFTC welcome notice window pops up over the buddy list one...
begin
@vm.focus_window('Buddy List')
rescue Test::Unit::AssertionFailedError
# 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
begin
@screen.wait(expected_channel_entry, 60)
break
rescue FindFailed
tries += 1
STDERR.puts "Forcing new Tor circuit... (attempt ##{tries})" if $config["DEBUG"]
step "I force Tor to use a new circuit"
@screen.wait_and_click('PidginReconnect.png', 20)
end
end
@screen.wait(expected_channel_entry, 10)
end
Then /^the "([^"]*)" account only responds to PING and VERSION CTCP requests$/ do |irc_server|
......@@ -308,8 +342,18 @@ Then /^I can join the "([^"]+)" channel on "([^"]+)"$/ do |channel, account|
next if @skip_steps_while_restoring_background
@screen.doubleClick( chan_image(account, channel, 'roster'))
@screen.hide_cursor
@vm.focus_window(".*\.oftc\.net$")
@screen.wait_and_click(chan_image(account, channel, 'conversation_tab'), 10)
focus_pidgin_irc_conversation_window(account)
try_for(60) do
begin
@screen.wait_and_click(chan_image(account, channel, 'conversation_tab'), 5)
rescue FindFailed => e
# If the channel tab can't be found it could be because there were
# multiple connection attempts and the channel tab we want is off the
# screen. We'll try closing tabs until the one we want can be found.
@screen.type("w", Sikuli::KeyModifier.CTRL)
raise e
end
end
@screen.hide_cursor
@screen.wait( chan_image(account, channel, 'welcome'), 10)
end
......
......@@ -75,6 +75,11 @@ by the local configuration file:
* `DEBUG`: Boolean value. If set to `true`, various debugging info
will be printed. Defaults to `false`.
* `MAX_NEW_TOR_CIRCUIT_RETRIES`: Integer. Upon failure, some test steps may be
run again after requesting that connections are made using new Tor circuits. This
configuration variable limits how many times forcing a circuit will be
attempted. Defaults to `5`.
* `PAUSE_ON_FAIL`: Boolean value. If set to `true`, the test suite run
is suspended on failure until ENTER is pressed. This is useful for
investigating the state of the VM guest to see exactly why a test
......
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