autojen/test_samba.groovy

98 lines
2.7 KiB
Groovy
Raw Normal View History

2018-11-08 12:13:00 +03:00
def baseName = 'test'
def tagsList = [
// [name, platform, tags, deploy job]
['common', 'p8', 'common', 'deploy-samba-3x3'],
['all', 'p8', 'all', 'deploy-samba-3x3'],
['sss', 'p8', 'all and sss', 'deploy-samba-1x3'],
['common', 'sisyphus', 'common', 'deploy-samba-sisyphus-3x3'],
['all', 'sisyphus', 'all', 'deploy-samba-sisyphus-3x3'],
['sss', 'sisyphus', 'all and sss', 'deploy-samba-sisyphus-1x3']
]
def testsRepo = 'https://github.com/altlinuxteam/infra.git'
def testsBranch = 'master'
tagsList.each { t ->
def name = t[0]
def distr = t[1]
def tags = t[2]
def deployJob = t[3]
def jobName = "test-${name}-${distr}"
pipelineJob(jobName) {
parameters {
stringParam('test_tags', "${tags}", 'tags list for pytest-bdd')
stringParam('TASKS', '', 'comma separated tasks list to add as additional repos')
choiceParam('DEPLOY_MODE', ['deploy', 'redeploy'], '')
}
definition {
cps {
sandbox()
script("""
node('small') {
stage('deploy stack') {
built = build(
job: '${deployJob}',
parameters: [
[\$class: 'StringParameterValue', name: 'TASKS', value: "\${TASKS}"],
[\$class: 'StringParameterValue', name: 'DEPLOY_MODE', value: "\${DEPLOY_MODE}"],
])
}
}
node('nix') {
stage('fetch infra repos') {
checkout(
[\$class: 'GitSCM',
branches: [[name: '${testsBranch}']],
doGenerateSubmoduleConfigurations: false,
extensions: [
[\$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: false, recursiveSubmodules: true, reference: '', trackingSubmodules: true]],
submoduleCfg: [],
userRemoteConfigs: [[url: '${testsRepo}']]]
)
}
stage('copy stack config from deploy job'){
copyArtifacts(
projectName: '${deployJob}',
selector: specific("\${built.number}"),
filter: '.tmp/*_config',
flatten: false);
}
stage('perform common tests'){
writeFile file: '.script', text: '''
set -o allexport
source .tmp/domain_config
set +o allexport
mkdir -p reports
rm -f reports/common.json
SSH_USERNAME="root" pytest --cucumberjson=reports/common.json --cucumberjson-expanded -k "\$test_tags" roles/samba/tests
if [[ -f reports/common.json ]]; then
exit 0;
else
exit 1;
fi
'''
sshagent(['robot_key']) {
sh 'chmod +x .script && nix-shell --run ./.script'
}
archiveArtifacts artifacts: 'reports/common.json', onlyIfSuccessful: true
cucumber fileIncludePattern: '**/*.json', jsonReportDirectory: 'reports/', sortingMethod: 'ALPHABETICAL'
}
stage('destroy stack') {
built = build(
job: '${deployJob}',
parameters: [
[\$class: 'StringParameterValue', name: 'DEPLOY_MODE', value: 'destroy'],
])
}
}
""".stripIndent())
}
}
}
}