From bd02339d90f8de3c8a61116a4becaa0cbdb9c53d Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 23 Apr 2020 17:50:28 -0400 Subject: [PATCH] Implement integration Selenium tests. --- .github/workflows/integration_selenium.yaml | 45 +++++++++++++++++++++ lib/galaxy_test/selenium/framework.py | 10 +++-- run_tests.sh | 8 +++- test/integration_selenium/__init__.py | 0 test/integration_selenium/framework.py | 23 +++++++++++ 5 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/integration_selenium.yaml create mode 100644 test/integration_selenium/__init__.py create mode 100644 test/integration_selenium/framework.py diff --git a/.github/workflows/integration_selenium.yaml b/.github/workflows/integration_selenium.yaml new file mode 100644 index 00000000000..b57342c4912 --- /dev/null +++ b/.github/workflows/integration_selenium.yaml @@ -0,0 +1,45 @@ +name: Integration Selenium +on: [push, pull_request] +env: + GALAXY_TEST_DBURI: 'postgres://postgres:postgres@localhost:5432/galaxy?client_encoding=utf8' + GALAXY_TEST_SELENIUM_REMOTE: '1' + GALAXY_TEST_SELENIUM_REMOTE_PORT: "4444" + GALAXY_SKIP_CLIENT_BUILD: '0' +jobs: + test: + name: Test + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: [3.7] + services: + postgres: + image: postgres:11 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + - 5432:5432 + selenium: + image: selenium/standalone-chrome:3.141.59 + ports: + - 4444:4444 + steps: + - name: Prune unused docker image, volumes and containers + run: docker system prune -a -f + - uses: actions/checkout@v2 + with: + path: 'galaxy root' + - uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Cache pip dir + uses: actions/cache@v1 + id: pip-cache + with: + path: ~/.cache/pip + key: pip-cache-${{ matrix.python-version }}-${{ hashFiles('galaxy root/requirements.txt') }} + - name: Run tests + run: './run_tests.sh -integration test/integration_selenium' + working-directory: 'galaxy root' diff --git a/lib/galaxy_test/selenium/framework.py b/lib/galaxy_test/selenium/framework.py index 30c1b96cc58..1668f3aa729 100644 --- a/lib/galaxy_test/selenium/framework.py +++ b/lib/galaxy_test/selenium/framework.py @@ -200,13 +200,17 @@ class TestWithSeleniumMixin(NavigatesGalaxy, UsesApiTestCaseMixin): # GALAXY_TEST_SELENIUM_ADMIN_USER_PASSWORD requires_admin = False - def setup_selenium(self): + def _target_url_from_selenium(self): # Deal with the case when Galaxy has a different URL when being accessed by Selenium # then when being accessed by local API calls. if GALAXY_TEST_EXTERNAL_FROM_SELENIUM is not None: - self.target_url_from_selenium = GALAXY_TEST_EXTERNAL_FROM_SELENIUM + target_url_from_selenium = GALAXY_TEST_EXTERNAL_FROM_SELENIUM else: - self.target_url_from_selenium = self.url + target_url_from_selenium = self.url + return target_url_from_selenium + + def setup_selenium(self): + self.target_url_from_selenium = self._target_url_from_selenium() self.snapshots = [] self.setup_driver_and_session() if self.requires_admin and GALAXY_TEST_SELENIUM_ADMIN_USER_EMAIL == DEFAULT_ADMIN_USER: diff --git a/run_tests.sh b/run_tests.sh index 1a1336346a7..888b1418067 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -276,7 +276,13 @@ report_file="run_functional_tests.html" coverage_arg="" xunit_report_file="" structured_data_report_file="" -skip_client_build="--skip-client-build" +SKIP_CLIENT_BUILD=${GALAXY_SKIP_CLIENT_BUILD:-1} +if [ "$SKIP_CLIENT_BUILD" = "1" ]; +then + skip_client_build="--skip-client-build" +else + skip_client_build="" +fi if [ "$1" = "--dockerize" ]; then diff --git a/test/integration_selenium/__init__.py b/test/integration_selenium/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/integration_selenium/framework.py b/test/integration_selenium/framework.py new file mode 100644 index 00000000000..66250fd6b37 --- /dev/null +++ b/test/integration_selenium/framework.py @@ -0,0 +1,23 @@ +from galaxy_test.driver import integration_util +from galaxy_test.selenium import ( + framework +) + +selenium_test = framework.selenium_test + + +class SeleniumIntegrationTestCase(integration_util.IntegrationTestCase, framework.TestWithSeleniumMixin): + + def setUp(self): + super(SeleniumIntegrationTestCase, self).setUp() + self.setup_selenium() + + def tearDown(self): + self.tear_down_selenium() + super(SeleniumIntegrationTestCase, self).tearDown() + + +__all__ = ( + 'selenium_test', + 'SeleniumIntegrationTestCase', +)