blob: a12d0ea3c77278c0e34653a44aa529f179e61f9f [file] [log] [blame]
asledzinskiye0948fd2017-01-06 16:23:54 +02001package com.mirantis.mcp-qa
2
3/**
4 * Run mcp-qa test by specified group
5 * @param testGroup defines what tests to run, options are '-m test_mark', '-k test_expression'
6 * @param jobSetParameters is additional params needed to run mcp-qa test
7 */
8
9def runTest(testGroup, jobSetParameters) {
10 def testArgs = [ '-s', '-ra' ]
11 testArgs.add(testGroup)
12 jobSetParameters.add("TEST_ARGS=${testArgs.join(' ')}")
13 echo("The current tags, args, which were set by job: ${jobSetParameters.join(' ')}")
14 withEnv(jobSetParameters) {
15 sh '''\
16 . ${VENV_PATH}/bin/activate
17 exit_code=0
18 export IMAGE_PATH=$(readlink -f "${IMAGE_PATH}")
19 if ! py.test ${TEST_ARGS}; then
20 exit_code=1
21 fi
22 # erase environment if test passed and KEEP_AFTER isn't set to 'yes' or 'true'
23 if [ ${exit_code} -eq 0 ]; then
24 if ! [[ "${KEEP_AFTER}" == "yes" || "${KEEP_AFTER}" == "true" ]]; then
25 dos.py erase "${ENV_NAME}" || true
26 fi
27 fi
28 if [ ${exit_code} -gt 0 ]; then
29 echo "Tests failed!"
30 exit 1
31 fi
32 '''.stripIndent()
33 }
34}