Skip to content

Commit

Permalink
Merge pull request #65 from raul-arabaolaza/JENKINS-51489
Browse files Browse the repository at this point in the history
[JENKINS-51489] Use ATH pre configured plugins mode from essentialsTest
  • Loading branch information
Raúl Arabaolaza Barquin authored Jun 11, 2018
2 parents a15e7df + a435806 commit 1034fc7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
11 changes: 7 additions & 4 deletions vars/essentialsTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ def call(Map params = [:]) {
def baseDir = params.containsKey('baseDir') ? params.baseDir : "."
def metadataFile = params.containsKey('metadataFile') ? params.metadataFile : "essentials.yml"
def labels = params.containsKey('labels') ? params.labels : "docker && highmem"
def testPluginResolution

node(labels) {
stage("Checkout") {
Expand All @@ -10,7 +11,9 @@ def call(Map params = [:]) {

dir(baseDir) {
def metadataPath = "${pwd()}/${metadataFile}"
metadata = readYaml(file: metadataPath)
def configData = readYaml(file: metadataPath)
testPluginResolution = configData.flow?.ath?.testPluginResolution?.skipOnUnmetDependencies ? "skipOnInvalid" : "failOnInvalid"


def customBOM = "${pwd tmp: true}/custom.bom.yml"
def customWAR = "${pwd tmp: true}/custom.war"
Expand All @@ -20,15 +23,15 @@ def call(Map params = [:]) {
customWARPackager.build(metadataPath, customWAR, customBOM)
}

if (metadata.ath != null && !metadata.ath.disabled) {
if (configData.ath != null && !configData.ath.disabled) {
stage("Run ATH") {
dir("ath") {
runATH jenkins: customWarURI, metadataFile: metadataPath
runATH jenkins: customWarURI, metadataFile: metadataPath, javaOptions: ["-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn", testPluginResolution]
}
}
}

if (metadata.pct != null && !metadata.pct.disabled) {
if (configData.pct != null && !configData.pct.disabled) {
stage("Run PCT") {
runPCT jenkins: customWarURI, metadataFile: metadataPath
}
Expand Down
19 changes: 12 additions & 7 deletions vars/runATH.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def call(Map params = [:]) {
def jenkins = params.get('jenkins', 'latest')
def athContainerImageTag = params.get("athImage", "jenkins/ath");
def configFile = params.get("configFile", null)
def javaOptions = params.get('javaOptions', ["-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"])

def mirror = "http://mirrors.jenkins.io/"
def defaultCategory = "org.jenkinsci.test.acceptance.junit.SmokeTest"
Expand Down Expand Up @@ -123,33 +124,33 @@ def call(Map params = [:]) {
if (supportedBrowsers.contains(browser)) {

def currentBrowser = browser
def containerArgs = "-v /var/run/docker.sock:/var/run/docker.sock -e SHARED_DOCKER_SERVICE=true -e EXERCISEDPLUGINREPORTER=textfile -u ath-user"
def containerArgs = "-v /var/run/docker.sock:/var/run/docker.sock -u ath-user"
if(configFile) {
containerArgs += " -e CONFIG=../${configFile}" // ATH runs are executed in a subfolder, hence path needs to take that into account
}
def commandBase = "./run.sh ${currentBrowser} ./jenkins.war -B -Dmaven.test.failure.ignore=true -DforkCount=1 -B -Dsurefire.rerunFailingTestsCount=${rerunCount} -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
def commandBase = "./run.sh ${currentBrowser} ./jenkins.war -B -Dmaven.test.failure.ignore=true -DforkCount=1 -B -Dsurefire.rerunFailingTestsCount=${rerunCount}"

if (testsToRun) {
testingbranches["ATH individual tests-${currentBrowser}"] = {
dir("test${currentBrowser}") {
def discriminator = "-Dtest=${testsToRun}"
test(discriminator, commandBase, localSnapshots, localPluginsStashName, containerArgs, athContainerImage)
test(discriminator, commandBase, localSnapshots, localPluginsStashName, containerArgs, athContainerImage, javaOptions)
}
}
}
if (categoriesToRun) {
testingbranches["ATH categories-${currentBrowser}"] = {
dir("categories${currentBrowser}") {
def discriminator = "-Dgroups=${categoriesToRun}"
test(discriminator, commandBase, localSnapshots, localPluginsStashName, containerArgs, athContainerImage)
test(discriminator, commandBase, localSnapshots, localPluginsStashName, containerArgs, athContainerImage, javaOptions)
}
}
}
if (testsToRun == null && categoriesToRun == null) {
testingbranches["ATH ${currentBrowser}"] = {
dir("ath${currentBrowser}") {
def discriminator = ""
test(discriminator, commandBase, localSnapshots, localPluginsStashName, containerArgs, athContainerImage)
test(discriminator, commandBase, localSnapshots, localPluginsStashName, containerArgs, athContainerImage, javaOptions)
}
}
}
Expand All @@ -164,11 +165,15 @@ def call(Map params = [:]) {
})
}

private void test(discriminator, commandBase, localSnapshots, localPluginsStashName, containerArgs, athContainerImage) {
private void test(discriminator, commandBase, localSnapshots, localPluginsStashName, containerArgs, athContainerImage, javaOptions) {
unstashResources(localSnapshots, localPluginsStashName)
athContainerImage.inside(containerArgs) {
realtimeJUnit(testResults: 'target/surefire-reports/TEST-*.xml', testDataPublishers: [[$class: 'AttachmentPublisher']]) {
sh 'eval "$(./vnc.sh)" && export DISPLAY=$BROWSER_DISPLAY && ' + prepareCommand(commandBase, discriminator, localSnapshots, localPluginsStashName)
def command = 'eval "$(./vnc.sh)" && export DISPLAY=$BROWSER_DISPLAY && export SHARED_DOCKER_SERVICE=true && export EXERCISEDPLUGINREPORTER=textfile && ' + prepareCommand(commandBase, discriminator, localSnapshots, localPluginsStashName)
if (!javaOptions.isEmpty()) {
command = """export JAVA_OPTS="${javaOptions.join(' ')}" && ${command}"""
}
sh command
}
}
}
Expand Down

0 comments on commit 1034fc7

Please sign in to comment.