You've already forked jenkins-lib
forked from jenkins/jenkins-lib
Доработка Yaxunit (#13)
* add params * rewrite and add params * fix options merge * fix command * switch to ArrayList * fix junit reports * fix yaxunit config * fix yaxunit config * fix yaxunit config paths * add allure * fix allure * fix public * fix static * copy allure * publish options * schema upd
This commit is contained in:
@@ -61,6 +61,8 @@ dependencies {
|
||||
|
||||
integrationTestImplementation("org.slf4j", "slf4j-api", slf4jVersion)
|
||||
integrationTestImplementation("org.slf4j", "slf4j-simple", slf4jVersion)
|
||||
integrationTestImplementation("org.springframework.security", "spring-security-core", "5.1.13.RELEASE")
|
||||
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
@@ -105,6 +107,8 @@ sharedLibrary {
|
||||
dependency("org.6wind.jenkins", "lockable-resources", "2.7")
|
||||
dependency("ru.yandex.qatools.allure", "allure-jenkins-plugin", "2.28.1")
|
||||
val declarativePluginsVersion = "1.6.0"
|
||||
|
||||
|
||||
dependency("org.jenkinsci.plugins", "pipeline-model-api", declarativePluginsVersion)
|
||||
dependency("org.jenkinsci.plugins", "pipeline-model-declarative-agent", "1.1.1")
|
||||
dependency("org.jenkinsci.plugins", "pipeline-model-definition", declarativePluginsVersion)
|
||||
|
@@ -83,7 +83,12 @@
|
||||
"publishToJUnitReport": true
|
||||
},
|
||||
"yaxunit": {
|
||||
"vrunnerSettings": "./tools/vrunner.json"
|
||||
"vrunnerSettings": "./tools/vrunner.json",
|
||||
"cfe": "https://github.com/bia-technologies/yaxunit/releases/download/23.05/YAXUNIT-23.05.cfe",
|
||||
"extensionNames": ["YAXUNIT"],
|
||||
"configPath": "./tools/yaxunit.json",
|
||||
"publishToAllureReport": false,
|
||||
"publishToJUnitReport": true
|
||||
},
|
||||
"resultsTransform": {
|
||||
"removeSupport": true,
|
||||
|
@@ -142,6 +142,10 @@
|
||||
"type": "integer",
|
||||
"description": "Таймаут шага дымовых тестов, в минутах.\n По умолчанию содержит значение 240.\n "
|
||||
},
|
||||
"yaxunit": {
|
||||
"type": "integer",
|
||||
"description": "Таймаут шага Юнит тестов, в минутах.\n По умолчанию содержит значение 240.\n "
|
||||
},
|
||||
"sonarqube": {
|
||||
"type": "integer",
|
||||
"description": "Таймаут шага статического анализа SonarQube, в минутах.\n По умолчанию содержит значение 90.\n "
|
||||
@@ -305,7 +309,15 @@
|
||||
},
|
||||
"configPath": {
|
||||
"type": "string",
|
||||
"description": "Путь к конфигурационному файлу для Yaxunit.\n По умолчанию содержит значение \"./tools/YaxunitConfig.json\".\n "
|
||||
"description": "Путь к конфигурационному файлу YAXUnit.\n По умолчанию содержит значение \"./tools/yaxunit.json\".\n "
|
||||
},
|
||||
"publishToAllureReport": {
|
||||
"type": "boolean",
|
||||
"description": "Выполнять публикацию результатов в отчет Allure.\n По умолчанию выключено.\n "
|
||||
},
|
||||
"publishToJUnitReport": {
|
||||
"type": "boolean",
|
||||
"description": "Выполнять публикацию результатов в отчет JUnit.\n По умолчанию включено.\n "
|
||||
}
|
||||
}
|
||||
},
|
||||
|
26
resources/yaxunit.json
Normal file
26
resources/yaxunit.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"reportPath": "./build/out/yaxunit/junit.xml",
|
||||
"closeAfterTests": true,
|
||||
"filter": {
|
||||
"extensions": [
|
||||
"YAXUNIT"
|
||||
],
|
||||
"modules": null,
|
||||
"suites": null,
|
||||
"tags": null,
|
||||
"contexts": null,
|
||||
"paths": null,
|
||||
"tests": null
|
||||
},
|
||||
"settings": {
|
||||
"ВТранзакции": true
|
||||
},
|
||||
"reportFormat": "jUnit",
|
||||
"showReport": false,
|
||||
"logging": {
|
||||
"file": "./build/out/yaxunit/log.txt",
|
||||
"enable": false,
|
||||
"level": "debug"
|
||||
},
|
||||
"exitCode": "./build/out/yaxunit/result.txt"
|
||||
}
|
@@ -65,7 +65,7 @@ class ConfigurationReader implements Serializable {
|
||||
"bddOptions",
|
||||
"sonarQubeOptions",
|
||||
"smokeTestOptions",
|
||||
"yaxunitoptions",
|
||||
"yaxunitOptions",
|
||||
"syntaxCheckOptions",
|
||||
"resultsTransformOptions",
|
||||
"notificationsOptions",
|
||||
@@ -81,6 +81,7 @@ class ConfigurationReader implements Serializable {
|
||||
mergeObjects(baseConfiguration, configurationToMerge, nonMergeableSettings)
|
||||
mergeInitInfoBaseOptions(baseConfiguration.initInfoBaseOptions, configurationToMerge.initInfoBaseOptions)
|
||||
mergeBddOptions(baseConfiguration.bddOptions, configurationToMerge.bddOptions)
|
||||
mergeYaxunitOptions(baseConfiguration.yaxunitOptions, configurationToMerge.yaxunitOptions)
|
||||
mergeSyntaxCheckOptions(baseConfiguration.syntaxCheckOptions, configurationToMerge.syntaxCheckOptions)
|
||||
mergeNotificationsOptions(baseConfiguration.notificationsOptions, configurationToMerge.notificationsOptions)
|
||||
|
||||
@@ -147,6 +148,14 @@ class ConfigurationReader implements Serializable {
|
||||
baseObject.vrunnerSteps = objectToMerge.vrunnerSteps.clone()
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
private static void mergeYaxunitOptions(YaxunitOptions baseObject, YaxunitOptions objectToMerge) {
|
||||
if (objectToMerge == null || objectToMerge.extensionNames == null) {
|
||||
return
|
||||
}
|
||||
baseObject.extensionNames = objectToMerge.extensionNames.clone()
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
private static void mergeSyntaxCheckOptions(SyntaxCheckOptions baseObject, SyntaxCheckOptions objectToMerge) {
|
||||
if (objectToMerge == null || objectToMerge.checkModes == null) {
|
||||
|
@@ -88,7 +88,7 @@ class JobConfiguration implements Serializable {
|
||||
", sonarQubeOptions=" + sonarQubeOptions +
|
||||
", syntaxCheckOptions=" + syntaxCheckOptions +
|
||||
", smokeTestOptions=" + smokeTestOptions +
|
||||
", yaxunitoptions=" + yaxunitOptions +
|
||||
", yaxunitOptions=" + yaxunitOptions +
|
||||
", resultsTransformOptions=" + resultsTransformOptions +
|
||||
", notificationOptions=" + notificationsOptions +
|
||||
", logosConfig='" + logosConfig + '\'' +
|
||||
|
@@ -10,13 +10,40 @@ class YaxunitOptions implements Serializable {
|
||||
@JsonPropertyDescription("""Путь к конфигурационному файлу vanessa-runner.
|
||||
По умолчанию содержит значение "./tools/vrunner.json".
|
||||
""")
|
||||
String vrunnerSettings
|
||||
String vrunnerSettings = "./tools/vrunner.json"
|
||||
|
||||
@JsonPropertyDescription("""Ссылка на скачивание YAXUnit.
|
||||
По умолчанию содержит ссылку на официальный релиз версии 23.05.
|
||||
""")
|
||||
String cfe = "https://github.com/bia-technologies/yaxunit/releases/download/23.05/YAXUNIT-23.05.cfe"
|
||||
|
||||
@JsonPropertyDescription("""Имена расширений с тестами.
|
||||
По умолчанию содержит один элемент - YAXUNIT.
|
||||
""")
|
||||
String[] extensionNames = ['YAXUNIT']
|
||||
|
||||
@JsonPropertyDescription("""Путь к конфигурационному файлу YAXUnit.
|
||||
По умолчанию содержит значение "./tools/yaxunit.json".
|
||||
""")
|
||||
String configPath = "./tools/yaxunit.json"
|
||||
|
||||
@JsonPropertyDescription("""Выполнять публикацию результатов в отчет Allure.
|
||||
По умолчанию выключено.
|
||||
""")
|
||||
boolean publishToAllureReport
|
||||
|
||||
@JsonPropertyDescription("""Выполнять публикацию результатов в отчет JUnit.
|
||||
По умолчанию включено.
|
||||
""")
|
||||
boolean publishToJUnitReport
|
||||
|
||||
@Override
|
||||
@NonCPS
|
||||
String toString() {
|
||||
return "YaxunitTestOptions{" +
|
||||
"vrunnerSettings='" + vrunnerSettings + '\'' +
|
||||
", cfe='" + cfe +
|
||||
", extensionNames='" + extensionNames.toString() +
|
||||
", configPath='" + configPath +
|
||||
'}'
|
||||
}
|
||||
|
@@ -9,8 +9,8 @@ import ru.pulsar.jenkins.library.utils.Logger
|
||||
|
||||
class PublishAllure implements Serializable {
|
||||
|
||||
private final JobConfiguration config;
|
||||
private IStepExecutor steps;
|
||||
private final JobConfiguration config
|
||||
private IStepExecutor steps
|
||||
|
||||
PublishAllure(JobConfiguration config) {
|
||||
this.config = config
|
||||
@@ -33,11 +33,14 @@ class PublishAllure implements Serializable {
|
||||
if (config.stageFlags.bdd) {
|
||||
safeUnstash('bdd-allure')
|
||||
}
|
||||
if (config.stageFlags.yaxunit) {
|
||||
safeUnstash(Yaxunit.YAXUNIT_ALLURE_STASH)
|
||||
}
|
||||
if (config.stageFlags.smoke && config.smokeTestOptions.publishToAllureReport) {
|
||||
safeUnstash(SmokeTest.SMOKE_ALLURE_STASH)
|
||||
}
|
||||
|
||||
def env = steps.env();
|
||||
def env = steps.env()
|
||||
|
||||
FilePath allurePath = FileUtils.getFilePath("$env.WORKSPACE/build/out/allure")
|
||||
if (!allurePath.exists()) {
|
||||
@@ -45,7 +48,7 @@ class PublishAllure implements Serializable {
|
||||
return
|
||||
}
|
||||
|
||||
List<String> results = new ArrayList<>();
|
||||
List<String> results = new ArrayList<>()
|
||||
|
||||
allurePath.listDirectories().each { FilePath filePath ->
|
||||
results.add(FileUtils.getLocalPath(filePath))
|
||||
|
@@ -8,14 +8,16 @@ 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'
|
||||
|
||||
private final String DEFAULT_YAXUNIT_CONFIGURATION_RESOURCE = 'yaxunit.json'
|
||||
|
||||
public static final String YAXUNIT_ALLURE_STASH = 'yaxunit-allure'
|
||||
|
||||
Yaxunit(JobConfiguration config) {
|
||||
this.config = config
|
||||
}
|
||||
@@ -39,60 +41,85 @@ class Yaxunit implements Serializable {
|
||||
def env = steps.env()
|
||||
|
||||
String vrunnerPath = VRunner.getVRunnerPath()
|
||||
String ibConnection = "--ibconnection /F./build/ib"
|
||||
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'))
|
||||
localPathToYaxunit.copyFrom(new URL(options.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"
|
||||
// Команда загрузки YAXUnit
|
||||
String loadYaxunitCommand = vrunnerPath + ' run --command "Путь=' + pathToYaxunit + ';ЗавершитьРаботуСистемы;" --execute '
|
||||
String executeParameter = '$runnerRoot/epf/ЗагрузитьРасширениеВРежимеПредприятия.epf'
|
||||
if (steps.isUnix()) {
|
||||
executeParameter = '\\' + executeParameter
|
||||
}
|
||||
loadYaxunitCommand += executeParameter
|
||||
loadYaxunitCommand += ' --ibconnection "/F./build/ib"'
|
||||
|
||||
// Создаем конфиг, т.к. в репо может быть ключ, который не закрывает программу и может повесить конвеер
|
||||
// Также путь к отчету в формате 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()))
|
||||
// Команда сборки расширений с тестами и их загрузки в ИБ
|
||||
def loadTestExtCommands = []
|
||||
for (String extension in options.extensionNames) {
|
||||
if (extension == "YAXUNIT") {
|
||||
continue
|
||||
}
|
||||
def loadTestExtCommand = "$vrunnerPath compileext ./src/cfe/$extension $extension --updatedb $ibConnection"
|
||||
loadTestExtCommands << loadTestExtCommand
|
||||
Logger.println("Команда сборки расширения: $loadTestExtCommands")
|
||||
}
|
||||
|
||||
// Запускаем тесты
|
||||
String command = "$vrunnerPath run --command RunUnitTests=$pathToConfig $ibConnection"
|
||||
String yaxunitConfigPath = options.configPath
|
||||
File yaxunitConfigFile = new File("$env.WORKSPACE/$yaxunitConfigPath")
|
||||
if (!steps.fileExists(yaxunitConfigPath)) {
|
||||
def defaultYaxunitConfig = steps.libraryResource DEFAULT_YAXUNIT_CONFIGURATION_RESOURCE
|
||||
yaxunitConfigFile.write defaultYaxunitConfig
|
||||
}
|
||||
def yaxunitConfig = yaxunitConfigFile.getCanonicalPath()
|
||||
|
||||
// Команда запуска тестов
|
||||
String command = "$vrunnerPath run --command RunUnitTests=$yaxunitConfig $ibConnection"
|
||||
|
||||
// Переопределяем настройки vrunner
|
||||
String vrunnerSettings = options.vrunnerSettings
|
||||
String[] loadTestExtCommandJoined = loadTestExtCommands
|
||||
if (steps.fileExists(vrunnerSettings)) {
|
||||
String vrunnerSettingsCommand = " --settings $vrunnerSettings"
|
||||
|
||||
command += vrunnerSettingsCommand
|
||||
loadYaxunitCommand += vrunnerSettingsCommand
|
||||
loadTestsCommand += vrunnerSettingsCommand
|
||||
|
||||
loadTestExtCommandJoined = loadTestExtCommands.collect { "$it $vrunnerSettingsCommand" }
|
||||
command += vrunnerSettingsCommand
|
||||
|
||||
}
|
||||
|
||||
// Выполяем команды
|
||||
steps.withEnv(logosConfig) {
|
||||
VRunner.exec(loadYaxunitCommand, true)
|
||||
VRunner.exec(loadTestsCommand, true)
|
||||
for (loadTestExtCommand in loadTestExtCommandJoined) {
|
||||
VRunner.exec(loadTestExtCommand, true)
|
||||
}
|
||||
VRunner.exec(command, true)
|
||||
}
|
||||
|
||||
// Сохраняем результаты
|
||||
steps.junit("$junitReportDir/*.xml", true)
|
||||
steps.archiveArtifacts("$junitReportDir/**")
|
||||
String junitReport = "./build/out/yaxunit/junit.xml"
|
||||
FilePath pathToJUnitReport = FileUtils.getFilePath("$env.WORKSPACE/$junitReport")
|
||||
String junitReportDir = FileUtils.getLocalPath(pathToJUnitReport.getParent())
|
||||
|
||||
if (options.publishToJUnitReport) {
|
||||
steps.junit("$junitReportDir/*.xml", true)
|
||||
steps.archiveArtifacts("$junitReportDir/**")
|
||||
}
|
||||
|
||||
if (options.publishToAllureReport) {
|
||||
String allureReport = "./build/out/allure/yaxunit/junit.xml"
|
||||
FilePath pathToAllureReport = FileUtils.getFilePath("$env.WORKSPACE/$allureReport")
|
||||
String allureReportDir = FileUtils.getLocalPath(pathToAllureReport.getParent())
|
||||
|
||||
pathToJUnitReport.copyTo(pathToAllureReport)
|
||||
|
||||
steps.stash(YAXUNIT_ALLURE_STASH, "$allureReportDir/**", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -253,7 +253,7 @@ void call() {
|
||||
expression { config.stageFlags.yaxunit }
|
||||
}
|
||||
steps {
|
||||
timeout(time: config.timeoutOptions.smoke, unit: TimeUnit.MINUTES) {
|
||||
timeout(time: config.timeoutOptions.yaxunit, unit: TimeUnit.MINUTES) {
|
||||
unzipInfobase()
|
||||
|
||||
yaxunit config
|
||||
|
Reference in New Issue
Block a user