From 632abe94c010455a588127efa99bc8f3f10bea2d Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Fri, 2 Feb 2018 16:24:17 -0800 Subject: [PATCH] Parallelize Docker versions Signed-off-by: Joffrey F --- Jenkinsfile | 35 +++++++++++++++++++++++++++-------- script/test/ci | 2 +- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index eb86ea326..44cd7c3c2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,12 +18,26 @@ def buildImage = { -> } } +def get_versions = { int number -> + def docker_versions + wrappedNode(label: "ubuntu && !zfs") { + def result = sh(script: """docker run --rm \\ + --entrypoint=/code/.tox/py27/bin/python \\ + ${image.id} \\ + /code/script/test/versions.py -n ${number} docker/docker-ce recent + """, returnStdout: true + ) + docker_versions = result.split() + } + return docker_versions +} + def runTests = { Map settings -> def dockerVersions = settings.get("dockerVersions", null) def pythonVersions = settings.get("pythonVersions", null) if (!pythonVersions) { - throw new Exception("Need Python versions to test. e.g.: `runTests(pythonVersions: 'py27,py34')`") + throw new Exception("Need Python versions to test. e.g.: `runTests(pythonVersions: 'py27,py36')`") } if (!dockerVersions) { throw new Exception("Need Docker versions to test. e.g.: `runTests(dockerVersions: 'all')`") @@ -46,7 +60,7 @@ def runTests = { Map settings -> -e "DOCKER_VERSIONS=${dockerVersions}" \\ -e "BUILD_NUMBER=\$BUILD_TAG" \\ -e "PY_TEST_VERSIONS=${pythonVersions}" \\ - --entrypoint="script/ci" \\ + --entrypoint="script/test/ci" \\ ${image.id} \\ --verbose """ @@ -56,9 +70,14 @@ def runTests = { Map settings -> } buildImage() -// TODO: break this out into meaningful "DOCKER_VERSIONS" values instead of all -parallel( - failFast: true, - all_py27: runTests(pythonVersions: "py27", dockerVersions: "all"), - all_py36: runTests(pythonVersions: "py36", dockerVersions: "all"), -) + +def testMatrix = [failFast: true] +def docker_versions = get_versions(2) + +for (int i = 0 ;i < docker_versions.length ; i++) { + def dockerVersion = docker_versions[i] + testMatrix["${dockerVersion}_py27"] = runTests([dockerVersions: dockerVersion, pythonVersions: "py27"]) + testMatrix["${dockerVersion}_py36"] = runTests([dockerVersions: dockerVersion, pythonVersions: "py36"]) +} + +parallel(testMatrix) diff --git a/script/test/ci b/script/test/ci index c5927b2c9..8d3aa56cb 100755 --- a/script/test/ci +++ b/script/test/ci @@ -14,7 +14,7 @@ set -ex docker version -export DOCKER_VERSIONS=all +export DOCKER_VERSIONS=${DOCKER_VERSIONS:-all} STORAGE_DRIVER=${STORAGE_DRIVER:-overlay} export DOCKER_DAEMON_ARGS="--storage-driver=$STORAGE_DRIVER"