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

Commit

Permalink
Defined task outputs for compose tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
sglahn authored and elmarx committed Nov 27, 2018
1 parent 872024d commit b477e9d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies {
}

group = 'org.rewedigital'
version = '0.2'
version = '0.3'

gradlePlugin {
plugins {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package org.rewedigital.frost.tasks


import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.rewedigital.frost.util.Util

class FrostComposeKillTask extends DockerComposeTask {

@OutputDirectory
def getReportDirectory() {
Util.composeOutputDirectory(project)
}

@TaskAction
@Override
def action() {
Expand All @@ -16,7 +21,7 @@ class FrostComposeKillTask extends DockerComposeTask {
cmd << "-f"
cmd << getComposeOverrideFile()
cmd << "kill"
Util.executeSynchronously(cmd, "docker_compose_kill")
Util.executeSynchronously(cmd, "docker_compose_kill", getReportDirectory())

cmd = [EXECUTABLE]
cmd << "-f"
Expand All @@ -26,7 +31,7 @@ class FrostComposeKillTask extends DockerComposeTask {
cmd << "rm"
cmd << "-f"
cmd << "-v"
Util.executeSynchronously(cmd, "docker_compose_rm")
Util.executeSynchronously(cmd, "docker_compose_rm", getReportDirectory())
} finally {
getComposeOverrideFile().delete()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
package org.rewedigital.frost.tasks


import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.rewedigital.frost.util.Util

import static org.rewedigital.frost.FrostPluginExtension.EXTENSION_NAME

class FrostComposePullTask extends DockerComposeTask {

@OutputDirectory
def getReportDirectory() {
Util.composeOutputDirectory(project)
}

@TaskAction
@Override
def action() {
def cmd = ["/bin/sh"]
cmd << "-c"
cmd << "export TAG=${project.extensions[EXTENSION_NAME].sutTag} && ${EXECUTABLE} -f ${getComposeFile()} -f ${getComposeOverrideFile()} pull --ignore-pull-failures"

Util.executeSynchronously(cmd, "docker_compose_pull")
Util.executeSynchronously(cmd, "docker_compose_pull", getReportDirectory())
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package org.rewedigital.frost.tasks

import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.rewedigital.frost.util.Util

import static org.rewedigital.frost.FrostPluginExtension.EXTENSION_NAME

class FrostComposeUpTask extends DockerComposeTask {

@OutputDirectory
def getReportDirectory() {
Util.composeOutputDirectory(project)
}

@TaskAction
@Override
def action() {
def cmd = ["/bin/sh"]
cmd << "-c"
cmd << "export TAG=${project.extensions[EXTENSION_NAME].sutTag} && ${EXECUTABLE} -f ${getComposeFile()} -f ${getComposeOverrideFile()} up"

Util.executeAsynchronously(cmd, "docker_compose_up")
Util.executeAsynchronously(cmd, "docker_compose_up", getReportDirectory())
}
}
14 changes: 12 additions & 2 deletions src/main/groovy/org/rewedigital/frost/tasks/FrostRunTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.rewedigital.frost.browsers.Browser
import org.rewedigital.frost.util.Util
Expand All @@ -19,6 +20,15 @@ class FrostRunTask extends DefaultTask {

private static final int TESTSUITE_TIMEOUT_MILLIS = HOURS.toMillis(1)

@OutputDirectory
def getTestReportDirectory() {
new File(project.buildDir, "reports/tests/frost")
}

@OutputDirectory
def getJunitTestReportDirectory() {
new File(project.buildDir, "test-results/frost")
}

@TaskAction
def action() {
Expand Down Expand Up @@ -71,7 +81,7 @@ class FrostRunTask extends DefaultTask {
def seleniumDriverUrl = "http://localhost:${browserPort}/wd/hub"
def thread = new Thread({
try {
def reportsDirectoryName = "build/reports/tests/uiTest/${browser.browserId}/${testSuitesDirectory.name}"
def reportsDirectoryName = "${getTestReportDirectory()}/${browser.browserId}/${testSuitesDirectory.name}"
executeTestSuitesOnSpecificBrowser(testSuitesDirectory, reportsDirectoryName, seleniumDriverUrl, browser.browserId, testGroups, recursive)
} catch (Exception e) {
lastException = e
Expand All @@ -95,7 +105,7 @@ class FrostRunTask extends DefaultTask {

def cmd = ["${workingDirectory}/galen/galen", "test", "${testSuitesDirectory.toString()}",
"--htmlreport", "${reportsDirectoryName}",
"--junitreport", "build/test-results/uiTest/TEST-${browser}.xml",
"--junitreport", "${getJunitTestReportDirectory()}/TEST-${browser}.xml",
"--parallel-tests", "${numberOfParallelTests}",
"-Dgalen.settings.website=http://${targetHost()}:${project.extensions[EXTENSION_NAME].sutPort}"]

Expand Down
14 changes: 8 additions & 6 deletions src/main/groovy/org/rewedigital/frost/util/Util.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class Util {
makeAbsoluteIfIsRelative(cacheDirectory, project.projectDir)
}

static File composeOutputDirectory(project) {
new File(project.buildDir, "reports/frost-logs")
}

private static File makeAbsoluteIfIsRelative(File possiblyRelativeDirectory, File baseDirectory) {
possiblyRelativeDirectory.isAbsolute() ?
Expand Down Expand Up @@ -79,17 +82,16 @@ class Util {
browser
}

static int executeSynchronously(cmd, processIdentifier) {
return executeInternal(cmd, true, processIdentifier)
static int executeSynchronously(cmd, processIdentifier, logDirectory) {
return executeInternal(cmd, true, processIdentifier, logDirectory)
}

static int executeAsynchronously(cmd, processIdentifier, failFast = true) {
return executeInternal(cmd, false, processIdentifier, failFast)
static int executeAsynchronously(cmd, processIdentifier, logDirectory, failFast = true) {
return executeInternal(cmd, false, processIdentifier, logDirectory, failFast)
}

private static int executeInternal(cmd, executeSynchronously, processIdentifier, failFast = true) {
private static int executeInternal(cmd, executeSynchronously, processIdentifier, logDirectory, failFast = true) {
LOG.info("Executing '{}'", cmd.join(" "))
def logDirectory = new File('build/reports/frost-logs')
def logFile = new File(logDirectory, "${processIdentifier}.log")
logFile.parentFile.mkdirs()

Expand Down

0 comments on commit b477e9d

Please sign in to comment.