Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Create behat.yml file with individual suites for DKAN and Custom Tests (
Browse files Browse the repository at this point in the history
#3)

* Refactor behat configurations to use suites.

REF CIVIC-4257

 Changes to be committed:
  new file:   ../config/tests/behat.custom.yml
  new file:   ../config/tests/features/bootstrap/CustomContext.php
  new file:   ../config/tests/features/custom.feature
  modified:   ../dkan/test/behat.yml
  modified:   behat.circleci.yml
  new file:   behat.data_starter.yml
  modified:   behat.docker.yml
  deleted:    behat.yml
  deleted:    features
  new file:   features/bootstrap/custom
  new file:   features/bootstrap/dkan
  renamed:    ../config/tests/features/general.feature -> features/general.feature
  renamed:    ../config/tests/features/resources.feature -> features/resources.feature

* Use one script for all tests.

REF CIVIC-4257

Now we've added some suite configurations for the different types of tests we
can pass a suite parameter to run our tests using the same script.

Changes to be committed:
	modified:   ../../circle.yml
	modified:   .scripts/behat-parse-params.rb
	modified:   .scripts/circle-behat.rb
	new file:   tests/behat-parse-params.rb

* Update selenium google drivers.

REF https://jira.govdelivery.com/browse/CIVIC-4312

Fixes bug.

* Fix clamav tests.

* Run fix-permissions after deploy.

REF CIVIC-4312

Some recline tests are failing because public://general directory is not
accessible.

* Disable clamav completely.

REF CIVIC-4212.

* Add assets folder, enable clamav tests.

* Fix artifacts folder and run one failing scenario.

* Consolidate all files in one place.

MinkExtesion is not suite aware so only knows the location of one files folder
per profile. I could have done a PR to fix this in MinkExtension but instead
I've decided that the easiest course of action is to use a convention of
files/<test_suite>  location and symlink back to appropriate sections as needed.

TODO: maybe as a good deed I should consider doing a PR to make MinkExtension
suite aware.

* Cleaup cirle.yml

* Update references to data_starter.

* Use default file path.

Since now by convention all folders are tests files folder are the same we can
reference the in the same way.

* Fix test.
  • Loading branch information
dkinzer authored and acouch committed Nov 4, 2016
1 parent 0eff0c7 commit bb57e22
Show file tree
Hide file tree
Showing 28 changed files with 185 additions and 162 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
/docroot/sites/default/**/files
/docroot/sites/default/**/private

tests/assets/*
dkan/test/assets/*


# Ignore the dkan test composer folder.
/docroot/profiles/dkan/test/vendor
Expand Down
37 changes: 7 additions & 30 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
## Customize the test machine
machine:

#timezone:
# America/New_York # Set the timezone

# Version of ruby to use
php:
version: '5.6.22'

# Override /etc/hosts
#hosts:
#circlehost: 127.0.0.1
#dev.mycompany.com: 127.0.0.1

# Add some environment variables
environment:
PATH: $PATH:$HOME/.config/composer/vendor/bin
# For xvfb / selenium setup (not sure why)
#DISPLAY: ':99.0'
DATABASE_URL: mysql://ubuntu:@127.0.0.1:3306/circle_test
# Timeouts issues happen when selenium tries to spawn a new chrome
# instance. I've nail that down to this selenium issue
# https://github.com/SeleniumHQ/docker-selenium/issues/87
DBUS_SESSION_BUS_ADDRESS: /dev/null
## Customize checkout
## Note: Only post is supported.
checkout:
Expand All @@ -27,19 +20,8 @@ checkout:

## Customize dependencies
dependencies:

# we automatically cache and restore many dependencies between
# builds. If you need to, you can add custom paths to cache:
#cache_directories:
# - "custom_1" # relative to the build directory
# - "~/custom_2" # relative to the user's home directory
cache_directories:
#- "dkan/test/vendor"
#- "~/.composer"
- "~/.drush"
# Disable caching sql install backups for now.
#- "backups"
#- "dkan/test/sites/default"
pre:
- rm /opt/circleci/php/$(phpenv global)/etc/conf.d/xdebug.ini
- echo "memory_limit = 256M" > $PHPENV_ROOT/versions/$(phpenv global)/etc/conf.d/memory.ini
Expand All @@ -58,10 +40,6 @@ dependencies:
- 'ahoy drush --yes runserver :8888':
background: true

# Setup display for selenium
#- sh -e /etc/init.d/xvfb start
#- sleep 3

- wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
- java -jar selenium-server-standalone-2.53.1.jar -p 4444 :
background: true
Expand All @@ -72,10 +50,9 @@ dependencies:
## Customize test commands
test:
override:
- ruby dkan/.ahoy/.scripts/circle-behat.rb docroot/profiles/dkan/test/features --tags='~@customizable&&~@fixme&&~@testBug':
- BEHAT_FOLDER=$HOME/$CIRCLE_PROJECT_REPONAME/tests ruby dkan/.ahoy/.scripts/circle-behat.rb dkan/test/features tests/features config/tests/features --tags='~@customizable&&~@fixme&&~@testBug':
timeout: 1200
parallel: true

post:
- echo $CIRCLE_ARTIFACTS; cp -av dkan/test/assets $CIRCLE_ARTIFACTS:
- echo $CIRCLE_ARTIFACTS; cp -av tests/assets $CIRCLE_ARTIFACTS:
parallel: true
12 changes: 12 additions & 0 deletions config/tests/behat.custom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# behat.yml
default:
suites:
custom:
paths:
- %paths.base%/../config/tests/features
contexts:
- CustomContext
- FeatureContext #Temporary overrides only!
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MessageContext
22 changes: 22 additions & 0 deletions config/tests/features/bootstrap/CustomContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;

/**
* Defines application features from the specific context.
*/
class CustomContext extends RawDrupalContext implements SnippetAcceptingContext {

/**
* Initializes context.
*
* Every scenario gets its own context instance.
* You can also pass arbitrary arguments to the
* context constructor through behat.yml.
*/
public function __construct() {
}

}
13 changes: 13 additions & 0 deletions config/tests/features/custom.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Feature: Custom Example


##################################################################
# ALL ( ANONYMOUS + AUTHENTICATED )
##################################################################

@api
Scenario: See custom about page
Given I am on the homepage
When I click "Datasets"
Then I should see "Content Types"
20 changes: 20 additions & 0 deletions dkan/.ahoy/.scripts/behat-parse-params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,23 @@ def behat_parse_params args
{:files => files, :params => params}
end

def behat_parse_suite file
default = "dkan_starter"

return default if file.nil? or file.empty?

key = file.split('/').reverse[3]

return default if key.nil?

types = {
:dkan => "dkan",
:config => "custom",
}

if types[key.to_sym]
types[key.to_sym]
else
default
end
end
5 changes: 3 additions & 2 deletions dkan/.ahoy/.scripts/circle-behat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@

files[CIRCLE_NODE_INDEX].each_index do |i|
file = Pathname(files[CIRCLE_NODE_INDEX][i]).realpath.to_s
puts "RUNNING: ahoy dkan test #{file} --format=pretty --out=std --format=junit --out='#{CIRCLE_ARTIFACTS}/junit' #{params} --colors"
suite = behat_parse_suite(file)
puts "RUNNING: ahoy dkan test #{file} --suite=#{suite} --format=pretty --out=std --format=junit --out='#{CIRCLE_ARTIFACTS}/junit' #{params} --colors"
IO.popen(
"ahoy dkan test #{file} --format=pretty --out=std --format=junit --out='#{CIRCLE_ARTIFACTS}/junit' #{params} --colors"
"ahoy dkan test #{file} --suite=#{suite} --format=pretty --out=std --format=junit --out='#{CIRCLE_ARTIFACTS}/junit' #{params} --colors"
) do |io|
while line = io.gets
print line
Expand Down
39 changes: 39 additions & 0 deletions dkan/.ahoy/tests/behat-parse-params.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require "minitest/autorun"
require "./.scripts/behat-parse-params.rb"

class TestBehatParseParams < MiniTest::Unit::TestCase

def test_behat_parse_suite
# return dkan for dkan features
expected = "dkan"
actual = behat_parse_suite "/var/www/dkan/test/features/my.feature"
assert_equal expected, actual

expected = "dkan"
actual = behat_parse_suite "dkan/test/features/my.feature"
assert_equal expected, actual

# returns custom for custom features.
expected = "custom"
actual = behat_parse_suite "/var/www/config/tests/features/my.feature"
assert_equal expected, actual

expected = "custom"
actual = behat_parse_suite "config/tests/features/my.feature"
assert_equal expected, actual

# returns dkan_starter for dkan_starter features or by default
expected = "dkan_starter"
actual = behat_parse_suite "/var/www/tests/features/my.feature"
assert_equal expected, actual

expected = "dkan_starter"
actual = behat_parse_suite "tests/features/my.feature"
assert_equal expected, actual

expected = "dkan_starter"
actual = behat_parse_suite nil
assert_equal expected, actual
end

end
2 changes: 1 addition & 1 deletion dkan/test/behat.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default:
suites:
default:
dkan:
contexts:
- FeatureContext #Temporary overrides only!
- Drupal\DrupalExtension\Context\MinkContext
Expand Down
6 changes: 3 additions & 3 deletions dkan/test/features/widgets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Feature: Widgets
Scenario: Adds "New File Widget" block to home page using panels ipe editor
When I click on the text " Add file"
And I wait for "Configure new Add file"
And I attach the drupal file "actionplan.pdf" to "files[field_basic_file_file_und_0]"
And I attach the drupal file "dkan/actionplan.pdf" to "files[field_basic_file_file_und_0]"
And I press "Finish"
And I wait and press "Save"
Then I should see "actionplan.pdf"
Expand All @@ -45,7 +45,7 @@ Feature: Widgets
When I click on the text " Add image"
And I wait for "Configure new Add image"
And I fill in "field_basic_image_caption[und][0][value]" with "dkan logo image test"
And I attach the drupal file "dkan_logo.png" to "files[field_basic_image_image_und_0]"
And I attach the drupal file "dkan/dkan_logo.png" to "files[field_basic_image_image_und_0]"
And I press "Finish"
And I wait and press "Save"
Then I should see "dkan logo image test"
Expand Down Expand Up @@ -105,7 +105,7 @@ Feature: Widgets
And I wait for "Configure new Add spotlight"
And I fill in "field_basic_spotlight_items[und][0][title]" with "First spot"
And I fill in "field_basic_spotlight_items[und][0][link]" with "http://demo.getdkan.com"
And I attach the drupal file "dkan_logo.png" to "files[field_basic_spotlight_items_und_0_fid]"
And I attach the drupal file "dkan/dkan_logo.png" to "files[field_basic_spotlight_items_und_0_fid]"
And I press "Finish"
And I wait and press "Save"
And I wait for "First spot"
Expand Down
File renamed without changes.
File renamed without changes
1 change: 1 addition & 0 deletions tests/assets/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
7 changes: 6 additions & 1 deletion tests/behat.circleci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
imports:
- behat.yml
# dkan is the default profile
- ../dkan/test/behat.yml
# data_stater will override dkan
- behat.dkan_starter.yml
# custom has the last say
- ../config/tests/behat.custom.yml

default:
extensions:
Expand Down
43 changes: 43 additions & 0 deletions tests/behat.dkan_starter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# this default param refers to a profile level configuration
default:
# autoloads can only be handled in behat using PS-0 at the profile level
# otherwise use composer.json and PS-3
autoload:
# PS-0 forces us to use a symlink inside of the profile level bootstrap
- %paths.base%/features/bootstrap/custom
- %paths.base%/features/bootstrap/dkan
- %paths.base%/features/bootstrap
suites:
# this default parram is for a suite level configuration
dkan_starter:
paths:
- %paths.base%/features
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\MarkupContext
- Drupal\DKANExtension\Context\DKANContext
- Drupal\DKANExtension\Context\MailContext
- Drupal\DKANExtension\Context\PageContext
- Drupal\DKANExtension\Context\GroupContext
- Drupal\DKANExtension\Context\WorkflowContext
- Drupal\DKANExtension\Context\DatasetContext
- Drupal\DKANExtension\Context\DataDashboardContext
- Drupal\DKANExtension\Context\ResourceContext
- Drupal\DKANExtension\Context\DatastoreContext
- Drupal\DKANExtension\Context\SearchAPIContext:
search_forms:
default:
form_css: '#dkan-sitewide-dataset-search-form'
form_field: 'edit-search'
form_button: 'edit-submit'
results_css: '.view-dkan-datasets'
result_item_css: '.views-row'
- Devinci\DevinciExtension\Context\JavascriptContext:
maximum_wait: 30
dkan:
# handle dkan path here to maintain backwards compatibility
paths:
- %paths.base%/../dkan/test/features
7 changes: 6 additions & 1 deletion tests/behat.docker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
imports:
- behat.yml
# dkan is the default profile
- ../dkan/test/behat.yml
# data_stater will override dkan
- behat.dkan_starter.yml
# custom has the last say
- ../config/tests/behat.custom.yml

default:
extensions:
Expand Down
Loading

0 comments on commit bb57e22

Please sign in to comment.