/**
 *
 * Launch pytest frameworks in Jenkins
 *
 * Expected parameters:
 *   SALT_MASTER_URL                 URL of Salt master
 *   SALT_MASTER_CREDENTIALS         Credentials to the Salt API
 *   IMAGE                           Docker image link to use for running container with test framework.
 *   EXTRA_PARAMS                    Yaml context which contains additional setting for job
 *
 */

common = new com.mirantis.mk.Common()
validate = new com.mirantis.mcp.Validate()
salt_testing = new com.mirantis.mk.SaltModelTesting()

def EXTRA_PARAMS = readYaml(text: env.getProperty('EXTRA_PARAMS')) ?: [:]
def env_vars = EXTRA_PARAMS.get("envs") ?: []

def IMAGE = (env.getProperty('IMAGE')) ?: 'docker-prod-local.docker.mirantis.net/mirantis/cvp/cvp-sanity-checks:stable'
def SLAVE_NODE = (env.getProperty('SLAVE_NODE')) ?: 'docker'

/*
YAML example
=====

# commands is a map of commands which looks like step_name: shell_command
commands:
  001_prepare: rm /var/lib/g.txt
  002_prepare: git clone http://repo_with_tests.git
  003_test: cd repo_with_tests && pytest /var/lib/ --collect-only
  004_collect: cp cvp-spt /var/lib/validation_artifacts/
# envs is a list of new environment variables
envs:
  - SALT_USERNAME=admin
  - SALT_PASSWORD=password
  - drivetrain_version=testing

*/

node (SLAVE_NODE) {
    def artifacts_dir = 'validation_artifacts'
    def configRun = [:]
    try {
        withEnv(env_vars) {
            stage('Initialization') {
                def container_workdir = '/var/lib'
                def test_suite_name = "${env.JOB_NAME}"
                def workdir = "${container_workdir}/${test_suite_name}"
                def xml_file = "${test_suite_name}_report.xml"
                def tests_set = (env.getProperty('tests_set')) ?: ''
                def script = "pytest --junitxml ${container_workdir}/${artifacts_dir}/${xml_file} --tb=short -sv -vv ${tests_set}"

                sh "mkdir -p ${artifacts_dir}"

                // Enrichment for docker commands
                def commands = EXTRA_PARAMS.get("commands") ?: ['010_start_tests': "cd ${workdir} && with_venv.sh ${script}"]
                def commands_list = commands.collectEntries{ [ (it.key) : { sh("${it.value}") } ] }

                // Enrichment for env variables
                def creds = common.getCredentials(SALT_MASTER_CREDENTIALS)
                def env_vars_list  =  [
                    "SALT_USERNAME=${creds.username}",
                    "SALT_PASSWORD=${creds.password}",
                    "SALT_URL=${SALT_MASTER_URL}"
                    ] + env_vars

                // Generating final config
                configRun = [
                    'image': IMAGE,
                    'baseRepoPreConfig': false,
                    'dockerMaxCpus': 2,
                    'dockerExtraOpts' : [
                        "-v /root/qa_results/:/root/qa_results/",
                        "-v ${env.WORKSPACE}/${artifacts_dir}/:${container_workdir}/${artifacts_dir}/",
                    ],
                    'envOpts'         : env_vars_list,
                    'runCommands'     : commands_list
                ]
            }

            stage('Run Tests') {
                salt_testing.setupDockerAndTest(configRun)
            }

            stage ('Publish results') {
                archiveArtifacts artifacts: "${artifacts_dir}/*"
                junit "${artifacts_dir}/*.xml"
                if (env.JOB_NAME.contains("cvp-spt")) {
                    plot csvFileName: 'plot-glance.csv',
                        group: 'SPT',
                        style: 'line',
                        title: 'SPT Glance results',
                        xmlSeries: [[
                        file: "${env.JOB_NAME}_report.xml",
                        nodeType: 'NODESET',
                        url: '',
                        xpath: '/testsuite/testcase[@name="test_speed_glance"]/properties/property']]
                    plot csvFileName: 'plot-hw2hw.csv',
                        group: 'SPT',
                        style: 'line',
                        title: 'SPT HW2HW results',
                        xmlSeries: [[
                        file: "${env.JOB_NAME}_report.xml",
                        nodeType: 'NODESET',
                        url: '',
                        xpath: '/testsuite/testcase[@classname="cvp_spt.tests.test_hw2hw"]/properties/property']]
                    plot csvFileName: 'plot-vm2vm.csv',
                        group: 'SPT',
                        style: 'line',
                        title: 'SPT VM2VM results',
                        xmlSeries: [[
                        file: "${env.JOB_NAME}_report.xml",
                        nodeType: 'NODESET',
                        url: '',
                        xpath: '/testsuite/testcase[@classname="cvp_spt.tests.test_vm2vm"]/properties/property']]
                }
            }
        }
    }
    catch (Throwable e) {
        currentBuild.result = "FAILURE"
        throw e
    }
    finally {
        sh "rm -rf ${artifacts_dir}"
    }
}
