From 1e3af3e8058504c20a96c0671aac9749d1ce0abe Mon Sep 17 00:00:00 2001 From: Rija Menage Date: Fri, 3 Jan 2020 13:17:27 +0800 Subject: [PATCH] Fix random acceptance tests issues by replacing phantomjs with chrome phantomjs is increasingly flaky, so we switch to another headless browser. Unfortunately SeleniumWebDriver support for Firefox has non-workaroundable or no-upcoming-fixes-soon problems [1] , only Chrome up to version 74 works [2], but it's a better place to be. By switching to Chrome, we have to alter (actually improve) a couple of background scenarios. Also *.dev domains are restricted in Chrome [3] so switching the internal domain to *.test. [1] https://stackoverflow.com/questions/46913377/php-codeception-not-so-quick-start-phpunit-framework-exception-undefined-inde [2] https://github.com/Behat/MinkExtension/issues/345 [3] https://www.theregister.co.uk/2017/11/29/google_dev_network/ --- README.md | 2 +- behat.yml | 9 ++++++++- features/admins-attach-author-to-user.feature | 3 +-- features/bootstrap/GigadbWebsiteContext.php | 16 ++++++++++++++++ features/dataset-admin.feature | 2 +- features/merge-authors-49.feature | 3 +-- ops/deployment/docker-compose.yml | 3 ++- 7 files changed, 30 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 468b8b7664..167da5e40a 100755 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ $ docker-compose build test ``` $ ./tests/unit_runner # run all the unit tests after ensuring test DB migrations are up-to-date $ ./tests/functional_runner # run all the functional tests after ensuring DB migrations are up-to-date -$ docker-compose up -d phantomjs # start a WebKit-based headless web browser +$ docker-compose up -d chrome # start a headless web browser $ ./tests/acceptance_runner local # run all the acceptance tests (see important note below) $ ./tests/coverage_runner # run test coverage, print report and submit to coveralls.io ``` diff --git a/behat.yml b/behat.yml index d4c14a6228..173f0b8873 100644 --- a/behat.yml +++ b/behat.yml @@ -15,8 +15,11 @@ default: - Behat\MinkExtension\Context\MinkContext extensions: Behat\MinkExtension: - base_url: "http://gigadb.dev/" + browser_name: chrome + base_url: "http://gigadb.test/" goutte: ~ + # selenium2: + # wd_host: http://phantomjs:8910/wd/hub selenium2: wd_host: "http://chrome:4444/wd/hub" browser: chrome @@ -26,6 +29,10 @@ default: - "--headless" - "--disable-gpu" - "--window-size=1024,768" + # marionette: true + # extra_capabilities: + # chromeOptions: + # w3c: false local: suites: diff --git a/features/admins-attach-author-to-user.feature b/features/admins-attach-author-to-user.feature index c463694393..ab836e5d84 100644 --- a/features/admins-attach-author-to-user.feature +++ b/features/admins-attach-author-to-user.feature @@ -7,8 +7,7 @@ Feature: a curator can fill in user id in an author record Background: Given Gigadb web site is loaded with "gigadb_testdata.pgdmp" data And default admin user exists - When I go to "/dataset/100002" - Then I should see "Genomic data from Adelie penguin (Pygoscelis adeliae)" + And dataset "100002" exists @ok @admin-author-form-add-user Scenario: populate user identity field when creating an author diff --git a/features/bootstrap/GigadbWebsiteContext.php b/features/bootstrap/GigadbWebsiteContext.php index 677a50aec7..064d167339 100644 --- a/features/bootstrap/GigadbWebsiteContext.php +++ b/features/bootstrap/GigadbWebsiteContext.php @@ -221,6 +221,22 @@ public function gigadbWebSiteIsLoadedWithData($arg1) } + + /** + * @Given dataset :arg1 exists + */ + public function datasetExists($arg1) + { + $sql = 'select identifier from dataset where identifier = $1'; + $dbconn = pg_connect("host=database dbname=gigadb user=gigadb password=vagrant port=5432") or die('Could not connect: ' . pg_last_error()); + $resultRes = pg_query_params($dbconn, $sql, [$arg1]); + $result = pg_fetch_array($resultRes, NULL, PGSQL_ASSOC); + PHPUnit_Framework_Assert::assertNotNull($result); + PHPUnit_Framework_Assert::assertEquals($arg1, $result['identifier']); + pg_free_result($resultRes); + pg_close($dbconn); + } + /** * @Given /^I take a screenshot named "([^"]*)"$/ */ diff --git a/features/dataset-admin.feature b/features/dataset-admin.feature index c21c6baa05..deace658fd 100644 --- a/features/dataset-admin.feature +++ b/features/dataset-admin.feature @@ -76,7 +76,7 @@ Scenario: Keywords Scenario: redirect Given I sign in as an admin And I am on "/adminDataset/update/id/210" - When I fill in "urltoredirect" with "http://gigadb.dev/dataset/100002/token/banasdfsaf74hsfds" + When I fill in "urltoredirect" with "http://gigadb.test/dataset/100002/token/banasdfsaf74hsfds" And I press "Save" And I go to "/dataset/100002/token/banasdfsaf74hsfds" Then the url should be "/dataset/100002/token/banasdfsaf74hsfds" diff --git a/features/merge-authors-49.feature b/features/merge-authors-49.feature index 93925b150f..786db461b6 100644 --- a/features/merge-authors-49.feature +++ b/features/merge-authors-49.feature @@ -7,8 +7,7 @@ Feature: Merging duplicate authors Background: Given Gigadb web site is loaded with "gigadb_testdata.pgdmp" data And default admin user exists - When I go to "/dataset/100002" - Then I should see "Genomic data from Adelie penguin (Pygoscelis adeliae)" + And dataset "100002" exists @ok Scenario: On author edit form, there is a button to start the merging with another author diff --git a/ops/deployment/docker-compose.yml b/ops/deployment/docker-compose.yml index e0890d2be3..cc1975c3ed 100644 --- a/ops/deployment/docker-compose.yml +++ b/ops/deployment/docker-compose.yml @@ -211,6 +211,7 @@ services: - db-tier extra_hosts: - "gigadb.dev:172.16.238.10" + - "gigadb.test:172.16.238.10" - "fuw-admin-api:172.16.238.10" command: bash -c "./tests/all_and_coverage" @@ -269,7 +270,7 @@ services: - "gigadb.test:172.16.238.10" chrome: - image: selenium/standalone-chrome-debug + image: selenium/standalone-chrome:3.141.59-oxygen # latest version with Chrome 74 shm_size: '1gb' # to avoid a known issue ports: # - "5900:5900" #for VNC access