Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-51489] Use ATH pre configured plugins mode from essentialsTest #65

Merged
merged 6 commits into from
Jun 11, 2018
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable was lacking a def and I have changed the name of it to avoid having a metadata.metadata in the code which may be misleading, and I like the idea of a metadatasection in the yml file

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