Skip to content

Commit

Permalink
Merge pull request #887 from MetadataConsulting/feature/chrome-for-fu…
Browse files Browse the repository at this point in the history
…nctional-tests

Feature/chrome for functional tests
  • Loading branch information
musketyr authored Nov 18, 2016
2 parents eb40cb1 + 96e7d9b commit 3d43f9d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 71 deletions.
20 changes: 14 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: groovy
sudo: false
services:
- mysql
sudo: required
dist: trusty
cache:
directories:
- node_modules
Expand All @@ -15,15 +14,24 @@ addons:
artifacts:
paths:
- $HOME/reports
apt:
packages:
- mysql-server-5.6
- mysql-client-core-5.6
- mysql-client-5.6
env:
- TEST_SUITE=functional
- TEST_SUITE=unit_and_integration
jdk:
- oraclejdk8
before_script:
- "export DISPLAY=:99.0"
before_install:
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1980x1080x16"
- export CHROME_BIN=/usr/bin/google-chrome
- export DISPLAY=:99.0
- sudo apt-get update
- sudo apt-get install -y libappindicator1 fonts-liberation
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome*.deb
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1980x1080x16
script:
- ./catalogue test
after_script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ grails.project.dependency.resolution = {
runtime "org.apache.httpcomponents:httpclient:4.3.1"

// Selenium WebDriver, for use in Geb
def webDriverVersion = System.getenv('WEB_DRIVER_VERSION') ?: "2.53.0"
def webDriverVersion = System.getenv('WEB_DRIVER_VERSION') ?: "3.0.1"

// Testing modules
test "org.gebish:geb-spock:$gebVersion"
Expand All @@ -144,6 +144,8 @@ grails.project.dependency.resolution = {
test "org.seleniumhq.selenium:selenium-chrome-driver:${webDriverVersion}"
test "org.seleniumhq.selenium:selenium-remote-driver:${webDriverVersion}"
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"

test 'io.github.bonigarcia:webdrivermanager:1.5.0'
}

plugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ environments {
driverClassName = "com.mysql.jdbc.Driver"
dialect='org.hibernate.dialect.MySQL5InnoDBDialect'
url = "jdbc:mysql://localhost:3306/metadata?autoReconnect=true&useUnicode=yes"
username = 'travis'
username = 'root'
dbCreate = "update"
properties {
maxActive = -1
Expand Down
71 changes: 9 additions & 62 deletions ModelCatalogueCorePluginTestApp/test/functional/GebConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,81 +4,28 @@
*/


import org.openqa.selenium.firefox.FirefoxDriver
import io.github.bonigarcia.wdm.ChromeDriverManager
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.logging.LogType
import org.openqa.selenium.logging.LoggingPreferences
import org.openqa.selenium.remote.CapabilityType
import org.openqa.selenium.remote.DesiredCapabilities
import org.openqa.selenium.remote.RemoteWebDriver
import org.openqa.selenium.chrome.ChromeOptions

import java.util.logging.Level
ChromeOptions options = new ChromeOptions()
options.addArguments("test-type")
options.addArguments("--disable-extensions")

reportsDir = new File("target/geb-reports")
reportOnTestFailureOnly = false
baseUrl = 'http://localhost:8080/'
cacheDriver = false

ChromeDriverManager.getInstance().setup()

driver = {
new FirefoxDriver()
new ChromeDriver(options)
}

waiting {
timeout = 15
retryInterval = 0.6
}
// Default to wraping `at SomePage` declarations in `waitFor` closures
atCheckWaiting = true

// Download the driver and set it up automatically

private void downloadDriver(File file, String path) {
if (!file.exists()) {
def ant = new AntBuilder()
ant.get(src: path, dest: 'driver.zip')
ant.unzip(src: 'driver.zip', dest: file.parent)
ant.delete(file: 'driver.zip')
ant.chmod(file: file, perm: '700')
}
}

environments {


// run as "grails -Dgeb.env=chrome test-app"
// See: http://code.google.com/p/selenium/wiki/ChromeDriver
chrome {
def chromeDriver = new File('test/drivers/chrome/chromedriver')
downloadDriver(chromeDriver, "http://chromedriver.storage.googleapis.com/2.22/chromedriver_mac32.zip")
System.setProperty('webdriver.chrome.driver', chromeDriver.absolutePath)
driver = {
DesiredCapabilities caps = DesiredCapabilities.chrome();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
logPrefs.enable(LogType.CLIENT, Level.ALL);
logPrefs.enable(LogType.DRIVER, Level.ALL);
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
new ChromeDriver(caps);
}
}

sauce {
waiting {
timeout = 15
retryInterval = 1
}

String username = System.getenv("SAUCE_USER_NAME");
String apiKey = System.getenv("SAUCE_API_KEY");
if(username == null || apiKey == null){
System.err.println("Sauce OnDemand credentials not set.");
}

DesiredCapabilities caps = DesiredCapabilities.chrome();
caps.setCapability("name", "ModelCatalogueCoreTestApp");
caps.setCapability("platform", "Linux");
driver = {
new RemoteWebDriver(new URL("http://${username}:${apiKey}@ondemand.saucelabs.com:80/wd/hub"), caps)
}
}
}
atCheckWaiting = true
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package org.modelcatalogue.core.dataarchitect
import org.modelcatalogue.core.AbstractIntegrationSpec
import org.modelcatalogue.core.DataModel
import org.modelcatalogue.core.DataClass
import spock.lang.Requires

@Requires({ !System.getenv('TRAVIS') })
class UmljServiceISpec extends AbstractIntegrationSpec {

def umljService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import org.modelcatalogue.core.DataClass
import org.modelcatalogue.builder.api.CatalogueBuilder
import org.modelcatalogue.crf.model.CaseReportForm
import org.springframework.validation.Errors
import spock.lang.Ignore
import spock.lang.Requires

class ModelToFormExporterServiceSpec extends AbstractIntegrationSpec {

Expand Down Expand Up @@ -159,6 +161,7 @@ class ModelToFormExporterServiceSpec extends AbstractIntegrationSpec {
gridGroup.repeatMax == TEST_GRID_REPEAT_MAX as Integer
}

@Requires({ !System.getenv('TRAVIS') })
def "various item types"(){
given:
DataClass formModel = build {
Expand Down
2 changes: 1 addition & 1 deletion bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export ES_VERSION=2.3.5
if [[ "$TRAVIS" != "" ]] ; then
if [ "$TEST_SUITE" = "functional" ] || [ "$TEST_SUITE" = "" ] ; then
echo "preparing metadata database"
mysql -u root -e "create database metadata;grant all privileges on metadata.* to 'travis'@'localhost'"
mysql -u root -e "create database metadata;grant all privileges on metadata.* to 'root'@'localhost'"
echo "running elasticsearch"
wget -qO- "http://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/$ES_VERSION/elasticsearch-$ES_VERSION.tar.gz" | tar xvz
"./elasticsearch-$ES_VERSION/bin/elasticsearch" -d --default.path.conf=conf/test/esconfig
Expand Down

0 comments on commit 3d43f9d

Please sign in to comment.