You've already forked jenkins-lib
forked from jenkins/jenkins-lib
Yaxunit
This commit is contained in:
@@ -18,11 +18,13 @@
|
||||
"syntaxCheck": false,
|
||||
"edtValidate": false,
|
||||
"smoke": false,
|
||||
"yaxunit": false,
|
||||
"email": false,
|
||||
"telegram": false
|
||||
},
|
||||
"timeout": {
|
||||
"smoke": 240,
|
||||
"yaxunit": 240,
|
||||
"bdd": 120,
|
||||
"getBinaries": 60,
|
||||
"createInfoBase": 60,
|
||||
@@ -80,6 +82,9 @@
|
||||
"publishToAllureReport": false,
|
||||
"publishToJUnitReport": true
|
||||
},
|
||||
"yaxunit": {
|
||||
"vrunnerSettings": "./tools/vrunner.json"
|
||||
},
|
||||
"resultsTransform": {
|
||||
"removeSupport": true,
|
||||
"supportLevel": 0
|
||||
|
@@ -67,6 +67,10 @@
|
||||
"type": "boolean",
|
||||
"description": "Дымовые тесты включены"
|
||||
},
|
||||
"yaxunit": {
|
||||
"type": "boolean",
|
||||
"description": "Юнит тесты"
|
||||
},
|
||||
"initSteps": {
|
||||
"type": "boolean",
|
||||
"description": "Предварительные шаги инициализации включены"
|
||||
@@ -290,6 +294,21 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"yaxunit": {
|
||||
"type": "object",
|
||||
"id": "urn:jsonschema:ru:pulsar:jenkins:library:configuration:YaxunitOptions",
|
||||
"description": "Настройки юнит тестирования",
|
||||
"properties": {
|
||||
"vrunnerSettings": {
|
||||
"type": "string",
|
||||
"description": "Путь к конфигурационному файлу vanessa-runner.\n По умолчанию содержит значение \"./tools/vrunner.json\".\n "
|
||||
},
|
||||
"configPath": {
|
||||
"type": "string",
|
||||
"description": "Путь к конфигурационному файлу для Yaxunit.\n По умолчанию содержит значение \"./tools/YaxunitConfig.json\".\n "
|
||||
}
|
||||
}
|
||||
},
|
||||
"resultsTransform": {
|
||||
"type": "object",
|
||||
"id": "urn:jsonschema:ru:pulsar:jenkins:library:configuration:ResultsTransformOptions",
|
||||
|
@@ -65,6 +65,7 @@ class ConfigurationReader implements Serializable {
|
||||
"bddOptions",
|
||||
"sonarQubeOptions",
|
||||
"smokeTestOptions",
|
||||
"yaxunitoptions",
|
||||
"syntaxCheckOptions",
|
||||
"resultsTransformOptions",
|
||||
"notificationsOptions",
|
||||
|
@@ -55,6 +55,10 @@ class JobConfiguration implements Serializable {
|
||||
@JsonPropertyDescription("Настройки дымового тестирования")
|
||||
SmokeTestOptions smokeTestOptions;
|
||||
|
||||
@JsonProperty("yaxunit")
|
||||
@JsonPropertyDescription("Настройки юнит тестирования")
|
||||
YaxunitOptions yaxunitOptions;
|
||||
|
||||
@JsonProperty("resultsTransform")
|
||||
@JsonPropertyDescription("Настройки трансформации результатов анализа")
|
||||
ResultsTransformOptions resultsTransformOptions;
|
||||
@@ -84,6 +88,7 @@ class JobConfiguration implements Serializable {
|
||||
", sonarQubeOptions=" + sonarQubeOptions +
|
||||
", syntaxCheckOptions=" + syntaxCheckOptions +
|
||||
", smokeTestOptions=" + smokeTestOptions +
|
||||
", yaxunitoptions=" + yaxunitOptions +
|
||||
", resultsTransformOptions=" + resultsTransformOptions +
|
||||
", notificationOptions=" + notificationsOptions +
|
||||
", logosConfig='" + logosConfig + '\'' +
|
||||
|
@@ -18,6 +18,9 @@ class StageFlags implements Serializable {
|
||||
@JsonPropertyDescription("Дымовые тесты включены")
|
||||
Boolean smoke
|
||||
|
||||
@JsonPropertyDescription("Юнит тесты")
|
||||
Boolean yaxunit
|
||||
|
||||
@JsonPropertyDescription("Предварительные шаги инициализации включены")
|
||||
Boolean initSteps
|
||||
|
||||
@@ -46,6 +49,6 @@ class StageFlags implements Serializable {
|
||||
}
|
||||
|
||||
boolean needInfoBase() {
|
||||
return smoke || syntaxCheck || initSteps || bdd
|
||||
return smoke || syntaxCheck || initSteps || bdd || yaxunit
|
||||
}
|
||||
}
|
||||
|
@@ -66,6 +66,11 @@ class TimeoutOptions implements Serializable {
|
||||
''')
|
||||
Integer smoke
|
||||
|
||||
@JsonPropertyDescription('''Таймаут шага Юнит тестов, в минутах.
|
||||
По умолчанию содержит значение 240.
|
||||
''')
|
||||
Integer yaxunit
|
||||
|
||||
@JsonPropertyDescription('''Таймаут шага статического анализа SonarQube, в минутах.
|
||||
По умолчанию содержит значение 90.
|
||||
''')
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package ru.pulsar.jenkins.library.configuration
|
||||
|
||||
import com.cloudbees.groovy.cps.NonCPS
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
class YaxunitOptions implements Serializable {
|
||||
|
||||
@JsonPropertyDescription("""Путь к конфигурационному файлу vanessa-runner.
|
||||
По умолчанию содержит значение "./tools/vrunner.json".
|
||||
""")
|
||||
String vrunnerSettings
|
||||
|
||||
@Override
|
||||
@NonCPS
|
||||
String toString() {
|
||||
return "YaxunitTestOptions{" +
|
||||
"vrunnerSettings='" + vrunnerSettings + '\'' +
|
||||
", configPath='" + configPath +
|
||||
'}'
|
||||
}
|
||||
}
|
98
src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy
Normal file
98
src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy
Normal file
@@ -0,0 +1,98 @@
|
||||
package ru.pulsar.jenkins.library.steps
|
||||
|
||||
import hudson.FilePath
|
||||
import ru.pulsar.jenkins.library.IStepExecutor
|
||||
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||
import ru.pulsar.jenkins.library.utils.FileUtils
|
||||
import ru.pulsar.jenkins.library.utils.Logger
|
||||
import ru.pulsar.jenkins.library.utils.VRunner
|
||||
|
||||
import java.nio.file.Files
|
||||
|
||||
class Yaxunit implements Serializable {
|
||||
|
||||
private final JobConfiguration config
|
||||
|
||||
private final String yaxunitPath = 'build/yaxunit.cfe'
|
||||
|
||||
Yaxunit(JobConfiguration config) {
|
||||
this.config = config
|
||||
}
|
||||
|
||||
def run() {
|
||||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||
|
||||
Logger.printLocation()
|
||||
|
||||
if (!config.stageFlags.yaxunit) {
|
||||
Logger.println("Yaxunit test step is disabled")
|
||||
return
|
||||
}
|
||||
|
||||
List<String> logosConfig = ["LOGOS_CONFIG=$config.logosConfig"]
|
||||
steps.withEnv(logosConfig) {
|
||||
steps.installLocalDependencies()
|
||||
}
|
||||
|
||||
def options = config.yaxunitOptions
|
||||
def env = steps.env()
|
||||
|
||||
String vrunnerPath = VRunner.getVRunnerPath()
|
||||
String ibConnection = "--ibconnection /F./build/ib"
|
||||
|
||||
// Скачиваем расширение с гитхаба
|
||||
String pathToYaxunit = "$env.WORKSPACE/$yaxunitPath"
|
||||
FilePath localPathToYaxunit = FileUtils.getFilePath(pathToYaxunit)
|
||||
Logger.println("Скачивание Yaxunit в $localPathToYaxunit")
|
||||
localPathToYaxunit.copyFrom(new URL('https://github.com/bia-technologies/yaxunit/releases/download/22.11.0/YAXUNIT-22.11.cfe'))
|
||||
|
||||
// Устанавливаем расширение
|
||||
// String loadYaxunitCommand = "$vrunnerPath loadext -f $localPathToYaxunit --extension Yaxunit --updatedb $ibConnection"
|
||||
String loadYaxunitCommand = vrunnerPath + ' run --command "Путь=' + pathToYaxunit + ';ЗавершитьРаботуСистемы" --execute $runnerRoot/epf/ЗагрузитьРасширениеВРежимеПредприятия.epf ' + ibConnection
|
||||
// Устанавливаем тесты
|
||||
String loadTestsCommand = "$vrunnerPath compileext ./src/cfe test --updatedb $ibConnection"
|
||||
|
||||
// Создаем конфиг, т.к. в репо может быть ключ, который не закрывает программу и может повесить конвеер
|
||||
// Также путь к отчету в формате junit указывается в конфиге, т.к. мы не знаем на чем стартует агент,
|
||||
// поэтому собираем сами. Стоит вынести в отдельный класс
|
||||
String junitReport = "build/out/jUnit/yaxunit/yaxunit.xml"
|
||||
FilePath pathToJUnitReport = FileUtils.getFilePath("$env.WORKSPACE/$junitReport")
|
||||
String junitReportDir = FileUtils.getLocalPath(pathToJUnitReport.getParent())
|
||||
String configYaxunit = "test-config.json"
|
||||
FilePath pathToConfig = FileUtils.getFilePath("$env.WORKSPACE/$configYaxunit")
|
||||
// def data = [
|
||||
// 'filter' : 'test',
|
||||
// 'reportPath' : 'ss'
|
||||
// ]
|
||||
// String data = "{\"filter\": {\"extensions\": [\"test\"]}, \"reportPath\": \"$pathToConfig\"}"
|
||||
// def json = new groovy.json.JsonBuilder()
|
||||
// json "filter" : "jj", "reportPath" : "ii"
|
||||
// def file = new File("$env.WORKSPACE\\$configYaxunit")
|
||||
// file.createNewFile()
|
||||
// file.write(groovy.json.JsonOutput.prettyPrint(json.toString()))
|
||||
|
||||
// Запускаем тесты
|
||||
String command = "$vrunnerPath run --command RunUnitTests=$pathToConfig $ibConnection"
|
||||
|
||||
String vrunnerSettings = options.vrunnerSettings
|
||||
if (steps.fileExists(vrunnerSettings)) {
|
||||
String vrunnerSettingsCommand = " --settings $vrunnerSettings"
|
||||
|
||||
command += vrunnerSettingsCommand
|
||||
loadYaxunitCommand += vrunnerSettingsCommand
|
||||
loadTestsCommand += vrunnerSettingsCommand
|
||||
}
|
||||
|
||||
steps.withEnv(logosConfig) {
|
||||
VRunner.exec(loadYaxunitCommand, true)
|
||||
VRunner.exec(loadTestsCommand, true)
|
||||
VRunner.exec(command, true)
|
||||
}
|
||||
|
||||
// Сохраняем результаты
|
||||
steps.junit("$junitReportDir/*.xml", true)
|
||||
steps.archiveArtifacts("$junitReportDir/**")
|
||||
|
||||
}
|
||||
}
|
@@ -243,6 +243,23 @@ void call() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Юнит тесты') {
|
||||
agent {
|
||||
label agent1C
|
||||
}
|
||||
when {
|
||||
beforeAgent true
|
||||
expression { config.stageFlags.yaxunit }
|
||||
}
|
||||
steps {
|
||||
timeout(time: config.timeoutOptions.smoke, unit: TimeUnit.MINUTES) {
|
||||
unzipInfobase()
|
||||
|
||||
yaxunit config
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
12
vars/yaxunit.groovy
Normal file
12
vars/yaxunit.groovy
Normal file
@@ -0,0 +1,12 @@
|
||||
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||
import ru.pulsar.jenkins.library.steps.Yaxunit
|
||||
|
||||
def call(JobConfiguration config) {
|
||||
|
||||
ContextRegistry.registerDefaultContext(this)
|
||||
|
||||
def yaxunit = new Yaxunit(config)
|
||||
yaxunit.run()
|
||||
|
||||
}
|
Reference in New Issue
Block a user