From f48fcdc75c31ba4f03cac5df9b9e71d7b841eea7 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 | 17 +++++++++++++++-- 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, 37 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 26414f57a3..6d2feb2ed1 100755 --- a/README.md +++ b/README.md @@ -132,7 +132,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 375180996f..917c403ffe 100644 --- a/behat.yml +++ b/behat.yml @@ -15,10 +15,23 @@ 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://phantomjs:8910/wd/hub + wd_host: "http://chrome:4444/wd/hub" + browser: chrome + capabilities: + chrome: + switches: + - "--headless" + - "--disable-gpu" + # 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 84e13c760f..5fee0085b1 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 8694ac667a..1d55794806 100644 --- a/ops/deployment/docker-compose.yml +++ b/ops/deployment/docker-compose.yml @@ -209,6 +209,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" @@ -245,7 +246,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