Changeset - 8a60eb2b7603
[Not reviewed]
default
0 1 0
domruf - 9 years ago 2017-04-09 00:13:17
dominikruf@gmail.com
Jenkinsfile: run each py.test on a separate executor

Running all py.test processes in parallel on the same executor is not a good idea.
If a node has not much RAM, it could run out of memory when all py.test processes
run at the same time. And If there are only 2 CPU cores, it doesn't make sense
to run more then 2 processes either.
Therefore use a separate executor for each one. The py.test processes will thus
only run in parallel if there are multiple Jenkins executors available.
1 file changed with 18 insertions and 3 deletions:
0 comments (0 inline, 0 general)
Jenkinsfile
Show inline comments
 
node {
 
    def createvirtualenv = ''
 
    def activatevirtualenv = ''
 

	
 
node {
 
    if (isUnix()) {
 
        createvirtualenv = 'rm -r $JENKINS_HOME/venv/$JOB_NAME || true && virtualenv $JENKINS_HOME/venv/$JOB_NAME'
 
        activatevirtualenv = '. $JENKINS_HOME/venv/$JOB_NAME/bin/activate'
 
    } else {
 
        createvirtualenv = 'rmdir /s /q %JENKINS_HOME%\\venv\\%JOB_NAME% || true && virtualenv %JENKINS_HOME%\\venv\\%JOB_NAME%'
 
        activatevirtualenv = 'call %JENKINS_HOME%\\venv\\%JOB_NAME%\\Scripts\\activate.bat'
 
@@ -58,14 +59,17 @@ node {
 
        } catch (java.lang.IllegalArgumentException exc) {
 
            echo "You need to install the 'Warnings Plug-in' to display the pylint report."
 
            currentBuild.result = 'UNSTABLE'
 
            echo "Caught: ${exc}"
 
        }
 
    }
 
}
 

	
 
    def pytests = [:]
 
    pytests['sqlite'] = {
 
    node {
 
        ws {
 
            deleteDir()
 
            unstash name: 'kallithea'
 
            if (isUnix()) {
 
                sh script: """$activatevirtualenv
 
                    py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea --cov-report xml
 
@@ -84,14 +88,17 @@ node {
 
                echo "You need to install the pipeline compatible 'CoberturaPublisher Plug-in' to display the coverage report."
 
                currentBuild.result = 'UNSTABLE'
 
                echo "Caught: ${exc}"
 
            }
 
        }
 
    }
 
}
 

	
 
pytests['de'] = {
 
    node {
 
    if (isUnix()) {
 
        pytests['de'] = {
 
            ws {
 
                deleteDir()
 
                unstash name: 'kallithea'
 
                withEnv(['LANG=de_DE.UTF-8',
 
                    'LANGUAGE=de',
 
                    'LC_ADDRESS=de_DE.UTF-8',
 
@@ -110,13 +117,17 @@ node {
 
                }
 
                sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1DE./g" pytest_de.xml'
 
                archiveArtifacts 'pytest_de.xml'
 
                junit 'pytest_de.xml'
 
            }
 
        }
 
    }
 
}
 
        pytests['mysql'] = {
 
    node {
 
        if (isUnix()) {
 
            ws {
 
                deleteDir()
 
                unstash name: 'kallithea'
 
                sh """$activatevirtualenv
 
                    pip install --upgrade MySQL-python
 
                    """
 
@@ -133,13 +144,17 @@ node {
 
                }
 
                sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1MYSQL./g" pytest_mysql.xml'
 
                archiveArtifacts 'pytest_mysql.xml'
 
                junit 'pytest_mysql.xml'
 
            }
 
        }
 
    }
 
}
 
        pytests['postgresql'] = {
 
    node {
 
        if (isUnix()) {
 
            ws {
 
                deleteDir()
 
                unstash name: 'kallithea'
 
                sh """$activatevirtualenv
 
                    pip install --upgrade psycopg2
 
                    """
 
@@ -157,10 +172,10 @@ node {
 
                sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1POSTGRES./g" pytest_postgresql.xml'
 
                archiveArtifacts 'pytest_postgresql.xml'
 
                junit 'pytest_postgresql.xml'
 
            }
 
        }
 
    }
 
}
 
    stage('Tests') {
 
        parallel pytests
 
    }
 
}
0 comments (0 inline, 0 general)