diff --git a/run-tests.sh b/run-tests.sh index efdbc6ade6..495977dd8f 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -19,7 +19,6 @@ GALAXY_PORT=48889 GALAXY_URL=http://localhost:$GALAXY_PORT GALAXY_INVALID_URL=http://localhost:48890 GALAXY_INVALID_URL2=http://localhost:48891 -CHROME_DRIVER=$SCRIPT_DIR/src/main/webapp/chromedriver SELENIUM_DOCKER_NAME=irida-selenium SELENIUM_DOCKER_TAG=latest SELENIUM_URL=http://localhost:4444/wd/hub @@ -126,28 +125,15 @@ test_rest() { test_ui() { SELENIUM_OPTS="" - if [ "$SELENIUM_DOCKER" = false ]; - then - if [ -z ${CHROMEWEBDRIVER} ] + if [ "$SELENIUM_DOCKER" = true ]; then - # use default CHROME_DRIVER if CHROMEWEBDRIVER env var is not set - SELENIUM_OPTS="-Dwebdriver.chrome.driver=$CHROME_DRIVER" - else - if [ -d $CHROMEWEBDRIVER ] && [ -f "$CHROMEWEBDRIVER/chromedriver" ] - then - SELENIUM_OPTS="-Dwebdriver.chrome.driver=$CHROMEWEBDRIVER/chromedriver" - else - SELENIUM_OPTS="-Dwebdriver.chrome.driver=$CHROMEWEBDRIVER" - fi - fi - else # create the $TMP_DIRECTORY/irida folder before docker runs so that root doesn't create it mkdir -p $TMP_DIRECTORY/irida # reuse selenium docker image if it exists docker start $SELENIUM_DOCKER_NAME || docker run -d -p 4444:4444 --name $SELENIUM_DOCKER_NAME -v $PWD:$PWD -v $TMP_DIRECTORY/irida:$TMP_DIRECTORY/irida -v /dev/shm:/dev/shm selenium/standalone-chrome:$SELENIUM_DOCKER_TAG SELENIUM_OPTS="-Dwebdriver.selenium_url=$SELENIUM_URL -Dserver.port=33333 -Dserver.base.url=http://$HOSTNAME:33333/irida -Djava.io.tmpdir=$TMP_DIRECTORY/irida" fi - ./gradlew clean check uiITest $SELENIUM_OPTS -Dirida.it.nosandbox=true -Dirida.it.headless=$HEADLESS -Dspring.datasource.url=$JDBC_URL -Dfile.processing.decompress=true -Dirida.it.rootdirectory=$TMP_DIRECTORY -Dspring.datasource.dbcp2.max-wait=$DB_MAX_WAIT_MILLIS $@ + ./gradlew clean uiITest $SELENIUM_OPTS -Dirida.it.nosandbox=true -Dirida.it.headless=$HEADLESS -Dspring.datasource.url=$JDBC_URL -Dfile.processing.decompress=true -Dirida.it.rootdirectory=$TMP_DIRECTORY -Dspring.datasource.dbcp2.max-wait=$DB_MAX_WAIT_MILLIS $@ exit_code=$? if [[ "$DO_KILL_DOCKER" = true && "$SELENIUM_DOCKER" = true ]]; then docker rm -f -v $SELENIUM_DOCKER_NAME; fi return $exit_code @@ -169,7 +155,7 @@ test_galaxy_internal() { task=$1 shift docker run -d -p $GALAXY_PORT:80 --name $GALAXY_DOCKER_NAME -v $TMP_DIRECTORY:$TMP_DIRECTORY -v $SCRIPT_DIR:$SCRIPT_DIR $GALAXY_DOCKER && \ - ./gradlew clean check $task -Dspring.datasource.url=$JDBC_URL -Dfile.processing.decompress=true -Dirida.it.rootdirectory=$TMP_DIRECTORY -Dtest.galaxy.url=$GALAXY_URL -Dtest.galaxy.invalid.url=$GALAXY_INVALID_URL -Dtest.galaxy.invalid.url2=$GALAXY_INVALID_URL2 -Dspring.datasource.dbcp2.max-wait=$DB_MAX_WAIT_MILLIS $@ + ./gradlew clean $task -Dspring.datasource.url=$JDBC_URL -Dfile.processing.decompress=true -Dirida.it.rootdirectory=$TMP_DIRECTORY -Dtest.galaxy.url=$GALAXY_URL -Dtest.galaxy.invalid.url=$GALAXY_INVALID_URL -Dtest.galaxy.invalid.url2=$GALAXY_INVALID_URL2 -Dspring.datasource.dbcp2.max-wait=$DB_MAX_WAIT_MILLIS $@ exit_code=$? if [ "$DO_KILL_DOCKER" = true ]; then docker rm -f -v $GALAXY_DOCKER_NAME; fi return $exit_code diff --git a/src/test/java/ca/corefacility/bioinformatics/irida/ria/integration/AbstractIridaUIITChromeDriver.java b/src/test/java/ca/corefacility/bioinformatics/irida/ria/integration/AbstractIridaUIITChromeDriver.java index 0500629bec..0887210b53 100644 --- a/src/test/java/ca/corefacility/bioinformatics/irida/ria/integration/AbstractIridaUIITChromeDriver.java +++ b/src/test/java/ca/corefacility/bioinformatics/irida/ria/integration/AbstractIridaUIITChromeDriver.java @@ -46,8 +46,8 @@ @Tag("IntegrationTest") @Tag("UI") @ActiveProfiles("it") -@SpringBootTest(classes = { IridaApplication.class, IridaApiTestFilesystemConfig.class }, - webEnvironment = WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = { IridaApplication.class, + IridaApiTestFilesystemConfig.class }, webEnvironment = WebEnvironment.RANDOM_PORT) @Import(IridaIntegrationTestUriConfig.class) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class }) @@ -62,9 +62,6 @@ public class AbstractIridaUIITChromeDriver { private static boolean isSingleTest = false; - private static final String CHROMEDRIVER_PROP_KEY = "webdriver.chrome.driver"; - private static final String CHROMEDRIVER_LOCATION = "src/main/webapp/chromedriver"; - @RegisterExtension public ScreenshotOnFailureWatcher watcher = new ScreenshotOnFailureWatcher(); @@ -86,12 +83,8 @@ public static void destroy() { */ public static WebDriver driver() { if (IntegrationUITestListener.driver() == null) { - final String chromeDriverProp = System.getProperty(CHROMEDRIVER_PROP_KEY); - System.setProperty(CHROMEDRIVER_PROP_KEY, - Strings.isNullOrEmpty(chromeDriverProp) ? CHROMEDRIVER_LOCATION : chromeDriverProp); logger.debug( - "Starting ChromeDriver for a single test class. Using `chromedriver` at '" + System.getProperty( - CHROMEDRIVER_PROP_KEY) + "'"); + "Starting ChromeDriver for a single test class."); isSingleTest = true; IntegrationUITestListener.startWebDriver(); } @@ -107,11 +100,7 @@ public static WebDriver driver() { */ public static WebDriver driver2() { if (IntegrationUITestListener.driver2() == null) { - final String chromeDriverProp = System.getProperty(CHROMEDRIVER_PROP_KEY); - System.setProperty(CHROMEDRIVER_PROP_KEY, - Strings.isNullOrEmpty(chromeDriverProp) ? CHROMEDRIVER_LOCATION : chromeDriverProp); - logger.debug("Starting a second ChromeDriver for a single test class. Using `chromedriver` at '" - + System.getProperty(CHROMEDRIVER_PROP_KEY) + "'"); + logger.debug("Starting a second ChromeDriver for a single test class"); isSingleTest = true; IntegrationUITestListener.startWebDriver(); } @@ -121,12 +110,16 @@ public static WebDriver driver2() { } /** - * Method to use on any page to check to ensure that internationalization messages are being automatically loaded + * Method to use on any page to check to ensure that internationalization + * messages are being automatically loaded * onto the page. * - * @param page - the instance of {@link AbstractPage} to check for internationalization. - * @param entries - a {@link List} of bundle names. This will correspond to the loaded webpack bundles. - * @param header - Expected text for the main heading on the page. Needs to have class name `t-main-heading` + * @param page - the instance of {@link AbstractPage} to check for + * internationalization. + * @param entries - a {@link List} of bundle names. This will correspond to the + * loaded webpack bundles. + * @param header - Expected text for the main heading on the page. Needs to + * have class name `t-main-heading` */ public void checkTranslations(AbstractPage page, List entries, String header) { // Always check for app :) @@ -158,7 +151,8 @@ public void testFailed(ExtensionContext context, Throwable t) { try { final Path destination = Files.createTempFile( "irida-" + context.getRequiredTestClass().getSimpleName() + "#" - + context.getRequiredTestMethod().getName(), ".png"); + + context.getRequiredTestMethod().getName(), + ".png"); Files.move(screenshot, destination, StandardCopyOption.REPLACE_EXISTING); logger.info("Screenshot deposited at: [" + destination.toString() + "]"); } catch (final IOException e) {