You've already forked jenkins-lib
forked from jenkins/jenkins-lib
Черновая реализация запуска дымовых
This commit is contained in:
@@ -50,6 +50,11 @@
|
||||
],
|
||||
"vrunnerSettings": "./tools/vrunner.json"
|
||||
},
|
||||
"smoke": {
|
||||
"vrunnerSettings": "./tools/vrunner.json",
|
||||
"publishToAllureReport": false,
|
||||
"publishToJUnitReport": true
|
||||
},
|
||||
"resultsTransform": {
|
||||
"removeSupport": true,
|
||||
"supportLevel": 0
|
||||
|
@@ -151,6 +151,25 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"smoke" : {
|
||||
"type" : "object",
|
||||
"id" : "urn:jsonschema:ru:pulsar:jenkins:library:configuration:SmokeTestOptions",
|
||||
"description" : "Настройки дымового тестирования",
|
||||
"properties" : {
|
||||
"vrunnerSettings" : {
|
||||
"type" : "string",
|
||||
"description" : "Путь к конфигурационному файлу vanessa-runner.\n По умолчанию содержит значение \"./tools/vrunner.json\".\n "
|
||||
},
|
||||
"publishToAllureReport" : {
|
||||
"type" : "boolean",
|
||||
"description" : "Выполнять публикацию результатов в отчет Allure.\n По умолчанию выключено.\n "
|
||||
},
|
||||
"publishToJUnitReport" : {
|
||||
"type" : "boolean",
|
||||
"description" : "Выполнять публикацию результатов в отчет JUnit.\n По умолчанию включено.\n "
|
||||
}
|
||||
}
|
||||
},
|
||||
"resultsTransform" : {
|
||||
"type" : "object",
|
||||
"id" : "urn:jsonschema:ru:pulsar:jenkins:library:configuration:ResultsTransformOptions",
|
||||
|
@@ -17,6 +17,8 @@ interface IStepExecutor {
|
||||
|
||||
FileWrapper[] findFiles(String glob, String excludes)
|
||||
|
||||
String readFile(String file)
|
||||
|
||||
String readFile(String file, String encoding)
|
||||
|
||||
boolean fileExists(String file)
|
||||
@@ -73,5 +75,7 @@ interface IStepExecutor {
|
||||
|
||||
def allure(List<String> results)
|
||||
|
||||
def junit(String testResults, boolean allowEmptyResults)
|
||||
|
||||
def installLocalDependencies()
|
||||
}
|
@@ -33,7 +33,7 @@ class StepExecutor implements IStepExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
String readFile(String file, String encoding) {
|
||||
String readFile(String file, String encoding = 'UTF-8') {
|
||||
steps.readFile encoding: encoding, file: file
|
||||
}
|
||||
|
||||
@@ -174,6 +174,11 @@ class StepExecutor implements IStepExecutor {
|
||||
])
|
||||
}
|
||||
|
||||
@Override
|
||||
def junit(String testResults, boolean allowEmptyResults) {
|
||||
steps.junit testResults: testResults, allowEmptyResults: allowEmptyResults
|
||||
}
|
||||
|
||||
@Override
|
||||
def installLocalDependencies() {
|
||||
steps.installLocalDependencies()
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package ru.pulsar.jenkins.library.configuration
|
||||
|
||||
import com.cloudbees.groovy.cps.NonCPS
|
||||
import com.fasterxml.jackson.annotation.JsonEnumDefaultValue
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription
|
||||
@@ -45,6 +44,10 @@ class JobConfiguration implements Serializable {
|
||||
@JsonPropertyDescription("Настройки синтаксического контроля")
|
||||
SyntaxCheckOptions syntaxCheckOptions;
|
||||
|
||||
@JsonProperty("smoke")
|
||||
@JsonPropertyDescription("Настройки дымового тестирования")
|
||||
SmokeTestOptions smokeTestOptions;
|
||||
|
||||
@JsonProperty("resultsTransform")
|
||||
@JsonPropertyDescription("Настройки трансформации результатов анализа")
|
||||
ResultsTransformOptions resultsTransformOptions;
|
||||
@@ -67,6 +70,7 @@ class JobConfiguration implements Serializable {
|
||||
", bddOptions=" + bddOptions +
|
||||
", sonarQubeOptions=" + sonarQubeOptions +
|
||||
", syntaxCheckOptions=" + syntaxCheckOptions +
|
||||
", smokeTestOptions=" + smokeTestOptions +
|
||||
", resultsTransformOptions=" + resultsTransformOptions +
|
||||
", logosConfig=" + logosConfig +
|
||||
'}';
|
||||
|
@@ -0,0 +1,34 @@
|
||||
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 SmokeTestOptions implements Serializable {
|
||||
|
||||
@JsonPropertyDescription("""Путь к конфигурационному файлу vanessa-runner.
|
||||
По умолчанию содержит значение "./tools/vrunner.json".
|
||||
""")
|
||||
String vrunnerSettings
|
||||
|
||||
@JsonPropertyDescription("""Выполнять публикацию результатов в отчет Allure.
|
||||
По умолчанию выключено.
|
||||
""")
|
||||
boolean publishToAllureReport
|
||||
|
||||
@JsonPropertyDescription("""Выполнять публикацию результатов в отчет JUnit.
|
||||
По умолчанию включено.
|
||||
""")
|
||||
boolean publishToJUnitReport
|
||||
|
||||
@Override
|
||||
@NonCPS
|
||||
String toString() {
|
||||
return "SyntaxCheckOptions{" +
|
||||
"vrunnerSettings=" + vrunnerSettings +
|
||||
", publishToAllureReport=" + publishToAllureReport +
|
||||
", publishToJUnitReport=" + publishToJUnitReport +
|
||||
'}';
|
||||
}
|
||||
}
|
@@ -23,6 +23,9 @@ class PublishAllure implements Serializable {
|
||||
|
||||
safeUnstash('init-allure')
|
||||
safeUnstash('bdd-allure')
|
||||
if (config.smokeTestOptions.publishToAllureReport) {
|
||||
safeUnstash(SmokeTest.SMOKE_ALLURE_STASH)
|
||||
}
|
||||
|
||||
def env = steps.env();
|
||||
|
||||
@@ -47,7 +50,7 @@ class PublishAllure implements Serializable {
|
||||
private void safeUnstash(String stashName) {
|
||||
try {
|
||||
steps.unstash(stashName)
|
||||
} catch (Exception ex) {
|
||||
} catch (Exception ignored) {
|
||||
Logger.println("Can't unstash $stashName")
|
||||
}
|
||||
}
|
||||
|
98
src/ru/pulsar/jenkins/library/steps/SmokeTest.groovy
Normal file
98
src/ru/pulsar/jenkins/library/steps/SmokeTest.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
|
||||
|
||||
class SmokeTest implements Serializable {
|
||||
|
||||
public static final String SMOKE_ALLURE_STASH = 'smoke-allure'
|
||||
|
||||
private final JobConfiguration config;
|
||||
|
||||
SmokeTest(JobConfiguration config) {
|
||||
this.config = config
|
||||
}
|
||||
|
||||
def run() {
|
||||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||
|
||||
Logger.printLocation()
|
||||
|
||||
if (!config.stageFlags.smoke) {
|
||||
Logger.println("Smoke test step is disabled")
|
||||
return
|
||||
}
|
||||
|
||||
List<String> logosConfig = ["LOGOS_CONFIG=$config.logosConfig"]
|
||||
steps.withEnv(logosConfig) {
|
||||
steps.installLocalDependencies()
|
||||
}
|
||||
|
||||
def options = config.smokeTestOptions
|
||||
def env = steps.env()
|
||||
|
||||
String vrunnerPath = VRunner.getVRunnerPath()
|
||||
String command = "$vrunnerPath xunit --ibconnection \"/F./build/ib\""
|
||||
|
||||
String vrunnerSettings = options.vrunnerSettings
|
||||
if (steps.fileExists(vrunnerSettings)) {
|
||||
command += " --settings $vrunnerSettings";
|
||||
}
|
||||
|
||||
String xddTestRunnerPath = "./oscript_modules/add/xddTestRunner.epf"
|
||||
if (steps.fileExists(xddTestRunnerPath)) {
|
||||
command += " --pathxunit $xddTestRunnerPath"
|
||||
}
|
||||
|
||||
String xddConfigPath = "./tools/xUnitParams.json"
|
||||
if (steps.fileExists(xddConfigPath)) {
|
||||
command += " --xddConfig $xddConfigPath"
|
||||
}
|
||||
|
||||
String junitReport = "build/out/jUnit/smoke/smoke.xml"
|
||||
FilePath pathToJUnitReport = FileUtils.getFilePath("$env.WORKSPACE/$junitReport")
|
||||
String junitReportDir = FileUtils.getLocalPath(pathToJUnitReport.getParent())
|
||||
|
||||
steps.createDir(junitReportDir)
|
||||
|
||||
String allureReport = "build/out/allure/smoke/allure.xml"
|
||||
FilePath pathToAllureReport = FileUtils.getFilePath("$env.WORKSPACE/$allureReport")
|
||||
String allureReportDir = FileUtils.getLocalPath(pathToAllureReport.getParent())
|
||||
|
||||
steps.createDir(allureReportDir)
|
||||
|
||||
command += " --reportsxunit \"ГенераторОтчетаJUnitXML{$junitReport};ГенераторОтчетаAllureXMLВерсия2{$allureReport}\""
|
||||
if (steps.isUnix()) {
|
||||
command = command.replace(';', '\\;')
|
||||
}
|
||||
|
||||
if (!VRunner.configContainsSetting(vrunnerSettings, "testsPath")) {
|
||||
String testsPath = "oscript_modules/add/tests/smoke"
|
||||
if (!steps.fileExists(testsPath)) {
|
||||
testsPath = '$addRoot/tests/smoke'
|
||||
if (steps.isUnix()) {
|
||||
testsPath = '\\' + testsPath
|
||||
}
|
||||
}
|
||||
command += " $testsPath"
|
||||
}
|
||||
|
||||
steps.withEnv(logosConfig) {
|
||||
VRunner.exec(command)
|
||||
}
|
||||
|
||||
steps.stash(SMOKE_ALLURE_STASH, "$allureReportDir/**", true)
|
||||
|
||||
if (options.publishToJUnitReport) {
|
||||
steps.junit("$junitReportDir/*.xml", true)
|
||||
}
|
||||
|
||||
steps.archiveArtifacts("$junitReportDir/**")
|
||||
steps.archiveArtifacts("$allureReportDir/**")
|
||||
}
|
||||
}
|
@@ -27,4 +27,11 @@ class VRunner {
|
||||
return steps.cmd(command, returnStatus)
|
||||
} as int
|
||||
}
|
||||
|
||||
static boolean configContainsSetting(String configPath, String settingName) {
|
||||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||
|
||||
String fileContent = steps.readFile(configPath)
|
||||
return fileContent.contains("\"$settingName\"")
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ class VersionParser implements Serializable {
|
||||
return ""
|
||||
}
|
||||
|
||||
def configurationText = steps.readFile(filePath, 'UTF-8');
|
||||
def configurationText = steps.readFile(filePath);
|
||||
return version(configurationText, regexp)
|
||||
}
|
||||
|
||||
|
@@ -183,6 +183,8 @@ void call() {
|
||||
expression { config.stageFlags.smoke }
|
||||
}
|
||||
steps {
|
||||
unzipInfobase()
|
||||
|
||||
smoke config
|
||||
}
|
||||
}
|
||||
|
@@ -1,23 +1,12 @@
|
||||
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||
import ru.pulsar.jenkins.library.steps.SmokeTest
|
||||
|
||||
def call(JobConfiguration config) {
|
||||
|
||||
ContextRegistry.registerDefaultContext(this)
|
||||
|
||||
// TODO: Вынести в отдельный класс по аналогии с SonarScanner
|
||||
|
||||
printLocation()
|
||||
|
||||
if (!config.stageFlags.smoke) {
|
||||
echo("Smoke tests step is disabled")
|
||||
return
|
||||
}
|
||||
|
||||
def options = config.syntaxCheckOptions
|
||||
|
||||
installLocalDependencies()
|
||||
|
||||
unzipInfobase()
|
||||
def smokeTest = new SmokeTest(config)
|
||||
smokeTest.run()
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user