Skip to content

Commit

Permalink
Fix random acceptance tests issues by replacing phantomjs with chrome
Browse files Browse the repository at this point in the history
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] Behat/MinkExtension#345
[3] https://www.theregister.co.uk/2017/11/29/google_dev_network/
  • Loading branch information
Rija Menage authored and rija committed Aug 22, 2020
1 parent c03f013 commit debf4ee
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
17 changes: 15 additions & 2 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions features/admins-attach-author-to-user.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions features/bootstrap/GigadbWebsiteContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "([^"]*)"$/
*/
Expand Down
2 changes: 1 addition & 1 deletion features/dataset-admin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions features/merge-authors-49.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion ops/deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,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"

Expand Down Expand Up @@ -244,7 +245,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
Expand Down

0 comments on commit debf4ee

Please sign in to comment.