Skip to content

Commit

Permalink
Add ability to specify multiple agents for flaky test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
brianseeders committed Oct 1, 2019
1 parent 98538b0 commit 65d26a8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
41 changes: 26 additions & 15 deletions .ci/Jenkinsfile_flaky
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,34 @@ 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') {
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()
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))()
}
}, getWorkerMap(params.NUMBER_EXECUTIONS.toInteger(), worker, workerFailures))()
}
}

parallel(agents)

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

if (workerFailures.size() > 0) {
Expand Down Expand Up @@ -66,22 +77,22 @@ def getWorkerFromParams(isXpack, job, ciGroup) {
}
}

def getWorkerMap(numberOfExecutions, worker, workerFailures, maxWorkers = 14) {
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["worker-${i}"] = { workerNumber ->
workerMap["agent-${agentNumber}-worker-${i}"] = { workerNumber ->
for(def j = 0; j < workerExecutions; j++) {
print "Execute worker-${workerNumber}: ${j}"
withEnv(["JOB=worker-${workerNumber}-${j}"]) {
print "Execute agent-${agentNumber} worker-${workerNumber}: ${j}"
withEnv(["JOB=agent-${agentNumber}-worker-${workerNumber}-${j}"]) {
catchError {
try {
worker(workerNumber)
} catch (ex) {
workerFailures << "worker-${workerNumber}-${j}"
workerFailures << "agent-${agentNumber} worker-${workerNumber}-${j}"
throw ex
}
}
Expand Down
1 change: 0 additions & 1 deletion vars/kibanaPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def jobRunner(label, closure) {

def uploadGcsArtifact(workerName, pattern) {
def storageLocation = "gs://kibana-ci-artifacts/jobs/${env.JOB_NAME}/${BUILD_NUMBER}/${workerName}" // TODO
// def storageLocation = "gs://kibana-pipeline-testing/jobs/pipeline-test/${BUILD_NUMBER}/${workerName}"

googleStorageUpload(
credentialsId: 'kibana-ci-gcs-plugin',
Expand Down

0 comments on commit 65d26a8

Please sign in to comment.