mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Fix transiently failing Selenium test of tool form re-running.
Reworks addition of staleness checkers introduced in #3780.
This commit is contained in:
@@ -9,7 +9,7 @@ import random
|
||||
import string
|
||||
import time
|
||||
|
||||
from functools import wraps
|
||||
from functools import partial, wraps
|
||||
|
||||
import requests
|
||||
import yaml
|
||||
@@ -28,23 +28,27 @@ class NullTourCallback(object):
|
||||
pass
|
||||
|
||||
|
||||
def retry_call_during_transitions(f, attempts=5, sleep=.1):
|
||||
previous_attempts = 0
|
||||
while True:
|
||||
try:
|
||||
return f()
|
||||
except Exception as e:
|
||||
if previous_attempts > attempts:
|
||||
raise
|
||||
|
||||
if not exception_indicates_stale_element(e):
|
||||
raise
|
||||
|
||||
time.sleep(sleep)
|
||||
previous_attempts += 1
|
||||
|
||||
|
||||
def retry_during_transitions(f, attempts=5, sleep=.1):
|
||||
|
||||
@wraps(f)
|
||||
def _retry(*args, **kwds):
|
||||
previous_attempts = 0
|
||||
while True:
|
||||
try:
|
||||
return f(*args, **kwds)
|
||||
except Exception as e:
|
||||
if previous_attempts > attempts:
|
||||
raise
|
||||
|
||||
if not exception_indicates_stale_element(e):
|
||||
raise
|
||||
|
||||
time.sleep(sleep)
|
||||
previous_attempts += 1
|
||||
retry_call_during_transitions(partial(f, *args, **kwds), attempts=attempts, sleep=sleep)
|
||||
|
||||
return _retry
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ from .framework import (
|
||||
UsesHistoryItemAssertions,
|
||||
)
|
||||
|
||||
from galaxy_selenium.navigates_galaxy import retry_call_during_transitions
|
||||
|
||||
|
||||
class ToolFormTestCase(SeleniumTestCase, UsesHistoryItemAssertions):
|
||||
|
||||
@@ -65,11 +67,16 @@ class ToolFormTestCase(SeleniumTestCase, UsesHistoryItemAssertions):
|
||||
self.history_panel_wait_for_hid_ok(1)
|
||||
self.hda_click_primary_action_button(1, "rerun")
|
||||
|
||||
inttest_div_element = self.tool_parameter_div("inttest")
|
||||
inttest_input_element = inttest_div_element.find_element_by_css_selector("input")
|
||||
recorded_val = inttest_input_element.get_attribute("value")
|
||||
# Assert form re-rendered with correct value in textbox.
|
||||
assert recorded_val == "42", recorded_val
|
||||
def check_recorded_val():
|
||||
inttest_div_element = self.tool_parameter_div("inttest")
|
||||
inttest_input_element = inttest_div_element.find_element_by_css_selector("input")
|
||||
recorded_val = inttest_input_element.get_attribute("value")
|
||||
# Assert form re-rendered with correct value in textbox.
|
||||
assert recorded_val == "42", recorded_val
|
||||
|
||||
# These form entries seem to be replaced/updated occasionally
|
||||
# causing stale elements.
|
||||
retry_call_during_transitions(check_recorded_val)
|
||||
self.tool_execute()
|
||||
|
||||
self.history_panel_wait_for_hid_ok(2)
|
||||
|
||||
Reference in New Issue
Block a user