diff options
author | intrigeri <intrigeri@boum.org> | 2015-06-29 07:40:39 +0000 |
---|---|---|
committer | intrigeri <intrigeri@boum.org> | 2015-06-29 07:40:39 +0000 |
commit | d9800fc7cab8d7ad1c8223b6357326755c44aca3 (patch) | |
tree | 7078f797886221bd751868fed5fbd2a0ea9a2b5e | |
parent | d7b9c0016aab7bc79a9ac0661cc7bb536955cc7a (diff) | |
parent | 6f3f2e41a4497a4253f319ca8ece67fdb2853b8d (diff) |
Merge remote-tracking branch 'kytv/test/9517-retry-oftc' into stable
Fix-committed: #9517
-rw-r--r-- | features/config/defaults.yml | 1 | ||||
-rw-r--r-- | features/images/PidginConfirmationIcon.png | bin | 0 -> 2983 bytes | |||
-rw-r--r-- | features/images/PidginReconnect.png | bin | 0 -> 852 bytes | |||
-rw-r--r-- | features/images/VidaliaMenuNewIdentity.png | bin | 0 -> 1615 bytes | |||
-rw-r--r-- | features/images/VidaliaNewIdentityNotification.png | bin | 0 -> 2059 bytes | |||
-rw-r--r-- | features/images/VidaliaSystrayReady.png | bin | 0 -> 593 bytes | |||
-rw-r--r-- | features/step_definitions/common_steps.rb | 32 | ||||
-rw-r--r-- | features/step_definitions/pidgin.rb | 54 | ||||
-rw-r--r-- | wiki/src/contribute/release_process/test/usage.mdwn | 5 |
9 files changed, 87 insertions, 5 deletions
diff --git a/features/config/defaults.yml b/features/config/defaults.yml index 2b7a3e5..fde749c 100644 --- a/features/config/defaults.yml +++ b/features/config/defaults.yml @@ -1,6 +1,7 @@ DEBUG: false PAUSE_ON_FAIL: false SIKULI_RETRY_FINDFAILED: false +MAX_NEW_TOR_CIRCUIT_RETRIES: 5 TMPDIR: "/tmp/TailsToaster" Unsafe_SSH_private_key: | diff --git a/features/images/PidginConfirmationIcon.png b/features/images/PidginConfirmationIcon.png Binary files differnew file mode 100644 index 0000000..cadb4d6 --- /dev/null +++ b/features/images/PidginConfirmationIcon.png diff --git a/features/images/PidginReconnect.png b/features/images/PidginReconnect.png Binary files differnew file mode 100644 index 0000000..c007e33 --- /dev/null +++ b/features/images/PidginReconnect.png diff --git a/features/images/VidaliaMenuNewIdentity.png b/features/images/VidaliaMenuNewIdentity.png Binary files differnew file mode 100644 index 0000000..30b253b --- /dev/null +++ b/features/images/VidaliaMenuNewIdentity.png diff --git a/features/images/VidaliaNewIdentityNotification.png b/features/images/VidaliaNewIdentityNotification.png Binary files differnew file mode 100644 index 0000000..6b43da6 --- /dev/null +++ b/features/images/VidaliaNewIdentityNotification.png diff --git a/features/images/VidaliaSystrayReady.png b/features/images/VidaliaSystrayReady.png Binary files differnew file mode 100644 index 0000000..73d251f --- /dev/null +++ b/features/images/VidaliaSystrayReady.png diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb index 06077ff..173c20c 100644 --- a/features/step_definitions/common_steps.rb +++ b/features/step_definitions/common_steps.rb @@ -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 diff --git a/features/step_definitions/pidgin.rb b/features/step_definitions/pidgin.rb index 77d0815..4500f1c 100644 --- a/features/step_definitions/pidgin.rb +++ b/features/step_definitions/pidgin.rb @@ -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 diff --git a/wiki/src/contribute/release_process/test/usage.mdwn b/wiki/src/contribute/release_process/test/usage.mdwn index eafa59b..82dbeea 100644 --- a/wiki/src/contribute/release_process/test/usage.mdwn +++ b/wiki/src/contribute/release_process/test/usage.mdwn @@ -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 |