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

Add pipeline for flaky test runner job #46740

Merged
merged 22 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1b342fd
WIP Jenkinsfile for flaky test runner
brianseeders Sep 25, 2019
733dda0
Fix syntax
brianseeders Sep 25, 2019
dcbdad2
A few more jenkinsfile fixes
brianseeders Sep 25, 2019
3b55624
A few more fixes
brianseeders Sep 25, 2019
c632d05
Can't round numbers in Jenkins groovy sandbox apparently
brianseeders Sep 25, 2019
b45b49e
More fixes
brianseeders Sep 26, 2019
bd9b7df
Only do build_kbn_tp_sample_panel_action once during flaky testing
brianseeders Sep 26, 2019
b1a1958
Fix path and try setting a different JOB value
brianseeders Sep 26, 2019
d0bd4a5
Keep track of flaky test failures
brianseeders Sep 26, 2019
712f9fb
Introduce flaky test for testing
brianseeders Sep 26, 2019
e4ea88f
Some flaky test pipeline cleanup
brianseeders Sep 26, 2019
44c8db4
Fix a couple of issues with flaky test failure tracking
brianseeders Sep 27, 2019
f448725
Update flaky test runner build name/desc with metadata
brianseeders Sep 27, 2019
888e388
Revert "Introduce flaky test for testing"
brianseeders Sep 27, 2019
2e897bf
Try adding a local shared library
brianseeders Sep 30, 2019
c85b489
Move local library loading logic to kibana pipeline library
brianseeders Sep 30, 2019
14ddd85
Move shared groovy code to shared library
brianseeders Sep 30, 2019
5fc4d89
Add missed file
brianseeders Sep 30, 2019
1037fe5
Add ability to specify multiple agents for flaky test runner
brianseeders Oct 1, 2019
dbe939b
Update kibana-pipeline-library version
brianseeders Oct 1, 2019
435d9ae
Fix bug causing early exit for oss ciGroup1
brianseeders Oct 3, 2019
8a73a36
Merge branch 'master' into flaky-test-runner
elasticmachine Oct 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .ci/Jenkinsfile_flaky
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/bin/groovy

library 'kibana-pipeline-library'
kibanaLibrary.load()

// Looks like 'oss:ciGroup:1' or 'oss:firefoxSmoke'
def JOB_PARTS = params.CI_GROUP.split(':')
def IS_XPACK = JOB_PARTS[0] == 'xpack'
def JOB = JOB_PARTS[1]
def CI_GROUP = JOB_PARTS[2] ?: ''

def worker = getWorkerFromParams(IS_XPACK, JOB, CI_GROUP)

def workerFailures = []

currentBuild.displayName += trunc(" ${params.GITHUB_OWNER}:${params.branch_specifier}", 24)
currentBuild.description = "${params.CI_GROUP}<br />Executions: ${params.NUMBER_EXECUTIONS}"

// Note: If you increase agent count, it will execute NUMBER_EXECUTIONS per agent. It will not divide them up amongst the agents
// e.g. NUMBER_EXECUTIONS = 25, agentCount = 4 results in 100 total executions
def agentCount = 1

stage("Kibana Pipeline") {
timeout(time: 180, unit: 'MINUTES') {
timestamps {
ansiColor('xterm') {
def agents = [:]
for(def agentNumber = 1; agentNumber <= agentCount; agentNumber++) {
agents["agent-${agentNumber}"] = {
catchError {
kibanaPipeline.withWorkers('flaky-test-runner', {
if (!IS_XPACK) {
kibanaPipeline.buildOss()
if (CI_GROUP == '1') {
runbld "./test/scripts/jenkins_build_kbn_tp_sample_panel_action.sh"
}
} else {
kibanaPipeline.buildXpack()
}
}, getWorkerMap(agentNumber, params.NUMBER_EXECUTIONS.toInteger(), worker, workerFailures))()
}
}
}

parallel(agents)

currentBuild.description += ", Failures: ${workerFailures.size()}"

if (workerFailures.size() > 0) {
print "There were ${workerFailures.size()} test suite failures."
print "The executions that failed were:"
print workerFailures.join("\n")
print "Please check 'Test Result' and 'Pipeline Steps' pages for more info"
}
}
}
}
}

def getWorkerFromParams(isXpack, job, ciGroup) {
if (!isXpack) {
if (job == 'firefoxSmoke') {
return kibanaPipeline.getPostBuildWorker('firefoxSmoke', { runbld './test/scripts/jenkins_firefox_smoke.sh' })
} else if(job == 'visualRegression') {
return kibanaPipeline.getPostBuildWorker('visualRegression', { runbld './test/scripts/jenkins_visual_regression.sh' })
} else {
return kibanaPipeline.getOssCiGroupWorker(ciGroup)
}
}

if (job == 'firefoxSmoke') {
return kibanaPipeline.getPostBuildWorker('xpack-firefoxSmoke', { runbld './test/scripts/jenkins_xpack_firefox_smoke.sh' })
} else if(job == 'visualRegression') {
return kibanaPipeline.getPostBuildWorker('xpack-visualRegression', { runbld './test/scripts/jenkins_xpack_visual_regression.sh' })
} else {
return kibanaPipeline.getXpackCiGroupWorker(ciGroup)
}
}

def getWorkerMap(agentNumber, numberOfExecutions, worker, workerFailures, maxWorkers = 14) {
def workerMap = [:]
def numberOfWorkers = Math.min(numberOfExecutions, maxWorkers)

for(def i = 1; i <= numberOfWorkers; i++) {
def workerExecutions = numberOfExecutions/numberOfWorkers + (i <= numberOfExecutions%numberOfWorkers ? 1 : 0)

workerMap["agent-${agentNumber}-worker-${i}"] = { workerNumber ->
for(def j = 0; j < workerExecutions; j++) {
print "Execute agent-${agentNumber} worker-${workerNumber}: ${j}"
withEnv(["JOB=agent-${agentNumber}-worker-${workerNumber}-${j}"]) {
catchError {
try {
worker(workerNumber)
} catch (ex) {
workerFailures << "agent-${agentNumber} worker-${workerNumber}-${j}"
throw ex
}
}
}
}
}
}

return workerMap
}

def trunc(str, length) {
if (str.size() >= length) {
return str.take(length) + "..."
}

return str;
}
Loading