mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
See documentation added to run_tests.sh. This can be configured to target local web browsers or Selenium remote services as detailed in that script. Individual tests can be executed with nosetests directly or groups of tests can share a common test Galaxy spin up when using ./run_tests.sh. If GALAXY_TEST_EXTERNAL=<url> is set - it will be respected and Galaxy will not be spun up (remember the URL needs to be reachable from the Selenium server inside the Docker container). Every test failure writes a current screenshot of Galaxy to database/test_errors. I will be honest that the desire to move toward selenium is based solely on failing to get the Casper tests to pass consistently due to bugs causing segfaults in the underlying tools (probably casperjs or phantomjs?). Over the past year I have tried multiple versions of dependencies, etc... and it never works out for me. Likewise Martin has never been able to get the tests to run consistently under Jenkins. I don't think Python or JavaScript is inherently better, this wasn't based on a personal preference about what kind of test I want to write. Despite this being the primary reason, there are clear benefits to Selenium. It tests the actual web browsers we support, generates screenshots, has better documented and more robust tooling, can scale across clusters. Less clear, but certainly still a benefit of being Python based is that it fits with the rest of the test framework more cleanly than CasperJS. Finally Carl's last words on CasperJS were "Ditch it". The following specific tests were added or replaced: - Implemented tour testing via Selenium (walk the two working stock tours and verify elements avaiable and clicks are valid). This is how I discovered #3206. - Added completely new workflow GUI test (basic creation from URL and in editor). - Replaced broken CasperJS registeration tests (text and expectations now wrong) with a Selenium variant that works against dev. - Replaced broken anonymous history CasperJS tests with working Selenium tests. - Replaced broken upload CasperJS tests with working Selenium tests. - Replaced history options CasperJS tests with Selenium tests. - Replaced login CasperJS tests with Selenium tests. - Replaced history-share-tests.js with test_history_options.py - Replaced history-panel-tests.js with test_history_panel.py - Replaced a big part of hda-state-tests.js with test_history_dataset_state.py I'm confident these utilities represent a sharable and higher-level abstraction around functional testing of Galaxy that can be used outside of Galaxy's testing framework. So a subset of the functional test stuff is in a separate module with minimal dependencies that I intend to make stand alone and pip installable like galaxy-lib. This module consists of: - Sizzle stuff in its own package. This code allows Selenium to reason with jQuery selectors instead of vanilla CSS selectors. - Functionality for creating a Selenium driver and virtual display. - The ``HasDriver`` mixin - this provides higher level navigation utilities not specifically tied to Galaxy. - A package with abstractions for navigating Galaxy. This provides a higher-level interfactor for things such as logging in and out, registering a user, navigating menus, fetching Galaxy style tooltips and error messages, and walking Galaxy tours. In order to demonstrate this new module is useful outside of Galaxy tests - I've included a CLI package to ease building argparse utilities around these abstractions and implemented a simple demonstration script that walks a Galaxy tour and dumps screenshots of Galaxy at each step to a folder. This is more of a demonstration of the utilities than an actual polished end user tool - though it might be helpful in linting and debugging tours. In the future I hope to extend this scripting to implement - Periodic deployment testing to ensure things like Jupyter work in production. - A best practice recipe for Galaxy QA testing by deployers. - An utility to generate dozens of screenshots of various aspects of Galaxy so we can quickly visually inspect ever part of the GUI before big releases. xref https://github.com/galaxyproject/starforge/pull/115 xref #1419
134 lines
3.9 KiB
Python
134 lines
3.9 KiB
Python
#!/usr/bin/env python
|
|
"""Test driver for many Galaxy Python functional tests.
|
|
|
|
Launch this script by running ``run_tests.sh`` from GALAXY_ROOT, see
|
|
that script for a list of options.
|
|
"""
|
|
|
|
import os
|
|
import os.path
|
|
import sys
|
|
|
|
galaxy_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
|
|
sys.path[1:1] = [ os.path.join( galaxy_root, "lib" ), os.path.join( galaxy_root, "test" ) ]
|
|
|
|
from base import driver_util
|
|
log = driver_util.build_logger()
|
|
|
|
from base.api_util import get_master_api_key, get_user_api_key
|
|
|
|
|
|
class MigratedToolsGalaxyTestDriver(driver_util.GalaxyTestDriver):
|
|
"""Instantiate a Galaxy-style nose TestDriver for testing migrated Galaxy tools."""
|
|
|
|
testing_shed_tools = True
|
|
|
|
def build_tests(self):
|
|
"""Build migrated tool test methods."""
|
|
self.setup_shed_tools(
|
|
testing_migrated_tools=True,
|
|
)
|
|
self.build_tool_tests()
|
|
|
|
|
|
class InstalledToolsGalaxyTestDriver(driver_util.GalaxyTestDriver):
|
|
"""Galaxy-style nose TestDriver for testing installed Galaxy tools."""
|
|
|
|
testing_shed_tools = True
|
|
|
|
def build_tests(self):
|
|
"""Build installed tool test methods."""
|
|
self.setup_shed_tools(
|
|
testing_installed_tools=True,
|
|
)
|
|
self.build_tool_tests()
|
|
|
|
|
|
class DefaultGalaxyTestDriver(driver_util.GalaxyTestDriver):
|
|
"""Default Galaxy-style nose test driver.
|
|
|
|
Just populate non-shed tool tests and run tests. Works
|
|
for tool tests, regular twill tests, and API testing.
|
|
"""
|
|
|
|
def build_tests(self):
|
|
"""Build framework tool test methods."""
|
|
self.build_tool_tests()
|
|
|
|
|
|
class SeleniumGalaxyTestDriver(driver_util.GalaxyTestDriver):
|
|
"""Galaxy-style nose TestDriver for selenium framework testing."""
|
|
|
|
framework_tool_and_types = True
|
|
|
|
@driver_util.classproperty
|
|
def default_web_host(cls):
|
|
from selenium_tests.framework import default_web_host_for_selenium_tests
|
|
return default_web_host_for_selenium_tests()
|
|
|
|
|
|
class FrameworkToolsGalaxyTestDriver(DefaultGalaxyTestDriver):
|
|
"""Galaxy-style nose TestDriver for testing framework Galaxy tools."""
|
|
|
|
framework_tool_and_types = True
|
|
|
|
|
|
class DataManagersGalaxyTestDriver(driver_util.GalaxyTestDriver):
|
|
"""Galaxy-style nose TestDriver for testing framework Galaxy tools."""
|
|
|
|
def build_tests(self):
|
|
"""Build data manager test methods."""
|
|
import functional.test_data_managers
|
|
functional.test_data_managers.data_managers = self.app.data_managers
|
|
functional.test_data_managers.build_tests(
|
|
tmp_dir=self.galaxy_test_tmp_dir,
|
|
testing_shed_tools=self.testing_shed_tools,
|
|
master_api_key=get_master_api_key(),
|
|
user_api_key=get_user_api_key(),
|
|
)
|
|
|
|
|
|
class WorkflowGalaxyTestDriver(driver_util.GalaxyTestDriver):
|
|
"""Galaxy-style nose TestDriver for testing a Galaxy workflow."""
|
|
|
|
def build_tests(self):
|
|
"""Setup WorkflowTestCase for test execution."""
|
|
import functional.workflow
|
|
functional.workflow.WorkflowTestCase.master_api_key = get_master_api_key()
|
|
functional.workflow.WorkflowTestCase.user_api_key = get_user_api_key()
|
|
|
|
|
|
TEST_DRIVERS = {
|
|
'-migrated': MigratedToolsGalaxyTestDriver,
|
|
'-installed': InstalledToolsGalaxyTestDriver,
|
|
'-framework': FrameworkToolsGalaxyTestDriver,
|
|
'-data_managers': DataManagersGalaxyTestDriver,
|
|
'-workflow': WorkflowGalaxyTestDriver,
|
|
'-selenium': SeleniumGalaxyTestDriver,
|
|
}
|
|
|
|
|
|
def find_test_driver():
|
|
"""Look at command-line args and find the correct Galaxy test driver."""
|
|
test_driver = DefaultGalaxyTestDriver
|
|
|
|
for key in TEST_DRIVERS.keys():
|
|
if _check_arg(key):
|
|
test_driver = TEST_DRIVERS[key]
|
|
|
|
return test_driver
|
|
|
|
|
|
def _check_arg( name ):
|
|
try:
|
|
index = sys.argv.index( name )
|
|
del sys.argv[ index ]
|
|
ret_val = True
|
|
except ValueError:
|
|
ret_val = False
|
|
return ret_val
|
|
|
|
|
|
if __name__ == "__main__":
|
|
driver_util.drive_test(find_test_driver())
|