From 2ed7b85682ef6d4d52445b7af4b33f7f8ac1f20b Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Thu, 12 Sep 2024 14:12:06 +0200 Subject: [PATCH 01/18] Extend/Update documentation (#164) --- README.md | 14 ++++++++++++++ .../configs/TestConfig/config.jelly | 1 + .../configs/TestConfig/config.properties | 6 ++++++ 3 files changed, 21 insertions(+) diff --git a/README.md b/README.md index a81b25c3..23cdb157 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,20 @@ node('windows') { } } ``` +#### Further Information + +The `testConfig` parameter consists of both the **Test Configuration** (`.tcf`) and **Test Bench Configuration** (`.tbc`) files. These files are essential for defining test settings in ecu.test. + +- **New Configurations**: Both `.tbc` and `.tcf` files must be explicitly set whenever a new configuration is needed. + +- **KEEP Option**: The `KEEP` option prevents reloading new configurations and keeps the currently active ones. +This feature is considered **advanced** and is not recommended for most use cases. +`KEEP` must always be set for both configurations and no constants may be set. + +- **Unload Configurations**: Keeping values empty, such as `[tbcPath: '', tcfPath: '']` will unload the configuration. +Providing an invalid data type for `testConfig` (e.g., an empty list) will result in an error and halt the pipeline execution. + +- **Force Reload**: In ecu.test versions prior to 2023.4, setting `forceConfigurationReload` to `true` forces a configuration reload, even if the same configuration is still active. The [test.guide](https://www.tracetronic.com/products/test-guide/) authentication key has to be set as a Jenkins [credential](https://www.jenkins.io/doc/book/using/using-credentials/) (username and password) to be used in the diff --git a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly index 71b3b155..be71ba08 100644 --- a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly +++ b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly @@ -1,6 +1,7 @@ + ${%configSection.description} diff --git a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties index cd75f49f..b59885d1 100644 --- a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties +++ b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties @@ -1,4 +1,6 @@ configSection.title=Test Configuration +configSection.description=Both the Test Bench Configuration and Test Configuration must be provided to load new configurations. \ + For invalid data types, such as testConfig: [], an Error will be thrown. constants.add=Add Global Constant constants.description=The configured global constants remain available throughout the entire test execution. constants.title=Global Constants @@ -9,9 +11,13 @@ packageParameters.description=Parameters for package execution. packageParameters.title=Package Parameters tbcPath.description=The relative path of the .tbc file in the Configurations directory to be started for this execution. \ Use "KEEP" to use the currently loaded test bench configuration. \ + The "KEEP" option is considered advanced and not recommended for typical use cases. \ + "KEEP" must always be set for both configurations. \ If empty, no test bench configuration will be loaded. tbcPath.title=Test Bench Configuration tcfPath.description=The relative path of the .tcf file in the Configurations directory to be started for this execution. \ Use "KEEP" to use the currently loaded test configuration. \ + The "KEEP" option is considered advanced and not recommended for typical use cases. \ + "KEEP" must always be set for both configurations. \ If empty, no test configuration will be loaded. tcfPath.title=Test Configuration From d192cf9df1ebe9ff7478f9db3b14b35a8d2a57a7 Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Thu, 12 Sep 2024 14:12:28 +0200 Subject: [PATCH 02/18] Extend tests (#164) --- .../steps/RunPackageStepIT.groovy | 48 ++++++++++++++ .../steps/RunProjectStepIT.groovy | 47 ++++++++++++++ .../steps/RunTestFolderStepIT.groovy | 64 +++++++++++++++++++ 3 files changed, 159 insertions(+) diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy index 15c78c3f..681fdfeb 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy @@ -167,6 +167,54 @@ class RunPackageStepIT extends IntegrationTestBase { jenkins.assertLogContains("Executing package 'test.pkg'", run) } + def 'Run pipeline by declaring .tbc and .tcf files in testConfig'() { + given: + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', testConfig: [tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) + + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + + expect: + WorkflowRun run = job.scheduleBuild2(0).get() + jenkins.assertLogContains("Executing package 'test.pkg'...", run) + jenkins.assertLogContains("-> With TBC=test.tbc", run) + jenkins.assertLogContains("-> With TCF=test.tcf", run) + } + + def 'Run pipeline by declaring KEEP in testConfig'() { + given: + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', testConfig: [tbcPath: 'KEEP', tcfPath: 'KEEP'] }", true)) + + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + + expect: + WorkflowRun run = job.scheduleBuild2(0).get() + jenkins.assertLogContains("Executing package 'test.pkg'...", run) + jenkins.assertLogContains("-> With TBC=KEEP", run) + jenkins.assertLogContains("-> With TCF=KEEP", run) + + } + + def 'Run pipeline with invalid data type for testConfig'() { + given: + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', testConfig: [] }", true)) + + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + + expect: + WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) + jenkins.assertLogContains("java.lang.ClassCastException", run) + jenkins.assertLogContains("expects class " + + "de.tracetronic.jenkins.plugins.ecutestexecution.configs.TestConfig", run) + jenkins.assertLogContains("but received class java.util.ArrayList", run) + } + + def 'Run pipeline with package check'(){ given: GroovyMock(RestApiClientFactory, global: true) diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy index 8b4bfd6e..1bc8eaae 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy @@ -115,6 +115,53 @@ class RunProjectStepIT extends IntegrationTestBase { jenkins.assertLogContains("Executing project 'test.prj'", run) } + def 'Run pipeline by declaring .tbc and .tcf files in testConfig'() { + given: + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', testConfig: [tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) + + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + + expect: + WorkflowRun run = job.scheduleBuild2(0).get() + jenkins.assertLogContains("Executing project 'test.prj'...", run) + jenkins.assertLogContains("-> With TBC=test.tbc", run) + jenkins.assertLogContains("-> With TCF=test.tcf", run) + } + + def 'Run pipeline by declaring KEEP in testConfig'() { + given: + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', testConfig: [tbcPath: 'KEEP', tcfPath: 'KEEP'] }", true)) + + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + + expect: + WorkflowRun run = job.scheduleBuild2(0).get() + jenkins.assertLogContains("Executing project 'test.prj'...", run) + jenkins.assertLogContains("-> With TBC=KEEP", run) + jenkins.assertLogContains("-> With TCF=KEEP", run) + + } + + def 'Run pipeline with invalid data type for testConfig'() { + given: + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', testConfig: [] }", true)) + + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + + expect: + WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) + jenkins.assertLogContains("java.lang.ClassCastException", run) + jenkins.assertLogContains("expects class " + + "de.tracetronic.jenkins.plugins.ecutestexecution.configs.TestConfig", run) + jenkins.assertLogContains("but received class java.util.ArrayList", run) + } + def 'Run pipeline with package check'() { given: GroovyMock(RestApiClientFactory, global: true) diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy index aa930295..4f0976fa 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy @@ -189,6 +189,70 @@ class RunTestFolderStepIT extends IntegrationTestBase { jenkins.assertLogContains("Executing package '${testPackage.getAbsolutePath()}'", run) } + def 'Run pipeline by declaring .tbc and .tcf files in testConfig'() { + given: + setupTestFolder() + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition( + "node { ttRunTestFolder recursiveScan: true, " + + "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'" + + ", testConfig: [tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", + true)) + + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + expect: + WorkflowRun run = job.scheduleBuild2(0).get() + jenkins.assertLogContains('Found 3 package(s)', run) + jenkins.assertLogContains('Found 3 project(s)', run) + jenkins.assertLogContains("Executing package '${subPackage.getAbsolutePath()}'", run) + jenkins.assertLogContains("-> With TBC=test.tbc", run) + jenkins.assertLogContains("-> With TCF=test.tcf", run) + } + + def 'Run pipeline by declaring KEEP in testConfig'() { + given: + setupTestFolder() + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition( + "node { ttRunTestFolder recursiveScan: true, " + + "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'" + + ", testConfig: [tbcPath: 'KEEP', tcfPath: 'KEEP'] }", + true)) + + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + + expect: + WorkflowRun run = job.scheduleBuild2(0).get() + jenkins.assertLogContains('Found 3 package(s)', run) + jenkins.assertLogContains('Found 3 project(s)', run) + jenkins.assertLogContains("Executing package '${subPackage.getAbsolutePath()}'", run) + jenkins.assertLogContains("-> With TBC=KEEP", run) + jenkins.assertLogContains("-> With TCF=KEEP", run) + } + + def 'Run pipeline with invalid data type for testConfig'() { + given: + setupTestFolder() + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition( + "node { ttRunTestFolder recursiveScan: true, " + + "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'" + + ", testConfig: [] }", + true)) + + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + + expect: + WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) + jenkins.assertLogContains("java.lang.ClassCastException", run) + jenkins.assertLogContains("expects class " + + "de.tracetronic.jenkins.plugins.ecutestexecution.configs.TestConfig", run) + jenkins.assertLogContains("but received class java.util.ArrayList", run) + } + def 'Run recursive scan pipeline'() { given: setupTestFolder() From d37e06c7848719657aff4f48a2695bb19c258fa9 Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Fri, 13 Sep 2024 08:43:02 +0200 Subject: [PATCH 03/18] Format tests and provide ref link in README (#164) --- README.md | 21 +++----- .../steps/RunPackageStepIT.groovy | 19 ++++--- .../steps/RunProjectStepIT.groovy | 53 ++++++++++--------- .../steps/RunTestFolderStepIT.groovy | 28 +++++----- 4 files changed, 61 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 23cdb157..4b9f0e3a 100644 --- a/README.md +++ b/README.md @@ -86,10 +86,7 @@ node('windows') { ttRunPackage testCasePath: 'sample.pkg', testConfig: [tbcPath: '', tcfPath: '', forceConfigurationReload: true, constants: [[label: 'sample', value: '\'sampleValue\'']]] } stage('Provide ecu.test logs in jenkins') { - ttProvideLogs(publishConfig: [allowMissing: true, timeout: 10, keepAll: true]) - } - stage('Provide ecu.test trf/prf reports in jenkins') { - ttProvideReports(publishConfig: [allowMissing: true, timeout: 10, keepAll: true]) + ttProvideLogs timeout: 60 } stage('Generate Reports') { ttGenerateReports 'HTML' @@ -121,7 +118,7 @@ The [test.guide](https://www.tracetronic.com/products/test-guide/) authenticatio [credential](https://www.jenkins.io/doc/book/using/using-credentials/) (username and password) to be used in the *ttUploadReports* step. -Check out the [advanced usage docs](./docs/AdvancedUsage.md) for more detailed information +Check out the [advanced usage doc](./docs/AdvancedUsage.md) for more information. ## Migration @@ -158,8 +155,7 @@ create an [issue](#contribution). trace.check compat matrix (min 2022.4) | Version | latest - 3.5 | 3.4 - 3.1 | 3.0 | -|---------|:------------------:|:------------------:|:------------------:| -| 2024.3 | :heavy_check_mark: | :x: | :x: | +|:-------:|:------------------:|:------------------:|:------------------:| | 2024.2 | :heavy_check_mark: | :x: | :x: | | 2024.1 | :heavy_check_mark: | :heavy_check_mark: | :x: | | 2023.4 | :heavy_check_mark: | :heavy_check_mark: | :x: | @@ -172,13 +168,12 @@ create an [issue](#contribution).
- optional: test.guide compat matrix (min 1.142.0) + optional: test.guide compat matrix (min 1.114.3) -| Version | latest - 3.6 | 3.5 - 3.0 | -|---------|--------------------|:------------------:| -| 1.178.0 | :heavy_check_mark: | :heavy_check_mark: | -| 1.147.0 | :x: | :heavy_check_mark: | -| 1.142.0 | :x: | :heavy_check_mark: | +| Version | latest - 3.0 | +|:-------:|:------------------:| +| 1.147.0 | :heavy_check_mark: | +| 1.142.0 | :heavy_check_mark: |
diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy index 681fdfeb..02e85ea5 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy @@ -170,10 +170,11 @@ class RunPackageStepIT extends IntegrationTestBase { def 'Run pipeline by declaring .tbc and .tcf files in testConfig'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', testConfig: [tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', " + + "testConfig: [tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) - GroovyMock(RestApiClientFactory, global: true) - RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() expect: WorkflowRun run = job.scheduleBuild2(0).get() @@ -185,7 +186,8 @@ class RunPackageStepIT extends IntegrationTestBase { def 'Run pipeline by declaring KEEP in testConfig'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', testConfig: [tbcPath: 'KEEP', tcfPath: 'KEEP'] }", true)) + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', " + + "testConfig: [tbcPath: 'KEEP', tcfPath: 'KEEP'] }", true)) GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() @@ -200,11 +202,12 @@ class RunPackageStepIT extends IntegrationTestBase { def 'Run pipeline with invalid data type for testConfig'() { given: - WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', testConfig: [] }", true)) + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', " + + "testConfig: [] }", true)) - GroovyMock(RestApiClientFactory, global: true) - RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() expect: WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy index 1bc8eaae..f8c7a378 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy @@ -117,49 +117,52 @@ class RunProjectStepIT extends IntegrationTestBase { def 'Run pipeline by declaring .tbc and .tcf files in testConfig'() { given: - WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', testConfig: [tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', " + + "testConfig: [tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) - GroovyMock(RestApiClientFactory, global: true) - RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() expect: - WorkflowRun run = job.scheduleBuild2(0).get() - jenkins.assertLogContains("Executing project 'test.prj'...", run) - jenkins.assertLogContains("-> With TBC=test.tbc", run) - jenkins.assertLogContains("-> With TCF=test.tcf", run) + WorkflowRun run = job.scheduleBuild2(0).get() + jenkins.assertLogContains("Executing project 'test.prj'...", run) + jenkins.assertLogContains("-> With TBC=test.tbc", run) + jenkins.assertLogContains("-> With TCF=test.tcf", run) } def 'Run pipeline by declaring KEEP in testConfig'() { given: - WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', testConfig: [tbcPath: 'KEEP', tcfPath: 'KEEP'] }", true)) + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', " + + "testConfig: [tbcPath: 'KEEP', tcfPath: 'KEEP'] }", true)) - GroovyMock(RestApiClientFactory, global: true) - RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() expect: - WorkflowRun run = job.scheduleBuild2(0).get() - jenkins.assertLogContains("Executing project 'test.prj'...", run) - jenkins.assertLogContains("-> With TBC=KEEP", run) - jenkins.assertLogContains("-> With TCF=KEEP", run) + WorkflowRun run = job.scheduleBuild2(0).get() + jenkins.assertLogContains("Executing project 'test.prj'...", run) + jenkins.assertLogContains("-> With TBC=KEEP", run) + jenkins.assertLogContains("-> With TCF=KEEP", run) } def 'Run pipeline with invalid data type for testConfig'() { given: - WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', testConfig: [] }", true)) + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', " + + "testConfig: [] }", true)) - GroovyMock(RestApiClientFactory, global: true) - RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() expect: - WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) - jenkins.assertLogContains("java.lang.ClassCastException", run) - jenkins.assertLogContains("expects class " + - "de.tracetronic.jenkins.plugins.ecutestexecution.configs.TestConfig", run) - jenkins.assertLogContains("but received class java.util.ArrayList", run) + WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) + jenkins.assertLogContains("java.lang.ClassCastException", run) + jenkins.assertLogContains("expects class " + + "de.tracetronic.jenkins.plugins.ecutestexecution.configs.TestConfig", run) + jenkins.assertLogContains("but received class java.util.ArrayList", run) } def 'Run pipeline with package check'() { diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy index 4f0976fa..824d09dd 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy @@ -234,23 +234,23 @@ class RunTestFolderStepIT extends IntegrationTestBase { def 'Run pipeline with invalid data type for testConfig'() { given: - setupTestFolder() - WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition( - "node { ttRunTestFolder recursiveScan: true, " + - "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'" + - ", testConfig: [] }", - true)) + setupTestFolder() + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition( + "node { ttRunTestFolder recursiveScan: true, " + + "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'" + + ", testConfig: [] }", + true)) - GroovyMock(RestApiClientFactory, global: true) - RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + GroovyMock(RestApiClientFactory, global: true) + RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() expect: - WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) - jenkins.assertLogContains("java.lang.ClassCastException", run) - jenkins.assertLogContains("expects class " + - "de.tracetronic.jenkins.plugins.ecutestexecution.configs.TestConfig", run) - jenkins.assertLogContains("but received class java.util.ArrayList", run) + WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) + jenkins.assertLogContains("java.lang.ClassCastException", run) + jenkins.assertLogContains("expects class " + + "de.tracetronic.jenkins.plugins.ecutestexecution.configs.TestConfig", run) + jenkins.assertLogContains("but received class java.util.ArrayList", run) } def 'Run recursive scan pipeline'() { From 48a65296e2103f219b5cc85c4dbd3b82d9598420 Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Fri, 4 Oct 2024 12:26:56 +0200 Subject: [PATCH 04/18] Remove outdated advanced doc (#164) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b9f0e3a..b3b3d5f6 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ The [test.guide](https://www.tracetronic.com/products/test-guide/) authenticatio [credential](https://www.jenkins.io/doc/book/using/using-credentials/) (username and password) to be used in the *ttUploadReports* step. -Check out the [advanced usage doc](./docs/AdvancedUsage.md) for more information. +Check out the [advanced usage docs](./docs/AdvancedUsage.md) for more detailed information ## Migration From 14e6efb8cfdefe14f4d5d1409c5dc0e017c75023 Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Fri, 4 Oct 2024 12:34:41 +0200 Subject: [PATCH 05/18] Sync README with main (#164) --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b3b3d5f6..2d3034b3 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,10 @@ node('windows') { ttRunPackage testCasePath: 'sample.pkg', testConfig: [tbcPath: '', tcfPath: '', forceConfigurationReload: true, constants: [[label: 'sample', value: '\'sampleValue\'']]] } stage('Provide ecu.test logs in jenkins') { - ttProvideLogs timeout: 60 + ttProvideLogs(publishConfig: [allowMissing: true, timeout: 10, keepAll: true]) + } + stage('Provide ecu.test trf/prf reports in jenkins') { + ttProvideReports(publishConfig: [allowMissing: true, timeout: 10, keepAll: true]) } stage('Generate Reports') { ttGenerateReports 'HTML' From 545030494ffb15d3c999d906b90ad56f6e82914a Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Fri, 4 Oct 2024 12:42:44 +0200 Subject: [PATCH 06/18] Update README with main (#164) --- README.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2d3034b3..29cd036c 100644 --- a/README.md +++ b/README.md @@ -108,12 +108,12 @@ The `testConfig` parameter consists of both the **Test Configuration** (`.tcf`) - **New Configurations**: Both `.tbc` and `.tcf` files must be explicitly set whenever a new configuration is needed. -- **KEEP Option**: The `KEEP` option prevents reloading new configurations and keeps the currently active ones. -This feature is considered **advanced** and is not recommended for most use cases. -`KEEP` must always be set for both configurations and no constants may be set. +- **KEEP Option**: The `KEEP` option prevents reloading new configurations and keeps the currently active ones. + This feature is considered **advanced** and is not recommended for most use cases. + `KEEP` must always be set for both configurations and no constants may be set. - **Unload Configurations**: Keeping values empty, such as `[tbcPath: '', tcfPath: '']` will unload the configuration. -Providing an invalid data type for `testConfig` (e.g., an empty list) will result in an error and halt the pipeline execution. + Providing an invalid data type for `testConfig` (e.g., an empty list) will result in an error and halt the pipeline execution. - **Force Reload**: In ecu.test versions prior to 2023.4, setting `forceConfigurationReload` to `true` forces a configuration reload, even if the same configuration is still active. @@ -158,7 +158,8 @@ create an [issue](#contribution). trace.check compat matrix (min 2022.4) | Version | latest - 3.5 | 3.4 - 3.1 | 3.0 | -|:-------:|:------------------:|:------------------:|:------------------:| +|---------|:------------------:|:------------------:|:------------------:| +| 2024.3 | :heavy_check_mark: | :x: | :x: | | 2024.2 | :heavy_check_mark: | :x: | :x: | | 2024.1 | :heavy_check_mark: | :heavy_check_mark: | :x: | | 2023.4 | :heavy_check_mark: | :heavy_check_mark: | :x: | @@ -171,12 +172,13 @@ create an [issue](#contribution).
- optional: test.guide compat matrix (min 1.114.3) + optional: test.guide compat matrix (min 1.142.0) -| Version | latest - 3.0 | -|:-------:|:------------------:| -| 1.147.0 | :heavy_check_mark: | -| 1.142.0 | :heavy_check_mark: | +| Version | latest - 3.6 | 3.5 - 3.0 | +|---------|--------------------|:------------------:| +| 1.178.0 | :heavy_check_mark: | :heavy_check_mark: | +| 1.147.0 | :x: | :heavy_check_mark: | +| 1.142.0 | :x: | :heavy_check_mark: |
From 9620818b56982c7b0e07618e487543ca46aaf3c6 Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Mon, 7 Oct 2024 09:18:03 +0200 Subject: [PATCH 07/18] Move testconfig related information from README to advancedUsage (#164) --- README.md | 14 -------------- docs/AdvancedUsage.md | 13 +++++++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 29cd036c..a81b25c3 100644 --- a/README.md +++ b/README.md @@ -102,20 +102,6 @@ node('windows') { } } ``` -#### Further Information - -The `testConfig` parameter consists of both the **Test Configuration** (`.tcf`) and **Test Bench Configuration** (`.tbc`) files. These files are essential for defining test settings in ecu.test. - -- **New Configurations**: Both `.tbc` and `.tcf` files must be explicitly set whenever a new configuration is needed. - -- **KEEP Option**: The `KEEP` option prevents reloading new configurations and keeps the currently active ones. - This feature is considered **advanced** and is not recommended for most use cases. - `KEEP` must always be set for both configurations and no constants may be set. - -- **Unload Configurations**: Keeping values empty, such as `[tbcPath: '', tcfPath: '']` will unload the configuration. - Providing an invalid data type for `testConfig` (e.g., an empty list) will result in an error and halt the pipeline execution. - -- **Force Reload**: In ecu.test versions prior to 2023.4, setting `forceConfigurationReload` to `true` forces a configuration reload, even if the same configuration is still active. The [test.guide](https://www.tracetronic.com/products/test-guide/) authentication key has to be set as a Jenkins [credential](https://www.jenkins.io/doc/book/using/using-credentials/) (username and password) to be used in the diff --git a/docs/AdvancedUsage.md b/docs/AdvancedUsage.md index b25e4a8c..d4f64f9c 100644 --- a/docs/AdvancedUsage.md +++ b/docs/AdvancedUsage.md @@ -98,6 +98,19 @@ node { | **forceConfigurationReload**: boolean | false | If true, always reload the configuration even if the same one is still active. Hint: This flag is only required for ecu.test versions less than 2023.4! | | **constants**: List\<[Constant](#constant)> | [] | The configured global constants remain available throughout the entire test execution. | +### Configuration Change Options + +- **New Configurations**: Both `.tbc` and `.tcf` files must be explicitly set whenever a new configuration is needed. + +- **KEEP Option**: The `KEEP` option prevents reloading new configurations and keeps the currently active ones. + This feature is considered **advanced** and is not recommended for most use cases. + `KEEP` must always be set for both configurations and no constants may be set. + +- **Unload Configurations**: Keeping values empty, such as `[tbcPath: '', tcfPath: '']` will unload the configuration. + Providing an invalid data type for `testConfig` (e.g., an empty list) will result in an error and halt the pipeline execution. + +- **Force Reload**: In ecu.test versions prior to 2023.4, setting `forceConfigurationReload` to `true` forces a configuration reload, even if the same configuration is still active. + ## PublishConfig | Properties | Default Value | Description | From 0ec2e3f6b6bed4fe79962d4baa4a9d0d1f1dd8de Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Mon, 21 Oct 2024 10:11:19 +0200 Subject: [PATCH 08/18] Add review notes (#164) - remove keep - ajust jelly, avdanvedDocs, and tests --- docs/AdvancedUsage.md | 23 +++++-------- .../configs/TestConfig.groovy | 4 +++ .../util/ValidationUtil.groovy | 4 +-- .../configs/TestConfig/config.jelly | 32 +++++++++++-------- .../configs/TestConfig/config.properties | 11 ++----- .../steps/RunPackageStepIT.groovy | 25 ++------------- .../steps/RunProjectStepIT.groovy | 24 ++------------ .../steps/RunTestFolderStepIT.groovy | 27 ++-------------- .../util/ValidationUtilTest.groovy | 2 -- 9 files changed, 41 insertions(+), 111 deletions(-) diff --git a/docs/AdvancedUsage.md b/docs/AdvancedUsage.md index d4f64f9c..11065d66 100644 --- a/docs/AdvancedUsage.md +++ b/docs/AdvancedUsage.md @@ -91,25 +91,18 @@ node { ## TestConfig -| Properties | Default Value | Description | -|----------------------------------------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **tbcPath**: String | '' | The relative path of the .tbc file in the Configurations directory to be started for this execution. Use "KEEP" to use the currently loaded test bench configuration. If empty, no test bench configuration will be loaded. | -| **tcfPath**: String | '' | The relative path of the .tcf file in the Configurations directory to be started for this execution. Use "KEEP" to use the currently loaded test configuration. If empty, no test configuration will be loaded. | -| **forceConfigurationReload**: boolean | false | If true, always reload the configuration even if the same one is still active. Hint: This flag is only required for ecu.test versions less than 2023.4! | -| **constants**: List\<[Constant](#constant)> | [] | The configured global constants remain available throughout the entire test execution. | +| Properties | Default Value | Description | +|----------------------------------------------|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **tbcPath**: String | '' | The relative path of the .tbc file in the Configurations directory to be started for this execution. If empty, no test bench configuration will be loaded. | +| **tcfPath**: String | '' | The relative path of the .tcf file in the Configurations directory to be started for this execution. If empty, no test configuration will be loaded. | +| **forceConfigurationReload**: boolean | false | If true, always reload the configuration even if the same one is still active. Hint: This flag is only required for ecu.test versions less than 2023.4! | +| **constants**: List\<[Constant](#constant)> | [] | The configured global constants remain available throughout the entire test execution. | ### Configuration Change Options -- **New Configurations**: Both `.tbc` and `.tcf` files must be explicitly set whenever a new configuration is needed. - -- **KEEP Option**: The `KEEP` option prevents reloading new configurations and keeps the currently active ones. - This feature is considered **advanced** and is not recommended for most use cases. - `KEEP` must always be set for both configurations and no constants may be set. - +- **Load Configuration**: Both `.tbc` and `.tcf` files must be explicitly set whenever a new configuration is needed. +- **Keep Configuration**: In ecu.test versions prior to 2023.4, setting `forceConfigurationReload` to `true` forces a configuration reload, even if the same configuration is still active. - **Unload Configurations**: Keeping values empty, such as `[tbcPath: '', tcfPath: '']` will unload the configuration. - Providing an invalid data type for `testConfig` (e.g., an empty list) will result in an error and halt the pipeline execution. - -- **Force Reload**: In ecu.test versions prior to 2023.4, setting `forceConfigurationReload` to `true` forces a configuration reload, even if the same configuration is still active. ## PublishConfig diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy index 1bce7628..b367fd6c 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy @@ -12,7 +12,11 @@ import hudson.Extension import hudson.model.AbstractDescribableImpl import hudson.model.Descriptor import hudson.util.FormValidation +import net.sf.json.JSONObject import org.apache.commons.lang.StringUtils +import org.jinterop.dcom.test.Test +import org.kohsuke.stapler.Stapler +import org.kohsuke.stapler.StaplerRequest import org.kohsuke.stapler.DataBoundConstructor import org.kohsuke.stapler.DataBoundSetter import org.kohsuke.stapler.QueryParameter diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtil.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtil.groovy index da36ac0f..2611895e 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtil.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtil.groovy @@ -57,9 +57,9 @@ class ValidationUtil { static validateConfigFile(String configFilePath, String fileExtension) { FormValidation returnValue = validateParameterizedValue(configFilePath, false) if (returnValue == FormValidation.ok() && !StringUtils.isEmpty(configFilePath)) { - if (!configFilePath.endsWith(fileExtension) && (configFilePath != 'KEEP')) { + if (!configFilePath.endsWith(fileExtension)) { returnValue = FormValidation.error( - "${configFilePath} has to be empty, either of file type ${fileExtension} or \"KEEP\".") + "${configFilePath} has to be empty or of file type ${fileExtension}.") } } return returnValue diff --git a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly index be71ba08..294d132a 100644 --- a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly +++ b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly @@ -2,20 +2,24 @@ ${%configSection.description} - - - - - - - - - - - - + + + - + + + + + + + + + + + + + + diff --git a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties index b59885d1..ac048d0c 100644 --- a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties +++ b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties @@ -1,6 +1,7 @@ configSection.title=Test Configuration -configSection.description=Both the Test Bench Configuration and Test Configuration must be provided to load new configurations. \ - For invalid data types, such as testConfig: [], an Error will be thrown. +configSection.description=It is recommended to choose one of the following options:

\ +
  • Load Configuration: Both the Test Bench Configuration and Test Configuration must be provided to load new configurations.
  • \ +
  • Keep Configuration: Enabling this option retains the existing configuration for continued use throughout the execution.
  • constants.add=Add Global Constant constants.description=The configured global constants remain available throughout the entire test execution. constants.title=Global Constants @@ -10,14 +11,8 @@ packageParameters.add=Add Package Parameter packageParameters.description=Parameters for package execution. packageParameters.title=Package Parameters tbcPath.description=The relative path of the .tbc file in the Configurations directory to be started for this execution. \ - Use "KEEP" to use the currently loaded test bench configuration. \ - The "KEEP" option is considered advanced and not recommended for typical use cases. \ - "KEEP" must always be set for both configurations. \ If empty, no test bench configuration will be loaded. tbcPath.title=Test Bench Configuration tcfPath.description=The relative path of the .tcf file in the Configurations directory to be started for this execution. \ - Use "KEEP" to use the currently loaded test configuration. \ - The "KEEP" option is considered advanced and not recommended for typical use cases. \ - "KEEP" must always be set for both configurations. \ If empty, no test configuration will be loaded. tcfPath.title=Test Configuration diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy index 02e85ea5..342efec5 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy @@ -183,11 +183,11 @@ class RunPackageStepIT extends IntegrationTestBase { jenkins.assertLogContains("-> With TCF=test.tcf", run) } - def 'Run pipeline by declaring KEEP in testConfig'() { + def 'Run pipeline by forcing configuration to reload in testConfig'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', " + - "testConfig: [tbcPath: 'KEEP', tcfPath: 'KEEP'] }", true)) + "testConfig: [forceConfigurationReload: true] }", true)) GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() @@ -195,29 +195,8 @@ class RunPackageStepIT extends IntegrationTestBase { expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains("Executing package 'test.pkg'...", run) - jenkins.assertLogContains("-> With TBC=KEEP", run) - jenkins.assertLogContains("-> With TCF=KEEP", run) - } - def 'Run pipeline with invalid data type for testConfig'() { - given: - WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', " + - "testConfig: [] }", true)) - - GroovyMock(RestApiClientFactory, global: true) - RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() - - expect: - WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) - jenkins.assertLogContains("java.lang.ClassCastException", run) - jenkins.assertLogContains("expects class " + - "de.tracetronic.jenkins.plugins.ecutestexecution.configs.TestConfig", run) - jenkins.assertLogContains("but received class java.util.ArrayList", run) - } - - def 'Run pipeline with package check'(){ given: GroovyMock(RestApiClientFactory, global: true) diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy index f8c7a378..e9cbdb48 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy @@ -131,11 +131,11 @@ class RunProjectStepIT extends IntegrationTestBase { jenkins.assertLogContains("-> With TCF=test.tcf", run) } - def 'Run pipeline by declaring KEEP in testConfig'() { + def 'Run pipeline by forcing configuration to reload in testConfig'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', " + - "testConfig: [tbcPath: 'KEEP', tcfPath: 'KEEP'] }", true)) + "testConfig: [forceConfigurationReload: true] }", true)) GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() @@ -143,26 +143,6 @@ class RunProjectStepIT extends IntegrationTestBase { expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains("Executing project 'test.prj'...", run) - jenkins.assertLogContains("-> With TBC=KEEP", run) - jenkins.assertLogContains("-> With TCF=KEEP", run) - - } - - def 'Run pipeline with invalid data type for testConfig'() { - given: - WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', " + - "testConfig: [] }", true)) - - GroovyMock(RestApiClientFactory, global: true) - RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() - - expect: - WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) - jenkins.assertLogContains("java.lang.ClassCastException", run) - jenkins.assertLogContains("expects class " + - "de.tracetronic.jenkins.plugins.ecutestexecution.configs.TestConfig", run) - jenkins.assertLogContains("but received class java.util.ArrayList", run) } def 'Run pipeline with package check'() { diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy index 824d09dd..d7cf6bcd 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy @@ -210,14 +210,14 @@ class RunTestFolderStepIT extends IntegrationTestBase { jenkins.assertLogContains("-> With TCF=test.tcf", run) } - def 'Run pipeline by declaring KEEP in testConfig'() { + def 'Run pipeline by forcing configuration to reload in testConfig'() { given: setupTestFolder() WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition( "node { ttRunTestFolder recursiveScan: true, " + "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'" + - ", testConfig: [tbcPath: 'KEEP', tcfPath: 'KEEP'] }", + ", testConfig: [forceConfigurationReload: true] }", true)) GroovyMock(RestApiClientFactory, global: true) @@ -228,29 +228,6 @@ class RunTestFolderStepIT extends IntegrationTestBase { jenkins.assertLogContains('Found 3 package(s)', run) jenkins.assertLogContains('Found 3 project(s)', run) jenkins.assertLogContains("Executing package '${subPackage.getAbsolutePath()}'", run) - jenkins.assertLogContains("-> With TBC=KEEP", run) - jenkins.assertLogContains("-> With TCF=KEEP", run) - } - - def 'Run pipeline with invalid data type for testConfig'() { - given: - setupTestFolder() - WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition( - "node { ttRunTestFolder recursiveScan: true, " + - "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'" + - ", testConfig: [] }", - true)) - - GroovyMock(RestApiClientFactory, global: true) - RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() - - expect: - WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) - jenkins.assertLogContains("java.lang.ClassCastException", run) - jenkins.assertLogContains("expects class " + - "de.tracetronic.jenkins.plugins.ecutestexecution.configs.TestConfig", run) - jenkins.assertLogContains("but received class java.util.ArrayList", run) } def 'Run recursive scan pipeline'() { diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtilTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtilTest.groovy index cb8ab5d5..a5a14c13 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtilTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtilTest.groovy @@ -73,8 +73,6 @@ class ValidationUtilTest extends Specification { configFilePath | fileExtension | expectedKind 'test.tcf' | '.tcf' | FormValidation.Kind.OK 'test.tcf' | '.tbc' | FormValidation.Kind.ERROR - 'KEEP' | '' | FormValidation.Kind.OK - 'KEEP' | '.tcf' | FormValidation.Kind.OK '${CONFIG}' | '' | FormValidation.Kind.WARNING '' | '' | FormValidation.Kind.OK null | null | FormValidation.Kind.OK From c07ef729a3d4f97867290215f35f4eeacade93f9 Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Tue, 29 Oct 2024 11:19:46 +0100 Subject: [PATCH 09/18] Add review notes (#164) - ensure either load configuration or keep configuration in snippet generator - adjust jelly and properties file - sync tests --- .../configs/TestConfig.groovy | 13 +-- .../configs/TestConfig/config.jelly | 26 +++--- .../configs/TestConfig/config.properties | 7 +- .../steps/RunPackageStepIT.groovy | 73 ++++++++++++++-- .../steps/RunProjectStepIT.groovy | 39 ++++++++- .../steps/RunTestFolderStepIT.groovy | 87 +++++++++++++++++-- 6 files changed, 205 insertions(+), 40 deletions(-) diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy index b367fd6c..d5b954f8 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy @@ -12,11 +12,7 @@ import hudson.Extension import hudson.model.AbstractDescribableImpl import hudson.model.Descriptor import hudson.util.FormValidation -import net.sf.json.JSONObject import org.apache.commons.lang.StringUtils -import org.jinterop.dcom.test.Test -import org.kohsuke.stapler.Stapler -import org.kohsuke.stapler.StaplerRequest import org.kohsuke.stapler.DataBoundConstructor import org.kohsuke.stapler.DataBoundSetter import org.kohsuke.stapler.QueryParameter @@ -39,10 +35,17 @@ class TestConfig extends AbstractDescribableImpl implements Expandab } TestConfig(TestConfig config) { + this.forceConfigurationReload = config.forceConfigurationReload + //setting paths and constants to empty in case forceConfigurationReload is set to true + if(this.forceConfigurationReload) { + this.tbcPath = "" + this.tcfPath = "" + this.constants = [] + } else { this.tbcPath = config.getTbcPath() this.tcfPath = config.getTcfPath() this.constants = config.getConstants() - this.forceConfigurationReload = config.forceConfigurationReload + } } String getTbcPath() { diff --git a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly index 294d132a..c39b4fa5 100644 --- a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly +++ b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly @@ -1,25 +1,25 @@ - ${%configSection.description} - - - - - - - + + ${%loadConfig.description} + + + + + + - - - - + + ${%keepConfig.description} + + + diff --git a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties index ac048d0c..8ad6c104 100644 --- a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties +++ b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties @@ -1,7 +1,8 @@ configSection.title=Test Configuration -configSection.description=It is recommended to choose one of the following options:

    \ -
  • Load Configuration: Both the Test Bench Configuration and Test Configuration must be provided to load new configurations.
  • \ -
  • Keep Configuration: Enabling this option retains the existing configuration for continued use throughout the execution.
  • +configOption.loadConfig=Load Configuration +configOption.keepConfig=Keep Configuration +loadConfig.description=Both the Test Bench Configuration and Test Configuration must be provided to load new configurations. +keepConfig.description=Enabling this option retains the existing configuration for continued use throughout the execution. constants.add=Add Global Constant constants.description=The configured global constants remain available throughout the entire test execution. constants.title=Global Constants diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy index 342efec5..6441342f 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy @@ -89,7 +89,7 @@ class RunPackageStepIT extends IntegrationTestBase { jenkins.assertEqualDataBoundBeans(before, after) } - def 'Snippet generator'() { + def 'Snippet generator with Load Configuration'() { given: SnippetizerTester st = new SnippetizerTester(jenkins) when: @@ -100,13 +100,13 @@ class RunPackageStepIT extends IntegrationTestBase { TestConfig testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') - testConfig.setForceConfigurationReload(true) + testConfig.setForceConfigurationReload(false) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunPackage testCasePath: 'test.pkg', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: PackageConfig packageConfig = new PackageConfig(Arrays.asList( new PackageParameter('paramLabel', 'paramValue'))) @@ -115,7 +115,7 @@ class RunPackageStepIT extends IntegrationTestBase { st.assertRoundTrip(step, "ttRunPackage packageConfig: [" + "packageParameters: [[label: 'paramLabel', value: 'paramValue']]], testCasePath: 'test.pkg', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: AnalysisConfig analysisConfig = new AnalysisConfig() analysisConfig.setMapping('mappingName') @@ -124,7 +124,6 @@ class RunPackageStepIT extends IntegrationTestBase { recording.setDeviceName('deviceName') recording.setFormatDetails('formatDetails') recording.setRecordingGroup('recordingGroup') - //recording.setMappingNames(['mapping1', 'mapping2']) analysisConfig.setRecordings(Arrays.asList(recording)) step.setAnalysisConfig(analysisConfig) then: @@ -134,7 +133,7 @@ class RunPackageStepIT extends IntegrationTestBase { "path: 'recording.csv', recordingGroup: 'recordingGroup']]], " + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + "testCasePath: 'test.pkg', testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) @@ -151,7 +150,67 @@ class RunPackageStepIT extends IntegrationTestBase { "executePackageCheck: true, stopOnError: false, stopUndefinedTools: false, timeout: 0], " + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + "testCasePath: 'test.pkg', testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + } + + def 'Snippet generator with Keep Configuration'() { + given: + SnippetizerTester st = new SnippetizerTester(jenkins) + when: + RunPackageStep step = new RunPackageStep('test.pkg') + then: + st.assertRoundTrip(step, "ttRunPackage 'test.pkg'") + when: + TestConfig testConfig = new TestConfig() + testConfig.setForceConfigurationReload(true) + testConfig.setTbcPath('test.tbc') + testConfig.setTcfPath('test.tcf') + testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) + step.setTestConfig(testConfig) + then: + st.assertRoundTrip(step, "ttRunPackage testCasePath: 'test.pkg', " + + "testConfig: [forceConfigurationReload: true]") + when: + PackageConfig packageConfig = new PackageConfig(Arrays.asList( + new PackageParameter('paramLabel', 'paramValue'))) + step.setPackageConfig(packageConfig) + then: + st.assertRoundTrip(step, "ttRunPackage packageConfig: [" + + "packageParameters: [[label: 'paramLabel', value: 'paramValue']]], testCasePath: 'test.pkg', " + + "testConfig: [forceConfigurationReload: true]") + when: + AnalysisConfig analysisConfig = new AnalysisConfig() + analysisConfig.setMapping('mappingName') + analysisConfig.setAnalysisName('analysisName') + RecordingAsSetting recording = new RecordingAsSetting('recording.csv') + recording.setDeviceName('deviceName') + recording.setFormatDetails('formatDetails') + recording.setRecordingGroup('recordingGroup') + analysisConfig.setRecordings(Arrays.asList(recording)) + step.setAnalysisConfig(analysisConfig) + then: + st.assertRoundTrip(step, "ttRunPackage analysisConfig: [" + + "analysisName: 'analysisName', mapping: 'mappingName', " + + "recordings: [[deviceName: 'deviceName', formatDetails: 'formatDetails', " + + "path: 'recording.csv', recordingGroup: 'recordingGroup']]], " + + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + + "testCasePath: 'test.pkg', testConfig: [forceConfigurationReload: true]") + when: + ExecutionConfig executionConfig = new ExecutionConfig() + executionConfig.setStopOnError(false) + executionConfig.setStopUndefinedTools(false) + executionConfig.setTimeout(0) + executionConfig.setExecutePackageCheck(true) + step.setExecutionConfig(executionConfig) + then: + st.assertRoundTrip(step, "ttRunPackage analysisConfig: [" + + "analysisName: 'analysisName', mapping: 'mappingName', " + + "recordings: [[deviceName: 'deviceName', formatDetails: 'formatDetails', " + + "path: 'recording.csv', recordingGroup: 'recordingGroup']]], " + + "executionConfig: [" + + "executePackageCheck: true, stopOnError: false, stopUndefinedTools: false, timeout: 0], " + + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + + "testCasePath: 'test.pkg', testConfig: [forceConfigurationReload: true]") } def 'Run pipeline'() { diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy index e9cbdb48..6bb9bc66 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy @@ -69,7 +69,7 @@ class RunProjectStepIT extends IntegrationTestBase { jenkins.assertEqualDataBoundBeans(before, after) } - def 'Snippet generator'() { + def 'Snippet generator with Load Configuration'() { given: SnippetizerTester st = new SnippetizerTester(jenkins) when: @@ -80,13 +80,13 @@ class RunProjectStepIT extends IntegrationTestBase { TestConfig testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') - testConfig.setForceConfigurationReload(true) + testConfig.setForceConfigurationReload(false) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunProject testCasePath: 'test.prj', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) @@ -99,7 +99,38 @@ class RunProjectStepIT extends IntegrationTestBase { "ttRunProject executionConfig: [" + "executePackageCheck: true, stopOnError: false, stopUndefinedTools: false, timeout: 0], " + "testCasePath: 'test.prj', testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + } + + def 'Snippet generator with Keep Configuration'() { + given: + SnippetizerTester st = new SnippetizerTester(jenkins) + when: + RunProjectStep step = new RunProjectStep('test.prj') + then: + st.assertRoundTrip(step, "ttRunProject 'test.prj'") + when: + TestConfig testConfig = new TestConfig() + testConfig.setTbcPath('test.tbc') + testConfig.setTcfPath('test.tcf') + testConfig.setForceConfigurationReload(true) + testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) + step.setTestConfig(testConfig) + then: + st.assertRoundTrip(step, "ttRunProject testCasePath: 'test.prj', " + + "testConfig: [forceConfigurationReload: true]") + when: + ExecutionConfig executionConfig = new ExecutionConfig() + executionConfig.setStopOnError(false) + executionConfig.setStopUndefinedTools(false) + executionConfig.setTimeout(0) + executionConfig.setExecutePackageCheck(true) + step.setExecutionConfig(executionConfig) + then: + st.assertRoundTrip(step, + "ttRunProject executionConfig: [" + + "executePackageCheck: true, stopOnError: false, stopUndefinedTools: false, timeout: 0], " + + "testCasePath: 'test.prj', testConfig: [forceConfigurationReload: true]") } def 'Run pipeline'() { diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy index d7cf6bcd..9b212136 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy @@ -92,7 +92,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { jenkins.assertEqualDataBoundBeans(before, after) } - def 'Snippet generator'() { + def 'Snippet generator with Load Configuration'() { given: SnippetizerTester st = new SnippetizerTester(jenkins) when: @@ -105,19 +105,19 @@ class RunTestFolderStepIT extends IntegrationTestBase { step.setScanMode(RunTestFolderStep.ScanMode.PROJECTS_ONLY) then: st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + - "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder'") + "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder'") when: TestConfig testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') - testConfig.setForceConfigurationReload(true) + testConfig.setForceConfigurationReload(false) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: PackageConfig packageConfig = new PackageConfig(Arrays.asList( new PackageParameter('paramLabel', 'paramValue'))) @@ -127,7 +127,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: AnalysisConfig analysisConfig = new AnalysisConfig() analysisConfig.setMapping('mappingName') @@ -136,7 +136,6 @@ class RunTestFolderStepIT extends IntegrationTestBase { recording.setDeviceName('deviceName') recording.setFormatDetails('formatDetails') recording.setRecordingGroup('recordingGroup') - //recording.setMappingNames(['mapping1', 'mapping2']) analysisConfig.setRecordings(Arrays.asList(recording)) step.setAnalysisConfig(analysisConfig) then: @@ -147,7 +146,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) @@ -166,7 +165,79 @@ class RunTestFolderStepIT extends IntegrationTestBase { "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + } + + def 'Snippet generator with Keep Configuration'() { + given: + SnippetizerTester st = new SnippetizerTester(jenkins) + when: + RunTestFolderStep step = new RunTestFolderStep('/TestFolder') + then: + st.assertRoundTrip(step, "ttRunTestFolder '/TestFolder'") + when: + step.setRecursiveScan(true) + step.setFailFast(false) + step.setScanMode(RunTestFolderStep.ScanMode.PROJECTS_ONLY) + then: + st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + + "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder'") + when: + TestConfig testConfig = new TestConfig() + testConfig.setTbcPath('test.tbc') + testConfig.setTcfPath('test.tcf') + testConfig.setForceConfigurationReload(true) + testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) + step.setTestConfig(testConfig) + then: + st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + + "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + + "testConfig: [forceConfigurationReload: true]") + when: + PackageConfig packageConfig = new PackageConfig(Arrays.asList( + new PackageParameter('paramLabel', 'paramValue'))) + step.setPackageConfig(packageConfig) + then: + st.assertRoundTrip(step, "ttRunTestFolder failFast: false, " + + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + + "testConfig: [forceConfigurationReload: true]") + when: + AnalysisConfig analysisConfig = new AnalysisConfig() + analysisConfig.setMapping('mappingName') + analysisConfig.setAnalysisName('analysisName') + RecordingAsSetting recording = new RecordingAsSetting('recording.csv') + recording.setDeviceName('deviceName') + recording.setFormatDetails('formatDetails') + recording.setRecordingGroup('recordingGroup') + analysisConfig.setRecordings(Arrays.asList(recording)) + step.setAnalysisConfig(analysisConfig) + then: + st.assertRoundTrip(step, "ttRunTestFolder " + + "analysisConfig: [analysisName: 'analysisName', mapping: 'mappingName', " + + "recordings: [[deviceName: 'deviceName', formatDetails: 'formatDetails', " + + "path: 'recording.csv', recordingGroup: 'recordingGroup']]], failFast: false, " + + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + + "testConfig: [forceConfigurationReload: true]") + when: + ExecutionConfig executionConfig = new ExecutionConfig() + executionConfig.setStopOnError(false) + executionConfig.setStopUndefinedTools(false) + executionConfig.setTimeout(0) + executionConfig.setExecutePackageCheck(true) + step.setExecutionConfig(executionConfig) + then: + st.assertRoundTrip(step, "ttRunTestFolder " + + "analysisConfig: [analysisName: 'analysisName', mapping: 'mappingName', " + + "recordings: [[deviceName: 'deviceName', formatDetails: 'formatDetails', " + + "path: 'recording.csv', recordingGroup: 'recordingGroup']]], " + + "executionConfig: [" + + "executePackageCheck: true, stopOnError: false, stopUndefinedTools: false, timeout: 0], "+ + "failFast: false, " + + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + + "testConfig: [forceConfigurationReload: true]") } def 'Run default pipeline'() { From 8dae1680bf107df19585c917210ba0a5d69151bc Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Mon, 4 Nov 2024 11:22:52 +0100 Subject: [PATCH 10/18] Add review note (#164) - enhance configOption handler in TestConfig - sync tests --- .../configs/TestConfig.groovy | 27 ++++++++++++------- .../steps/RunPackageStepIT.groovy | 11 ++++++++ .../steps/RunProjectStepIT.groovy | 9 +++++++ .../steps/RunTestFolderStepIT.groovy | 7 +++++ 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy index d5b954f8..5012047f 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy @@ -20,6 +20,7 @@ import org.kohsuke.stapler.QueryParameter class TestConfig extends AbstractDescribableImpl implements ExpandableConfig, Serializable { private static final long serialVersionUID = 1L + private static transient String configOption private String tbcPath private String tcfPath @@ -35,16 +36,14 @@ class TestConfig extends AbstractDescribableImpl implements Expandab } TestConfig(TestConfig config) { + this() this.forceConfigurationReload = config.forceConfigurationReload - //setting paths and constants to empty in case forceConfigurationReload is set to true - if(this.forceConfigurationReload) { - this.tbcPath = "" - this.tcfPath = "" - this.constants = [] - } else { - this.tbcPath = config.getTbcPath() - this.tcfPath = config.getTcfPath() - this.constants = config.getConstants() + + if (configOption != 'keepConfig') { + this.tbcPath = config.getTbcPath() + this.tcfPath = config.getTcfPath() + this.constants = config.getConstants() + this.forceConfigurationReload = false } } @@ -84,6 +83,15 @@ class TestConfig extends AbstractDescribableImpl implements Expandab this.constants = constants ? removeEmptyConstants(constants) : [] } + @DataBoundSetter + void setConfigOption(String value) { + configOption = value + } + + String getConfigOption() { + return configOption ?: 'loadConfig' + } + @Override String toString() { """ @@ -91,6 +99,7 @@ class TestConfig extends AbstractDescribableImpl implements Expandab -> tcfPath: ${tcfPath} -> forceConfigurationReload: ${forceConfigurationReload} -> constants: ${constants.each { it }} + -> configOption: ${configOption} """.stripIndent().trim() } diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy index 6441342f..fee1e1de 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy @@ -102,6 +102,7 @@ class RunPackageStepIT extends IntegrationTestBase { testConfig.setTcfPath('test.tcf') testConfig.setForceConfigurationReload(false) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) + testConfig.setConfigOption('loadConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunPackage testCasePath: 'test.pkg', " + @@ -166,6 +167,7 @@ class RunPackageStepIT extends IntegrationTestBase { testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) + testConfig.setConfigOption('keepConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunPackage testCasePath: 'test.pkg', " + @@ -235,6 +237,9 @@ class RunPackageStepIT extends IntegrationTestBase { GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('loadConfig') + expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains("Executing package 'test.pkg'...", run) @@ -251,6 +256,9 @@ class RunPackageStepIT extends IntegrationTestBase { GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('keepConfig') + expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains("Executing package 'test.pkg'...", run) @@ -316,6 +324,9 @@ class RunPackageStepIT extends IntegrationTestBase { WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', testConfig: [tbcPath: 'test.tbc'] }", true)) + + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('loadConfig') when: WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) then: diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy index 6bb9bc66..3ba6fdac 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy @@ -82,6 +82,7 @@ class RunProjectStepIT extends IntegrationTestBase { testConfig.setTcfPath('test.tcf') testConfig.setForceConfigurationReload(false) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) + testConfig.setConfigOption('loadConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunProject testCasePath: 'test.prj', " + @@ -115,6 +116,7 @@ class RunProjectStepIT extends IntegrationTestBase { testConfig.setTcfPath('test.tcf') testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) + testConfig.setConfigOption('keepConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunProject testCasePath: 'test.prj', " + @@ -155,6 +157,8 @@ class RunProjectStepIT extends IntegrationTestBase { GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('loadConfig') expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains("Executing project 'test.prj'...", run) @@ -171,6 +175,8 @@ class RunProjectStepIT extends IntegrationTestBase { GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('keepConfig') expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains("Executing project 'test.prj'...", run) @@ -235,6 +241,9 @@ class RunProjectStepIT extends IntegrationTestBase { WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', testConfig: [tbcPath: 'test.tbc'] }", true)) + + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('loadConfig') when: WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) then: diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy index 9b212136..65a76631 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy @@ -112,6 +112,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { testConfig.setTcfPath('test.tcf') testConfig.setForceConfigurationReload(false) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) + testConfig.setConfigOption('loadConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + @@ -188,6 +189,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { testConfig.setTcfPath('test.tcf') testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) + testConfig.setConfigOption('keepConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + @@ -272,6 +274,9 @@ class RunTestFolderStepIT extends IntegrationTestBase { GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('loadConfig') expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains('Found 3 package(s)', run) @@ -294,6 +299,8 @@ class RunTestFolderStepIT extends IntegrationTestBase { GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('keepConfig') expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains('Found 3 package(s)', run) From 2e39235b551e5e014416f1e2d82a45885b717cbf Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Fri, 8 Nov 2024 13:17:07 +0100 Subject: [PATCH 11/18] Add review notes (#164) - provide console log for configOption and sync related tests - provide test for behavior of keeping tbc/tcf paths empty --- build.gradle | 1 + .../util/LogConfigUtil.groovy | 3 ++ .../ecutestexecution/ETV2ContainerTest.groovy | 43 +++++++++++++++++++ .../steps/RunPackageStepIT.groovy | 2 + .../steps/RunProjectStepIT.groovy | 2 + .../steps/RunTestFolderStepIT.groovy | 2 + .../util/LogConfigUtilTest.groovy | 7 ++- 7 files changed, 59 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 44dc7a1a..d33cfbfc 100644 --- a/build.gradle +++ b/build.gradle @@ -77,6 +77,7 @@ dependencies { testImplementation('org.jenkins-ci.plugins.workflow:workflow-basic-steps') {//:1042.ve7b_140c4a_e0c') { exclude group: 'org.jenkins-ci.modules', module: 'instance-identity' } + testImplementation 'org.jenkins-ci.plugins:http_request' testImplementation 'org.jenkins-ci.plugins.workflow:workflow-cps' testImplementation('org.jenkins-ci.plugins.workflow:workflow-cps') {artifact{ classifier = 'tests'}} testImplementation 'org.jenkins-ci.plugins.workflow:workflow-job' diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtil.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtil.groovy index 3af5d231..cf2bce42 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtil.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtil.groovy @@ -49,6 +49,9 @@ class LogConfigUtil implements Serializable { if (testConfig.constants) { listener.logger.println("-> With global constants=[${testConfig.constants.each { it.toString() }}]") } + if (testConfig.configOption) { + listener.logger.println("-> With TestConfig=${testConfig.configOption}") + } } private void logPackageConfig() { diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy index fb53d852..6075e141 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy @@ -82,6 +82,49 @@ class ETV2ContainerTest extends ETContainerTest { jenkins.assertLogContains("[WARNING] No files found!", run) } + def "Keep tbc and tcf path empty should unload the current loaded configuration."() { + given: "a pipeline with predefined testConfig paths" + String script = """ + node { + withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) { + httpRequest( + ignoreSslErrors: true, + responseHandle: 'NONE', + url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration", + wrapAsMultipart: false, + customHeaders: [[name: 'Content-Type', value: 'application/json']], + httpMode: 'PUT', + requestBody: '''{ + "action": "Start", + "tbc": { "tbcPath": "test.tbc" }, + "tcf": { "tcfPath": "test.tcf" } + }''' + ) + + ttRunPackage testCasePath: 'test.pkg' + + def response = httpRequest( + ignoreSslErrors: true, + url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration" + ) + echo response.content + } + } + """.stripIndent() + + WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline") + job.setDefinition(new CpsFlowDefinition(script, true)) + + when: "scheduling a new build" + WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job) + + then: "expect log information about testConfig being empty but received predefined paths" + jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) + jenkins.assertLogContains("Executing package 'test.pkg'...", run) + jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) + jenkins.assertLogContains("\"tbc\": {\"tbcPath\": \"test.tbc\"}, \"tcf\": {\"tcfPath\": \"test.tcf\"}", run) + } + def "Perform provide logs step with logs"() { given: "a pipeline with test packages and log provider" String script = """ diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy index fee1e1de..8be524f8 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy @@ -245,6 +245,7 @@ class RunPackageStepIT extends IntegrationTestBase { jenkins.assertLogContains("Executing package 'test.pkg'...", run) jenkins.assertLogContains("-> With TBC=test.tbc", run) jenkins.assertLogContains("-> With TCF=test.tcf", run) + jenkins.assertLogContains("-> With TestConfig=loadConfig", run) } def 'Run pipeline by forcing configuration to reload in testConfig'() { @@ -262,6 +263,7 @@ class RunPackageStepIT extends IntegrationTestBase { expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains("Executing package 'test.pkg'...", run) + jenkins.assertLogContains("-> With TestConfig=keepConfig", run) } def 'Run pipeline with package check'(){ diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy index 3ba6fdac..b8bd6a18 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy @@ -164,6 +164,7 @@ class RunProjectStepIT extends IntegrationTestBase { jenkins.assertLogContains("Executing project 'test.prj'...", run) jenkins.assertLogContains("-> With TBC=test.tbc", run) jenkins.assertLogContains("-> With TCF=test.tcf", run) + jenkins.assertLogContains("-> With TestConfig=loadConfig", run) } def 'Run pipeline by forcing configuration to reload in testConfig'() { @@ -180,6 +181,7 @@ class RunProjectStepIT extends IntegrationTestBase { expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains("Executing project 'test.prj'...", run) + jenkins.assertLogContains("-> With TestConfig=keepConfig", run) } def 'Run pipeline with package check'() { diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy index 65a76631..81ff0882 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy @@ -284,6 +284,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { jenkins.assertLogContains("Executing package '${subPackage.getAbsolutePath()}'", run) jenkins.assertLogContains("-> With TBC=test.tbc", run) jenkins.assertLogContains("-> With TCF=test.tcf", run) + jenkins.assertLogContains("-> With TestConfig=loadConfig", run) } def 'Run pipeline by forcing configuration to reload in testConfig'() { @@ -306,6 +307,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { jenkins.assertLogContains('Found 3 package(s)', run) jenkins.assertLogContains('Found 3 project(s)', run) jenkins.assertLogContains("Executing package '${subPackage.getAbsolutePath()}'", run) + jenkins.assertLogContains("-> With TestConfig=keepConfig", run) } def 'Run recursive scan pipeline'() { diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy index fa050535..60024b49 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy @@ -17,6 +17,7 @@ import spock.lang.Specification class LogConfigUtilTest extends Specification { private TaskListener listener private PrintStream logger + private String expectedConfigPrint private String expectedTbcPrint private String expectedTcfPrint private String expectedConstPrint @@ -30,6 +31,7 @@ class LogConfigUtilTest extends Specification { logger = Mock() listener = Mock(TaskListener) listener.getLogger() >> logger + expectedConfigPrint = '-> With TestConfig=loadConfig' expectedTbcPrint = '-> With TBC=test.tbc' expectedTcfPrint = '-> With TCF=test.tcf' expectedConstPrint = '-> With global constants=[[constLabel=constValue]]' @@ -49,8 +51,8 @@ class LogConfigUtilTest extends Specification { logConfigUtil.log() then: + 1* logger.println(expectedConfigPrint) 0* logger.println(_) - } def 'Log Test Config'() { @@ -64,6 +66,7 @@ class LogConfigUtilTest extends Specification { logConfigUtil.log() then: + 1* logger.println(expectedConfigPrint) 1* logger.println(expectedTbcPrint) 1* logger.println(expectedTcfPrint) 1* logger.println(expectedConstPrint) @@ -81,6 +84,7 @@ class LogConfigUtilTest extends Specification { logConfigUtil.log() then: + 1* logger.println(expectedConfigPrint) 1* logger.println(expectedParamPrint) 0* logger.println(_) } @@ -104,6 +108,7 @@ class LogConfigUtilTest extends Specification { logConfigUtil.log() then: + 1* logger.println(expectedConfigPrint) 1* logger.println(expectedAnalysisNamePrint) 1* logger.println(expectedMappingPrint) 1* logger.println(expectedRecordingPrint) From 5406da2fbcac9cd1337eaed65d2ce64ac32c3ea3 Mon Sep 17 00:00:00 2001 From: Mario Fuchs Date: Tue, 12 Nov 2024 11:28:37 +0100 Subject: [PATCH 12/18] Provide keepConfig and loadConfig behavior for TestConfig and sync tests (#164) --- docs/AdvancedUsage.md | 17 ++- .../builder/ExecutionOrderBuilder.groovy | 3 +- .../clients/RestApiClientV2.groovy | 15 ++- .../clients/model/ExecutionOrder.groovy | 16 ++- .../configs/TestConfig.groovy | 22 ++-- .../configs/TestConfig/config.jelly | 18 +-- .../configs/TestConfig/config.properties | 6 +- .../ecutestexecution/ETV2ContainerTest.groovy | 109 ++++++++++++------ .../builder/TestPackageBuilderTest.groovy | 4 +- .../builder/TestProjectBuilderTest.groovy | 4 +- .../steps/RunPackageStepIT.groovy | 64 +++++----- .../steps/RunProjectStepIT.groovy | 33 +++--- .../steps/RunTestFolderStepIT.groovy | 42 +++---- .../util/LogConfigUtilTest.groovy | 18 ++- 14 files changed, 216 insertions(+), 155 deletions(-) diff --git a/docs/AdvancedUsage.md b/docs/AdvancedUsage.md index 11065d66..8d192c3d 100644 --- a/docs/AdvancedUsage.md +++ b/docs/AdvancedUsage.md @@ -91,18 +91,17 @@ node { ## TestConfig -| Properties | Default Value | Description | -|----------------------------------------------|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **tbcPath**: String | '' | The relative path of the .tbc file in the Configurations directory to be started for this execution. If empty, no test bench configuration will be loaded. | -| **tcfPath**: String | '' | The relative path of the .tcf file in the Configurations directory to be started for this execution. If empty, no test configuration will be loaded. | -| **forceConfigurationReload**: boolean | false | If true, always reload the configuration even if the same one is still active. Hint: This flag is only required for ecu.test versions less than 2023.4! | -| **constants**: List\<[Constant](#constant)> | [] | The configured global constants remain available throughout the entire test execution. | +| Properties | Default Value | Description | +|----------------------------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **tbcPath**: String | null | The relative path of the .tbc file in the Configurations directory to be started for this execution. If empty, no test bench configuration will be loaded. | +| **tcfPath**: String | null | The relative path of the .tcf file in the Configurations directory to be started for this execution. If empty, no test configuration will be loaded. | +| **forceConfigurationReload**: boolean | false | If true, always reload the configuration even if the same one is still active. | +| **constants**: List\<[Constant](#constant)> | [] | The configured global constants remain available throughout the entire test execution. | ### Configuration Change Options -- **Load Configuration**: Both `.tbc` and `.tcf` files must be explicitly set whenever a new configuration is needed. -- **Keep Configuration**: In ecu.test versions prior to 2023.4, setting `forceConfigurationReload` to `true` forces a configuration reload, even if the same configuration is still active. -- **Unload Configurations**: Keeping values empty, such as `[tbcPath: '', tcfPath: '']` will unload the configuration. +- **Load Configuration**: Both `.tbc` and `.tcf` files must be explicitly set whenever a new configuration is needed. Setting `forceConfigurationReload` to `true` forces a configuration reload, even if the same configuration is still active. If empty, Test Configuration will be unloaded. +- **Keep Configuration**: Enabling this option retains the existing configuration for continued use throughout the execution. ## PublishConfig diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/ExecutionOrderBuilder.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/ExecutionOrderBuilder.groovy index 4dec0e10..9f1f7f4b 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/ExecutionOrderBuilder.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/ExecutionOrderBuilder.groovy @@ -72,8 +72,7 @@ class ExecutionOrderBuilder implements Serializable { settings = new AdditionalSettings(testConfig.forceConfigurationReload) } - ExecutionOrder executionOrder = new ExecutionOrder(testCasePath, settings, testConfig.tbcPath, - testConfig.tcfPath, testConfig.constants) + ExecutionOrder executionOrder = new ExecutionOrder(testCasePath, testConfig, settings) return executionOrder } diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/RestApiClientV2.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/RestApiClientV2.groovy index d741df91..309cc686 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/RestApiClientV2.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/RestApiClientV2.groovy @@ -127,25 +127,34 @@ class RestApiClientV2 extends RestApiClientV2WithIdleHandle implements RestApiCl ExecutionApi executionApi = new ExecutionApi(apiClient) de.tracetronic.cxs.generated.et.client.model.v2.ExecutionOrder executionOrderV2 executionOrderV2 = executionOrder.toExecutionOrderV2() - List constants = [] executionOrder.constants.each { constant -> constants.add(new LabeledValue().label(constant.label).value(constant.value)) } + ConfigurationOrder configOrder = new ConfigurationOrder() .tbc(new TestbenchConfiguration().tbcPath(executionOrder.tbcPath)) .tcf(new TestConfiguration().tcfPath(executionOrder.tcfPath)) .constants(constants) .action(ConfigurationOrder.ActionEnum.START) try { - if (configOrder.tbc.tbcPath || configOrder.tcf.tcfPath || constants) { + if(executionOrder.configOption == 'loadConfig') { ConfigurationApi configApi = new ConfigurationApi(apiClient) - configApi.manageConfiguration(configOrder) Closure checkConfigStatus = { ModelConfiguration configuration -> configuration?.status?.key in [null, ConfigurationStatus.KeyEnum.WAITING, ConfigurationStatus.KeyEnum.RUNNING] } + if(executionOrder.loadConfig) { + ConfigurationOrder loadConfigOrder = new ConfigurationOrder().action(ConfigurationOrder.ActionEnum.STOP) + configApi.manageConfiguration(loadConfigOrder) + + while (checkConfigStatus(configApi.lastConfigurationOrder)) { + sleep(1000) + } + } + + configApi.manageConfiguration(configOrder) while (checkConfigStatus(configApi.lastConfigurationOrder)) { sleep(1000) } diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/model/ExecutionOrder.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/model/ExecutionOrder.groovy index 90d18e78..e6015bcb 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/model/ExecutionOrder.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/model/ExecutionOrder.groovy @@ -6,6 +6,7 @@ package de.tracetronic.jenkins.plugins.ecutestexecution.clients.model +import de.tracetronic.jenkins.plugins.ecutestexecution.configs.TestConfig import de.tracetronic.jenkins.plugins.ecutestexecution.model.Constant import jline.internal.Nullable @@ -17,17 +18,20 @@ class ExecutionOrder implements Serializable { public String testCasePath public AdditionalSettings additionalSetting + public String configOption + public boolean loadConfig @Nullable public String tbcPath @Nullable public String tcfPath @Nullable public List constants ExecutionOrder(String testCasePath, AdditionalSettings additionalSetting, - String tbcPath, String tcfPath, List constants) { + String tbcPath, String tcfPath, List constants, String configOption) { this.testCasePath = testCasePath this.additionalSetting = additionalSetting this.tbcPath = tbcPath this.tcfPath = tcfPath this.constants = constants + this.configOption = configOption } ExecutionOrder(String testCasePath, AdditionalSettings additionalSetting) { @@ -35,6 +39,16 @@ class ExecutionOrder implements Serializable { this.additionalSetting = additionalSetting } + ExecutionOrder(String testCasePath, TestConfig testConfig, AdditionalSettings additionalSettings) { + this.testCasePath = testCasePath + this.additionalSetting = additionalSettings + this.tbcPath = testConfig.tbcPath + this.tcfPath = testConfig.tcfPath + this.constants = testConfig.constants + this.configOption = testConfig.configOption + this.loadConfig = testConfig.forceConfigurationReload + } + /** * Convert the abstract ExecutionOrder object to a ecu.test REST API object of the API version V1 * @return ExecutionOrder for ecu-test REST API in version V1 diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy index 5012047f..338a43f1 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy @@ -12,6 +12,7 @@ import hudson.Extension import hudson.model.AbstractDescribableImpl import hudson.model.Descriptor import hudson.util.FormValidation +import jline.internal.Nullable import org.apache.commons.lang.StringUtils import org.kohsuke.stapler.DataBoundConstructor import org.kohsuke.stapler.DataBoundSetter @@ -29,40 +30,43 @@ class TestConfig extends AbstractDescribableImpl implements Expandab @DataBoundConstructor TestConfig() { - this.tbcPath = '' - this.tcfPath = '' - this.forceConfigurationReload = false + this.tcfPath = null + this.tbcPath = null this.constants = [] + this.forceConfigurationReload = false } TestConfig(TestConfig config) { this() - this.forceConfigurationReload = config.forceConfigurationReload - if (configOption != 'keepConfig') { + configOption = getConfigOption() + + if(configOption == 'loadConfig') { this.tbcPath = config.getTbcPath() this.tcfPath = config.getTcfPath() this.constants = config.getConstants() - this.forceConfigurationReload = false + this.forceConfigurationReload = config.isForceConfigurationReload() } } + @Nullable String getTbcPath() { return tbcPath } @DataBoundSetter void setTbcPath(String tbcPath) { - this.tbcPath = StringUtils.trimToEmpty(tbcPath) + this.tbcPath = tbcPath || configOption == 'loadConfig' ? StringUtils.trimToEmpty(tbcPath) : null } + @Nullable String getTcfPath() { return tcfPath } @DataBoundSetter void setTcfPath(String tcfPath) { - this.tcfPath = StringUtils.trimToEmpty(tcfPath) + this.tcfPath = tcfPath || configOption == 'loadConfig' ? StringUtils.trimToEmpty(tcfPath) : null } boolean isForceConfigurationReload() { @@ -89,7 +93,7 @@ class TestConfig extends AbstractDescribableImpl implements Expandab } String getConfigOption() { - return configOption ?: 'loadConfig' + return configOption ?: 'keepConfig' } @Override diff --git a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly index c39b4fa5..e2c4aa4c 100644 --- a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly +++ b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly @@ -1,22 +1,22 @@ + + ${%keepConfig.description} + ${%loadConfig.description} - - - - - - + + + + + + - - - ${%keepConfig.description} diff --git a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties index 8ad6c104..5ed9aaf8 100644 --- a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties +++ b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties @@ -1,12 +1,14 @@ configSection.title=Test Configuration configOption.loadConfig=Load Configuration configOption.keepConfig=Keep Configuration -loadConfig.description=Both the Test Bench Configuration and Test Configuration must be provided to load new configurations. +loadConfig.description=Both the Test Bench Configuration and Test Configuration must be provided to load new configurations. \ + Setting forceConfigurationReload to true forces a configuration reload, even if the same configuration is still active. \ + If empty, Test Configuration will be unloaded. keepConfig.description=Enabling this option retains the existing configuration for continued use throughout the execution. constants.add=Add Global Constant constants.description=The configured global constants remain available throughout the entire test execution. constants.title=Global Constants -forceConfigurationReload.description=If true, always reload the configuration even if the same one is still active. Hint: This flag is only required for ecu.test versions less than 2023.4! +forceConfigurationReload.description=If true, always reload the configuration even if the same one is still active. forceConfigurationReload.title=Reload Configuration packageParameters.add=Add Package Parameter packageParameters.description=Parameters for package execution. diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy index 6075e141..a4408447 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy @@ -82,47 +82,90 @@ class ETV2ContainerTest extends ETContainerTest { jenkins.assertLogContains("[WARNING] No files found!", run) } - def "Keep tbc and tcf path empty should unload the current loaded configuration."() { + def "Run pipeline with keepConfig to keep the current loaded configuration."() { given: "a pipeline with predefined testConfig paths" - String script = """ - node { - withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) { - httpRequest( - ignoreSslErrors: true, - responseHandle: 'NONE', - url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration", - wrapAsMultipart: false, - customHeaders: [[name: 'Content-Type', value: 'application/json']], - httpMode: 'PUT', - requestBody: '''{ - "action": "Start", - "tbc": { "tbcPath": "test.tbc" }, - "tcf": { "tcfPath": "test.tcf" } - }''' - ) + String script = """ + node { + withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) { + httpRequest( + ignoreSslErrors: true, + responseHandle: 'NONE', + url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration", + wrapAsMultipart: false, + customHeaders: [[name: 'Content-Type', value: 'application/json']], + httpMode: 'PUT', + requestBody: '''{ + "action": "Start", + "tbc": { "tbcPath": "test.tbc" }, + "tcf": { "tcfPath": "test.tcf" } + }''' + ) + + ttRunPackage testCasePath: 'test.pkg' + + def response = httpRequest( + ignoreSslErrors: true, + url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration" + ) + echo response.content + } + } + """.stripIndent() - ttRunPackage testCasePath: 'test.pkg' + WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline") + job.setDefinition(new CpsFlowDefinition(script, true)) + + when: "scheduling a new build" + WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job) - def response = httpRequest( - ignoreSslErrors: true, - url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration" - ) - echo response.content + then: "expect log information about predefined paths being kept" + jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) + jenkins.assertLogContains("Executing package 'test.pkg'...", run) + jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) + jenkins.assertLogContains("\"tbc\": {\"tbcPath\": \"test.tbc\"}, \"tcf\": {\"tcfPath\": \"test.tcf\"}", run) + } + + def "Run pipeline with loadConfig to unload the current loaded configuration."() { + given: "a pipeline with predefined testConfig paths" + String script = """ + node { + withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) { + httpRequest( + ignoreSslErrors: true, + responseHandle: 'NONE', + url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration", + wrapAsMultipart: false, + customHeaders: [[name: 'Content-Type', value: 'application/json']], + httpMode: 'PUT', + requestBody: '''{ + "action": "Start", + "tbc": { "tbcPath": "test.tbc" }, + "tcf": { "tcfPath": "test.tcf" } + }''' + ) + + ttRunPackage testCasePath: 'test.pkg', testConfig: [tbcPath: '', tcfPath: ''] + + def response = httpRequest( + ignoreSslErrors: true, + url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration" + ) + echo response.content + } } - } - """.stripIndent() + """.stripIndent() - WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline") - job.setDefinition(new CpsFlowDefinition(script, true)) + WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline") + job.setDefinition(new CpsFlowDefinition(script, true)) when: "scheduling a new build" - WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job) + WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job) - then: "expect log information about testConfig being empty but received predefined paths" - jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) - jenkins.assertLogContains("Executing package 'test.pkg'...", run) - jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) - jenkins.assertLogContains("\"tbc\": {\"tbcPath\": \"test.tbc\"}, \"tcf\": {\"tcfPath\": \"test.tcf\"}", run) + then: "expect log information about predefined paths being empty" + jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) + jenkins.assertLogContains("Executing package 'test.pkg'...", run) + jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) + jenkins.assertLogContains("\"tbc\": {\"tbcPath\": \"\"}, \"tcf\": {\"tcfPath\": \"\"}", run) } def "Perform provide logs step with logs"() { diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/TestPackageBuilderTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/TestPackageBuilderTest.groovy index 7412fdca..0a964e72 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/TestPackageBuilderTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/TestPackageBuilderTest.groovy @@ -65,8 +65,8 @@ class TestPackageBuilderTest extends Specification { void assertExecutionOrder(ExecutionOrder order) { assert order.additionalSetting != null assert order.testCasePath == 'testFile' - assert order.tbcPath == '' - assert order.tcfPath == '' + assert order.tbcPath == null + assert order.tcfPath == null assert order.constants != null } } diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/TestProjectBuilderTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/TestProjectBuilderTest.groovy index 5c07aa80..f261aea6 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/TestProjectBuilderTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/builder/TestProjectBuilderTest.groovy @@ -60,8 +60,8 @@ class TestProjectBuilderTest extends Specification { void assertExecutionOrder(ExecutionOrder order) { assert order.additionalSetting != null assert order.testCasePath == 'testFile' - assert order.tbcPath == '' - assert order.tcfPath == '' + assert order.tbcPath == null + assert order.tcfPath == null assert order.constants != null } } diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy index 8be524f8..dea81ed2 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy @@ -45,6 +45,9 @@ class RunPackageStepIT extends IntegrationTestBase { def 'Default config round trip'() { given: RunPackageStep before = new RunPackageStep('test.pkg') + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('keepConfig') + before.setTestConfig(testConfig) when: RunPackageStep after = new StepConfigTester(jenkins).configRoundTrip(before) then: @@ -100,14 +103,14 @@ class RunPackageStepIT extends IntegrationTestBase { TestConfig testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') - testConfig.setForceConfigurationReload(false) + testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) testConfig.setConfigOption('loadConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunPackage testCasePath: 'test.pkg', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: PackageConfig packageConfig = new PackageConfig(Arrays.asList( new PackageParameter('paramLabel', 'paramValue'))) @@ -116,7 +119,7 @@ class RunPackageStepIT extends IntegrationTestBase { st.assertRoundTrip(step, "ttRunPackage packageConfig: [" + "packageParameters: [[label: 'paramLabel', value: 'paramValue']]], testCasePath: 'test.pkg', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: AnalysisConfig analysisConfig = new AnalysisConfig() analysisConfig.setMapping('mappingName') @@ -134,7 +137,7 @@ class RunPackageStepIT extends IntegrationTestBase { "path: 'recording.csv', recordingGroup: 'recordingGroup']]], " + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + "testCasePath: 'test.pkg', testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) @@ -151,7 +154,7 @@ class RunPackageStepIT extends IntegrationTestBase { "executePackageCheck: true, stopOnError: false, stopUndefinedTools: false, timeout: 0], " + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + "testCasePath: 'test.pkg', testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") } def 'Snippet generator with Keep Configuration'() { @@ -159,27 +162,18 @@ class RunPackageStepIT extends IntegrationTestBase { SnippetizerTester st = new SnippetizerTester(jenkins) when: RunPackageStep step = new RunPackageStep('test.pkg') - then: - st.assertRoundTrip(step, "ttRunPackage 'test.pkg'") - when: TestConfig testConfig = new TestConfig() - testConfig.setForceConfigurationReload(true) - testConfig.setTbcPath('test.tbc') - testConfig.setTcfPath('test.tcf') - testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) testConfig.setConfigOption('keepConfig') step.setTestConfig(testConfig) then: - st.assertRoundTrip(step, "ttRunPackage testCasePath: 'test.pkg', " + - "testConfig: [forceConfigurationReload: true]") + st.assertRoundTrip(step, "ttRunPackage 'test.pkg'") when: PackageConfig packageConfig = new PackageConfig(Arrays.asList( new PackageParameter('paramLabel', 'paramValue'))) step.setPackageConfig(packageConfig) then: st.assertRoundTrip(step, "ttRunPackage packageConfig: [" + - "packageParameters: [[label: 'paramLabel', value: 'paramValue']]], testCasePath: 'test.pkg', " + - "testConfig: [forceConfigurationReload: true]") + "packageParameters: [[label: 'paramLabel', value: 'paramValue']]], testCasePath: 'test.pkg'") when: AnalysisConfig analysisConfig = new AnalysisConfig() analysisConfig.setMapping('mappingName') @@ -196,7 +190,7 @@ class RunPackageStepIT extends IntegrationTestBase { "recordings: [[deviceName: 'deviceName', formatDetails: 'formatDetails', " + "path: 'recording.csv', recordingGroup: 'recordingGroup']]], " + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + - "testCasePath: 'test.pkg', testConfig: [forceConfigurationReload: true]") + "testCasePath: 'test.pkg'") when: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) @@ -212,7 +206,7 @@ class RunPackageStepIT extends IntegrationTestBase { "executionConfig: [" + "executePackageCheck: true, stopOnError: false, stopUndefinedTools: false, timeout: 0], " + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + - "testCasePath: 'test.pkg', testConfig: [forceConfigurationReload: true]") + "testCasePath: 'test.pkg'") } def 'Run pipeline'() { @@ -228,42 +222,42 @@ class RunPackageStepIT extends IntegrationTestBase { jenkins.assertLogContains("Executing package 'test.pkg'", run) } - def 'Run pipeline by declaring .tbc and .tcf files in testConfig'() { + def 'Run pipeline with keepConfig as TestConfig'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', " + - "testConfig: [tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg'}", true)) GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('loadConfig') + testConfig.setConfigOption('keepConfig') expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains("Executing package 'test.pkg'...", run) - jenkins.assertLogContains("-> With TBC=test.tbc", run) - jenkins.assertLogContains("-> With TCF=test.tcf", run) - jenkins.assertLogContains("-> With TestConfig=loadConfig", run) + jenkins.assertLogContains("-> With TestConfig=keepConfig", run) } - def 'Run pipeline by forcing configuration to reload in testConfig'() { + def 'Run pipeline with loadConfig as TestConfig'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', " + - "testConfig: [forceConfigurationReload: true] }", true)) + "testConfig: [forceConfigurationReload: true, " + + "tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') + testConfig.setConfigOption('loadConfig') expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains("Executing package 'test.pkg'...", run) - jenkins.assertLogContains("-> With TestConfig=keepConfig", run) + jenkins.assertLogContains("-> With TestConfig=loadConfig", run) + jenkins.assertLogContains("-> With TBC=test.tbc", run) + jenkins.assertLogContains("-> With TCF=test.tcf", run) } def 'Run pipeline with package check'(){ @@ -295,6 +289,9 @@ class RunPackageStepIT extends IntegrationTestBase { createExecution(*_) >> {restApiClient.apiClient.execute(mockCall, null)} } + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('keepConfig') + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunPackage 'test.pkg' }", true)) when: @@ -324,11 +321,11 @@ class RunPackageStepIT extends IntegrationTestBase { } } - WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', testConfig: [tbcPath: 'test.tbc'] }", true)) - TestConfig testConfig = new TestConfig() testConfig.setConfigOption('loadConfig') + + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', testConfig: [tbcPath: 'test.tbc'] }", true)) when: WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) then: @@ -355,6 +352,9 @@ class RunPackageStepIT extends IntegrationTestBase { getCurrentExecution() >> new Execution() } + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('keepConfig') + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath:'test.pkg', executionConfig:[timeout: 2]}", true)) expect: diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy index b8bd6a18..d72b0e7d 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy @@ -40,6 +40,9 @@ class RunProjectStepIT extends IntegrationTestBase { def 'Default config round trip'() { given: RunProjectStep before = new RunProjectStep('test.prj') + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('keepConfig') + before.setTestConfig(testConfig) when: RunProjectStep after = new StepConfigTester(jenkins).configRoundTrip(before) then: @@ -80,14 +83,14 @@ class RunProjectStepIT extends IntegrationTestBase { TestConfig testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') - testConfig.setForceConfigurationReload(false) + testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) testConfig.setConfigOption('loadConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunProject testCasePath: 'test.prj', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) @@ -100,7 +103,7 @@ class RunProjectStepIT extends IntegrationTestBase { "ttRunProject executionConfig: [" + "executePackageCheck: true, stopOnError: false, stopUndefinedTools: false, timeout: 0], " + "testCasePath: 'test.prj', testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") } def 'Snippet generator with Keep Configuration'() { @@ -108,19 +111,11 @@ class RunProjectStepIT extends IntegrationTestBase { SnippetizerTester st = new SnippetizerTester(jenkins) when: RunProjectStep step = new RunProjectStep('test.prj') - then: - st.assertRoundTrip(step, "ttRunProject 'test.prj'") - when: TestConfig testConfig = new TestConfig() - testConfig.setTbcPath('test.tbc') - testConfig.setTcfPath('test.tcf') - testConfig.setForceConfigurationReload(true) - testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) testConfig.setConfigOption('keepConfig') step.setTestConfig(testConfig) then: - st.assertRoundTrip(step, "ttRunProject testCasePath: 'test.prj', " + - "testConfig: [forceConfigurationReload: true]") + st.assertRoundTrip(step, "ttRunProject 'test.prj'") when: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) @@ -132,7 +127,7 @@ class RunProjectStepIT extends IntegrationTestBase { st.assertRoundTrip(step, "ttRunProject executionConfig: [" + "executePackageCheck: true, stopOnError: false, stopUndefinedTools: false, timeout: 0], " + - "testCasePath: 'test.prj', testConfig: [forceConfigurationReload: true]") + "testCasePath: 'test.prj'") } def 'Run pipeline'() { @@ -148,11 +143,12 @@ class RunProjectStepIT extends IntegrationTestBase { jenkins.assertLogContains("Executing project 'test.prj'", run) } - def 'Run pipeline by declaring .tbc and .tcf files in testConfig'() { + def 'Run pipeline with loadConfig as TestConfig'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', " + - "testConfig: [tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) + "testConfig: [forceConfigurationReload: true," + + "tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() @@ -162,16 +158,15 @@ class RunProjectStepIT extends IntegrationTestBase { expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains("Executing project 'test.prj'...", run) + jenkins.assertLogContains("-> With TestConfig=loadConfig", run) jenkins.assertLogContains("-> With TBC=test.tbc", run) jenkins.assertLogContains("-> With TCF=test.tcf", run) - jenkins.assertLogContains("-> With TestConfig=loadConfig", run) } - def 'Run pipeline by forcing configuration to reload in testConfig'() { + def 'Run pipeline with keepConfig as TestConfig'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', " + - "testConfig: [forceConfigurationReload: true] }", true)) + job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj'}", true)) GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy index 81ff0882..54b69ea0 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy @@ -46,6 +46,9 @@ class RunTestFolderStepIT extends IntegrationTestBase { def 'Default config round trip'() { given: RunTestFolderStep before = new RunTestFolderStep(folder.newFolder().getAbsolutePath()) + TestConfig testConfig = new TestConfig() + testConfig.setConfigOption('keepConfig') + before.setTestConfig(testConfig) when: RunTestFolderStep after = new StepConfigTester(jenkins).configRoundTrip(before) then: @@ -110,7 +113,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { TestConfig testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') - testConfig.setForceConfigurationReload(false) + testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) testConfig.setConfigOption('loadConfig') step.setTestConfig(testConfig) @@ -118,7 +121,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: PackageConfig packageConfig = new PackageConfig(Arrays.asList( new PackageParameter('paramLabel', 'paramValue'))) @@ -128,7 +131,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: AnalysisConfig analysisConfig = new AnalysisConfig() analysisConfig.setMapping('mappingName') @@ -147,7 +150,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") when: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) @@ -166,7 +169,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf']") + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf']") } def 'Snippet generator with Keep Configuration'() { @@ -180,21 +183,12 @@ class RunTestFolderStepIT extends IntegrationTestBase { step.setRecursiveScan(true) step.setFailFast(false) step.setScanMode(RunTestFolderStep.ScanMode.PROJECTS_ONLY) - then: - st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + - "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder'") - when: TestConfig testConfig = new TestConfig() - testConfig.setTbcPath('test.tbc') - testConfig.setTcfPath('test.tcf') - testConfig.setForceConfigurationReload(true) - testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) testConfig.setConfigOption('keepConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + - "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + - "testConfig: [forceConfigurationReload: true]") + "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder'") when: PackageConfig packageConfig = new PackageConfig(Arrays.asList( new PackageParameter('paramLabel', 'paramValue'))) @@ -202,8 +196,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { then: st.assertRoundTrip(step, "ttRunTestFolder failFast: false, " + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + - "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + - "testConfig: [forceConfigurationReload: true]") + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder'") when: AnalysisConfig analysisConfig = new AnalysisConfig() analysisConfig.setMapping('mappingName') @@ -220,8 +213,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { "recordings: [[deviceName: 'deviceName', formatDetails: 'formatDetails', " + "path: 'recording.csv', recordingGroup: 'recordingGroup']]], failFast: false, " + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + - "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + - "testConfig: [forceConfigurationReload: true]") + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder'") when: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) @@ -238,8 +230,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { "executePackageCheck: true, stopOnError: false, stopUndefinedTools: false, timeout: 0], "+ "failFast: false, " + "packageConfig: [packageParameters: [[label: 'paramLabel', value: 'paramValue']]], " + - "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + - "testConfig: [forceConfigurationReload: true]") + "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder'") } def 'Run default pipeline'() { @@ -262,14 +253,14 @@ class RunTestFolderStepIT extends IntegrationTestBase { jenkins.assertLogContains("Executing package '${testPackage.getAbsolutePath()}'", run) } - def 'Run pipeline by declaring .tbc and .tcf files in testConfig'() { + def 'Run pipeline with loadConfig as TestConfig'() { given: setupTestFolder() WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition( "node { ttRunTestFolder recursiveScan: true, " + "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'" + - ", testConfig: [tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", + ", testConfig: [forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) GroovyMock(RestApiClientFactory, global: true) @@ -287,14 +278,13 @@ class RunTestFolderStepIT extends IntegrationTestBase { jenkins.assertLogContains("-> With TestConfig=loadConfig", run) } - def 'Run pipeline by forcing configuration to reload in testConfig'() { + def 'Run pipeline with keepConfig as TestConfig'() { given: setupTestFolder() WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition( "node { ttRunTestFolder recursiveScan: true, " + - "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'" + - ", testConfig: [forceConfigurationReload: true] }", + "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'}", true)) GroovyMock(RestApiClientFactory, global: true) diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy index 60024b49..036f04b5 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy @@ -17,7 +17,8 @@ import spock.lang.Specification class LogConfigUtilTest extends Specification { private TaskListener listener private PrintStream logger - private String expectedConfigPrint + private String expectedKeepConfigPrint + private String expectedLoadConfigPrint private String expectedTbcPrint private String expectedTcfPrint private String expectedConstPrint @@ -31,7 +32,8 @@ class LogConfigUtilTest extends Specification { logger = Mock() listener = Mock(TaskListener) listener.getLogger() >> logger - expectedConfigPrint = '-> With TestConfig=loadConfig' + expectedKeepConfigPrint = '-> With TestConfig=keepConfig' + expectedLoadConfigPrint = '-> With TestConfig=loadConfig' expectedTbcPrint = '-> With TBC=test.tbc' expectedTcfPrint = '-> With TCF=test.tcf' expectedConstPrint = '-> With global constants=[[constLabel=constValue]]' @@ -46,18 +48,20 @@ class LogConfigUtilTest extends Specification { def 'Log Empty Config'() { given: TestConfig testConfig = new TestConfig() + testConfig.setConfigOption("keepConfig") LogConfigUtil logConfigUtil = new LogConfigUtil(listener, testConfig) when: logConfigUtil.log() then: - 1* logger.println(expectedConfigPrint) + 1* logger.println(expectedKeepConfigPrint) 0* logger.println(_) } def 'Log Test Config'() { given: TestConfig testConfig = new TestConfig() + testConfig.setConfigOption("loadConfig") testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) @@ -66,7 +70,7 @@ class LogConfigUtilTest extends Specification { logConfigUtil.log() then: - 1* logger.println(expectedConfigPrint) + 1* logger.println(expectedLoadConfigPrint) 1* logger.println(expectedTbcPrint) 1* logger.println(expectedTcfPrint) 1* logger.println(expectedConstPrint) @@ -76,6 +80,7 @@ class LogConfigUtilTest extends Specification { def 'Log Package Config'() { given: TestConfig testConfig = new TestConfig() + testConfig.setConfigOption("keepConfig") PackageConfig packageConfig = new PackageConfig(Arrays.asList( new PackageParameter('paramLabel', 'paramValue'))) @@ -84,7 +89,7 @@ class LogConfigUtilTest extends Specification { logConfigUtil.log() then: - 1* logger.println(expectedConfigPrint) + 1* logger.println(expectedKeepConfigPrint) 1* logger.println(expectedParamPrint) 0* logger.println(_) } @@ -92,6 +97,7 @@ class LogConfigUtilTest extends Specification { def 'Log Analysis Config'() { given: TestConfig testConfig = new TestConfig() + testConfig.setConfigOption("keepConfig") AnalysisConfig analysisConfig = new AnalysisConfig() analysisConfig.setMapping('mappingName') analysisConfig.setAnalysisName('analysisName') @@ -108,7 +114,7 @@ class LogConfigUtilTest extends Specification { logConfigUtil.log() then: - 1* logger.println(expectedConfigPrint) + 1* logger.println(expectedKeepConfigPrint) 1* logger.println(expectedAnalysisNamePrint) 1* logger.println(expectedMappingPrint) 1* logger.println(expectedRecordingPrint) From 200517521e5ca2f83a07677093ac025fc536bc03 Mon Sep 17 00:00:00 2001 From: Martin Grosche Date: Fri, 15 Nov 2024 09:24:42 +0100 Subject: [PATCH 13/18] Update loadConfig process (#164) - adapt Docs - add help information in jelly - provide TestConfig tests --- docs/AdvancedUsage.md | 4 +- .../clients/RestApiClientV2.groovy | 4 +- .../clients/model/ExecutionOrder.groovy | 16 +- .../configs/TestConfig.groovy | 49 +++-- .../steps/RunPackageStep.groovy | 6 +- .../steps/RunProjectStep.groovy | 6 +- .../util/LogConfigUtil.groovy | 15 +- .../util/ValidationUtil.groovy | 4 +- .../configs/TestConfig/config.jelly | 17 +- .../configs/TestConfig/config.properties | 9 +- .../webapp/help/TestConfig/loadConfig.html | 14 ++ .../ecutestexecution/ETV2ContainerTest.groovy | 93 ++++++++- .../configs/ExpandableConfigTest.groovy | 6 +- .../configs/TestConfigTest.groovy | 185 ++++++++++++++++++ .../steps/RunPackageStepIT.groovy | 112 +++++------ .../steps/RunProjectStepIT.groovy | 114 +++++++---- .../steps/RunTestFolderStepIT.groovy | 85 ++++---- .../util/ValidationUtilTest.groovy | 2 +- 18 files changed, 545 insertions(+), 196 deletions(-) create mode 100644 src/main/webapp/help/TestConfig/loadConfig.html create mode 100644 src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfigTest.groovy diff --git a/docs/AdvancedUsage.md b/docs/AdvancedUsage.md index 8d192c3d..fd0139bc 100644 --- a/docs/AdvancedUsage.md +++ b/docs/AdvancedUsage.md @@ -100,8 +100,8 @@ node { ### Configuration Change Options -- **Load Configuration**: Both `.tbc` and `.tcf` files must be explicitly set whenever a new configuration is needed. Setting `forceConfigurationReload` to `true` forces a configuration reload, even if the same configuration is still active. If empty, Test Configuration will be unloaded. -- **Keep Configuration**: Enabling this option retains the existing configuration for continued use throughout the execution. +- **Load Configuration**: The TestConfiguration and/or the TestBenchConfiguration files must be explicitly set whenever a new configuration is needed. If both are empty, Test Configuration will be unloaded. Setting `forceConfigurationReload` to `true` forces a configuration reload, even if the same configuration is still active. +- **Keep Configuration**: Enable this option by not specify the testConfig property for example `ttRunTestPackage '.pkg'` this option retains the existing configuration for continued use throughout the execution. ## PublishConfig diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/RestApiClientV2.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/RestApiClientV2.groovy index 309cc686..6ff8ab95 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/RestApiClientV2.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/RestApiClientV2.groovy @@ -138,14 +138,14 @@ class RestApiClientV2 extends RestApiClientV2WithIdleHandle implements RestApiCl .constants(constants) .action(ConfigurationOrder.ActionEnum.START) try { - if(executionOrder.configOption == 'loadConfig') { + if(executionOrder.loadConfig) { ConfigurationApi configApi = new ConfigurationApi(apiClient) Closure checkConfigStatus = { ModelConfiguration configuration -> configuration?.status?.key in [null, ConfigurationStatus.KeyEnum.WAITING, ConfigurationStatus.KeyEnum.RUNNING] } - if(executionOrder.loadConfig) { + if(executionOrder.forceReload) { ConfigurationOrder loadConfigOrder = new ConfigurationOrder().action(ConfigurationOrder.ActionEnum.STOP) configApi.manageConfiguration(loadConfigOrder) diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/model/ExecutionOrder.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/model/ExecutionOrder.groovy index e6015bcb..f2c686ca 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/model/ExecutionOrder.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/clients/model/ExecutionOrder.groovy @@ -18,22 +18,12 @@ class ExecutionOrder implements Serializable { public String testCasePath public AdditionalSettings additionalSetting - public String configOption public boolean loadConfig + public boolean forceReload @Nullable public String tbcPath @Nullable public String tcfPath @Nullable public List constants - ExecutionOrder(String testCasePath, AdditionalSettings additionalSetting, - String tbcPath, String tcfPath, List constants, String configOption) { - this.testCasePath = testCasePath - this.additionalSetting = additionalSetting - this.tbcPath = tbcPath - this.tcfPath = tcfPath - this.constants = constants - this.configOption = configOption - } - ExecutionOrder(String testCasePath, AdditionalSettings additionalSetting) { this.testCasePath = testCasePath this.additionalSetting = additionalSetting @@ -45,8 +35,8 @@ class ExecutionOrder implements Serializable { this.tbcPath = testConfig.tbcPath this.tcfPath = testConfig.tcfPath this.constants = testConfig.constants - this.configOption = testConfig.configOption - this.loadConfig = testConfig.forceConfigurationReload + this.loadConfig = testConfig.loadConfig + this.forceReload = testConfig.forceConfigurationReload } /** diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy index 338a43f1..c74b98b4 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig.groovy @@ -13,16 +13,18 @@ import hudson.model.AbstractDescribableImpl import hudson.model.Descriptor import hudson.util.FormValidation import jline.internal.Nullable +import net.sf.json.JSONObject import org.apache.commons.lang.StringUtils import org.kohsuke.stapler.DataBoundConstructor import org.kohsuke.stapler.DataBoundSetter import org.kohsuke.stapler.QueryParameter +import org.kohsuke.stapler.StaplerRequest class TestConfig extends AbstractDescribableImpl implements ExpandableConfig, Serializable { private static final long serialVersionUID = 1L - private static transient String configOption + private boolean loadConfig private String tbcPath private String tcfPath private boolean forceConfigurationReload @@ -34,14 +36,14 @@ class TestConfig extends AbstractDescribableImpl implements Expandab this.tbcPath = null this.constants = [] this.forceConfigurationReload = false + this.loadConfig = false } TestConfig(TestConfig config) { this() - configOption = getConfigOption() - - if(configOption == 'loadConfig') { + this.loadConfig = config.tcfPath != null || config.tbcPath != null + if(this.loadConfig) { this.tbcPath = config.getTbcPath() this.tcfPath = config.getTcfPath() this.constants = config.getConstants() @@ -56,7 +58,7 @@ class TestConfig extends AbstractDescribableImpl implements Expandab @DataBoundSetter void setTbcPath(String tbcPath) { - this.tbcPath = tbcPath || configOption == 'loadConfig' ? StringUtils.trimToEmpty(tbcPath) : null + this.tbcPath = tbcPath } @Nullable @@ -66,7 +68,7 @@ class TestConfig extends AbstractDescribableImpl implements Expandab @DataBoundSetter void setTcfPath(String tcfPath) { - this.tcfPath = tcfPath || configOption == 'loadConfig' ? StringUtils.trimToEmpty(tcfPath) : null + this.tcfPath = tcfPath } boolean isForceConfigurationReload() { @@ -87,13 +89,8 @@ class TestConfig extends AbstractDescribableImpl implements Expandab this.constants = constants ? removeEmptyConstants(constants) : [] } - @DataBoundSetter - void setConfigOption(String value) { - configOption = value - } - - String getConfigOption() { - return configOption ?: 'keepConfig' + boolean getLoadConfig() { + return loadConfig } @Override @@ -103,7 +100,7 @@ class TestConfig extends AbstractDescribableImpl implements Expandab -> tcfPath: ${tcfPath} -> forceConfigurationReload: ${forceConfigurationReload} -> constants: ${constants.each { it }} - -> configOption: ${configOption} + -> loadConfig: ${loadConfig} """.stripIndent().trim() } @@ -112,6 +109,7 @@ class TestConfig extends AbstractDescribableImpl implements Expandab TestConfig expConfig = new TestConfig() expConfig.setTbcPath(envVars.expand(tbcPath)) expConfig.setTcfPath(envVars.expand(tcfPath)) + expConfig.setForceConfigurationReload(forceConfigurationReload) expConfig.setConstants(constants.collect { constant -> constant.expand(envVars) }) return expConfig } @@ -128,12 +126,31 @@ class TestConfig extends AbstractDescribableImpl implements Expandab 'TestConfig' } + /** + * Creates a new instance of {@link TestConfig} from form data. + * If loadConfig is present and false, removes tbcPath and tcfPath from the form data + * before creating the instance to ensure they are null in the resulting configuration. + */ + @Override + TestConfig newInstance(StaplerRequest req, JSONObject formData) throws FormException { + def processedFormData = processFormData(formData) + return (TestConfig) super.newInstance(req, processedFormData); + } + FormValidation doCheckTbcPath(@QueryParameter String value) { - return ValidationUtil.validateConfigFile(value, '.tbc') + return ValidationUtil.validateFileExtension(value, '.tbc') } FormValidation doCheckTcfPath(@QueryParameter final String value) { - return ValidationUtil.validateConfigFile(value, '.tcf') + return ValidationUtil.validateFileExtension(value, '.tcf') + } + + protected static JSONObject processFormData(JSONObject formData) { + if (formData.containsKey("loadConfig") && !formData.getBoolean("loadConfig")) { + formData.remove("tbcPath") + formData.remove("tcfPath") + } + return formData } } } diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStep.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStep.groovy index 20812fba..d503fbf8 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStep.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStep.groovy @@ -159,7 +159,11 @@ class RunPackageStep extends RunTestStep { * @return the form validation */ FormValidation doCheckTestCasePath(@QueryParameter String value) { - return ValidationUtil.validateParameterizedValue(value, true) + FormValidation valid = ValidationUtil.validateParameterizedValue(value, true) + if (valid == FormValidation.ok()) { + return ValidationUtil.validateFileExtension(value, '.pkg') + } + return valid } } } diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStep.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStep.groovy index 506947c5..d2b002ce 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStep.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStep.groovy @@ -121,7 +121,11 @@ class RunProjectStep extends RunTestStep { * @return the form validation */ FormValidation doCheckTestCasePath(@QueryParameter String value) { - return ValidationUtil.validateParameterizedValue(value, true) + FormValidation valid = ValidationUtil.validateParameterizedValue(value, true) + if (valid == FormValidation.ok()) { + return ValidationUtil.validateFileExtension(value, '.prj') + } + return valid } } } diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtil.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtil.groovy index cf2bce42..a00d5f4f 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtil.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtil.groovy @@ -40,17 +40,18 @@ class LogConfigUtil implements Serializable { } private void logTestConfig() { - if (testConfig.tbcPath) { - listener.logger.println("-> With TBC=${testConfig.tbcPath}") - } - if (testConfig.tcfPath) { - listener.logger.println("-> With TCF=${testConfig.tcfPath}") + if (!testConfig.loadConfig) { + return } + + listener.logger.println("-> With TBC='${testConfig.tbcPath}'") + listener.logger.println("-> With TCF='${testConfig.tcfPath}'") + if (testConfig.constants) { listener.logger.println("-> With global constants=[${testConfig.constants.each { it.toString() }}]") } - if (testConfig.configOption) { - listener.logger.println("-> With TestConfig=${testConfig.configOption}") + if (testConfig.forceConfigurationReload) { + listener.logger.println("-> With ForceConfigurationReload=${testConfig.forceConfigurationReload}") } } diff --git a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtil.groovy b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtil.groovy index 2611895e..f6b98882 100644 --- a/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtil.groovy +++ b/src/main/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtil.groovy @@ -54,12 +54,12 @@ class ValidationUtil { return returnValue } - static validateConfigFile(String configFilePath, String fileExtension) { + static validateFileExtension(String configFilePath, String fileExtension) { FormValidation returnValue = validateParameterizedValue(configFilePath, false) if (returnValue == FormValidation.ok() && !StringUtils.isEmpty(configFilePath)) { if (!configFilePath.endsWith(fileExtension)) { returnValue = FormValidation.error( - "${configFilePath} has to be empty or of file type ${fileExtension}.") + "${configFilePath} has to be of file type '${fileExtension}'") } } return returnValue diff --git a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly index e2c4aa4c..aab5e8d6 100644 --- a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly +++ b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.jelly @@ -1,16 +1,19 @@ - - ${%keepConfig.description} - - + + + + ${%loadConfig.description} - + - + @@ -20,6 +23,6 @@ - + diff --git a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties index 5ed9aaf8..cab10bd6 100644 --- a/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties +++ b/src/main/resources/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfig/config.properties @@ -1,10 +1,9 @@ configSection.title=Test Configuration configOption.loadConfig=Load Configuration -configOption.keepConfig=Keep Configuration -loadConfig.description=Both the Test Bench Configuration and Test Configuration must be provided to load new configurations. \ - Setting forceConfigurationReload to true forces a configuration reload, even if the same configuration is still active. \ - If empty, Test Configuration will be unloaded. -keepConfig.description=Enabling this option retains the existing configuration for continued use throughout the execution. +loadConfig.description=The TestConfiguration and/or the TestBenchConfiguration files must be explicitly set whenever\ + a new configuration is needed. If both are empty, Test Configuration will be unloaded. \ + Setting forceConfigurationReload to true forces a configuration reload,\ + even if the same configuration is still active. constants.add=Add Global Constant constants.description=The configured global constants remain available throughout the entire test execution. constants.title=Global Constants diff --git a/src/main/webapp/help/TestConfig/loadConfig.html b/src/main/webapp/help/TestConfig/loadConfig.html new file mode 100644 index 00000000..2845e579 --- /dev/null +++ b/src/main/webapp/help/TestConfig/loadConfig.html @@ -0,0 +1,14 @@ + +
    + +
    +
    Unchecked (default):
    +
    Enabling this option retains the existing configuration for continued use throughout the execution.
    +
    Checked:
    +
    The TestConfiguration and/or the TestBenchConfiguration files must be explicitly set whenever + a new configuration is needed. If both are empty, Test Configuration will be unloaded. + Setting `forceConfigurationReload` to `true` forces a configuration reload, + even if the same configuration is still active. +
    +
    +
    diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy index a4408447..1cef03d3 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy @@ -16,6 +16,7 @@ import org.testcontainers.containers.GenericContainer import org.testcontainers.containers.output.Slf4jLogConsumer import org.testcontainers.containers.wait.strategy.Wait import org.testcontainers.spock.Testcontainers +import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval @Testcontainers class ETV2ContainerTest extends ETContainerTest { @@ -82,7 +83,7 @@ class ETV2ContainerTest extends ETContainerTest { jenkins.assertLogContains("[WARNING] No files found!", run) } - def "Run pipeline with keepConfig to keep the current loaded configuration."() { + def "Run pipeline and keep the current loaded configuration."() { given: "a pipeline with predefined testConfig paths" String script = """ node { @@ -121,11 +122,11 @@ class ETV2ContainerTest extends ETContainerTest { then: "expect log information about predefined paths being kept" jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) jenkins.assertLogContains("Executing package 'test.pkg'...", run) - jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) jenkins.assertLogContains("\"tbc\": {\"tbcPath\": \"test.tbc\"}, \"tcf\": {\"tcfPath\": \"test.tcf\"}", run) + jenkins.assertLogContains("\"action\": \"Start\"", run) } - def "Run pipeline with loadConfig to unload the current loaded configuration."() { + def "Run pipeline unload the current loaded configuration."() { given: "a pipeline with predefined testConfig paths" String script = """ node { @@ -164,10 +165,94 @@ class ETV2ContainerTest extends ETContainerTest { then: "expect log information about predefined paths being empty" jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) jenkins.assertLogContains("Executing package 'test.pkg'...", run) - jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) jenkins.assertLogContains("\"tbc\": {\"tbcPath\": \"\"}, \"tcf\": {\"tcfPath\": \"\"}", run) } + def "Run package execution with test config started."() { + given: "a pipeline with predefined testConfig paths" + String script = """ + node { + withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) { + httpRequest( + ignoreSslErrors: true, + responseHandle: 'NONE', + url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration", + wrapAsMultipart: false, + customHeaders: [[name: 'Content-Type', value: 'application/json']], + httpMode: 'PUT', + requestBody: '''{ + "action": "Start", + "tbc": { "tbcPath": "test.tbc" }, + "tcf": { "tcfPath": "test.tcf" } + }''' + ) + + ttRunPackage testCasePath: 'test.pkg', + testConfig: [tbcPath: 'test.tbc', tcfPath: 'test.tcf', forceConfigurationReload: true] + } + } + """.stripIndent() + + WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline") + job.setDefinition(new CpsFlowDefinition(script, true)) + + when: "scheduling a new build" + WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job) + and: + String containerLogs = etContainer.getLogs() + then: "expect log information about predefined paths being empty" + jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) + jenkins.assertLogContains("Executing package 'test.pkg'...", run) + containerLogs.contains("Stop TCF") + containerLogs.contains("Stop TBC") + containerLogs.contains("Load TCF") + containerLogs.contains("Load TBC") + containerLogs.contains("Start TCF") + containerLogs.contains("Start TBC") + } + +def "Run pipeline with forceReload test configuration"() { + given: "a pipeline with predefined testConfig paths" + String script = """ + node { + withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) { + httpRequest( + ignoreSslErrors: true, + responseHandle: 'NONE', + url: "http://\\${ET_API_HOSTNAME}:\\${ET_API_PORT}/api/v2/configuration", + wrapAsMultipart: false, + customHeaders: [[name: 'Content-Type', value: 'application/json']], + httpMode: 'PUT', + requestBody: '''{ + "action": "Start", + "tbc": { "tbcPath": "test.tbc" }, + "tcf": { "tcfPath": "test.tcf" } + }''' + ) + + ttRunPackage testCasePath: 'test.pkg', testConfig: [tbcPath: '', tcfPath: ''] + + def response = httpRequest( + ignoreSslErrors: true, + url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration" + ) + echo response.content + } + } + """.stripIndent() + + WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline") + job.setDefinition(new CpsFlowDefinition(script, true)) + + when: "scheduling a new build" + WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job) + + then: "expect log information about predefined paths being empty" + jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) + jenkins.assertLogContains("Executing package 'test.pkg'...", run) + jenkins.assertLogContains("\"tbc\": {\"tbcPath\": \"test.tbc\"}, \"tcf\": {\"tcfPath\": \"test.tcf\"}", run) + } + def "Perform provide logs step with logs"() { given: "a pipeline with test packages and log provider" String script = """ diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/ExpandableConfigTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/ExpandableConfigTest.groovy index d61b16a9..980b2ce4 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/ExpandableConfigTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/ExpandableConfigTest.groovy @@ -27,7 +27,7 @@ class ExpandableConfigTest extends Specification { AnalysisConfig analysisConfig = new AnalysisConfig() analysisConfig.setMapping('${MAPPING_NAME}') analysisConfig.setAnalysisName('${ANALYSIS_NAME}') - RecordingAsSetting recording = new RecordingAsSetting('${RECORDING_PATH}') + RecordingAsSetting recording = new RecordingAsSetting('${RECORDING_PATH}') recording.setDeviceName('deviceName') recording.setFormatDetails('formatDetails') recording.setRecordingGroup('recordingGroup') @@ -66,11 +66,12 @@ class ExpandableConfigTest extends Specification { envVars.put('TCF_PATH', 'test.tcf') envVars.put('CONSTANT_LABEL', 'constLabel') envVars.put('CONSTANT_VALUE', 'constValue') - + and: TestConfig testConfig = new TestConfig() testConfig.setTbcPath('${TBC_PATH}') testConfig.setTcfPath('${TCF_PATH}') testConfig.setConstants(Arrays.asList(new Constant('${CONSTANT_LABEL}', '${CONSTANT_VALUE}'))) + testConfig.setForceConfigurationReload(true) when: TestConfig expTestConfig = testConfig.expand(envVars) then: @@ -78,5 +79,6 @@ class ExpandableConfigTest extends Specification { expTestConfig.getTcfPath() == 'test.tcf' expTestConfig.getConstants().get(0).getLabel() == 'constLabel' expTestConfig.getConstants().get(0).getValue() == 'constValue' + expTestConfig.isForceConfigurationReload() } } diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfigTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfigTest.groovy new file mode 100644 index 00000000..55ac1132 --- /dev/null +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/configs/TestConfigTest.groovy @@ -0,0 +1,185 @@ +package de.tracetronic.jenkins.plugins.ecutestexecution.configs + +import de.tracetronic.jenkins.plugins.ecutestexecution.model.Constant +import hudson.EnvVars +import hudson.util.FormValidation +import net.sf.json.JSONObject +import spock.lang.Specification + +class TestConfigTest extends Specification { + + def "TestConfig default"() { + when: + def config = new TestConfig() + then: + !config.loadConfig + config.tbcPath == null + config.tcfPath == null + !config.forceConfigurationReload + config.constants == [] + } + + def "TestConfig with config"() { + given: + def originalConfig = new TestConfig() + originalConfig.tbcPath = "test.tbc" + originalConfig.tcfPath = "test.tcf" + originalConfig.forceConfigurationReload = true + originalConfig.constants = [new Constant("test", "value")] + when: + def createdTestConfig = new TestConfig(originalConfig) + then: + createdTestConfig.loadConfig + createdTestConfig.tbcPath == "test.tbc" + createdTestConfig.tcfPath == "test.tcf" + createdTestConfig.forceConfigurationReload + createdTestConfig.constants.size() == 1 + createdTestConfig.constants[0].label == "test" + createdTestConfig.constants[0].value == "value" + } + + def "TestConfig set loadConfig true"() { + given: + def originalConfig = new TestConfig() + originalConfig.tbcPath = "" + originalConfig.tcfPath = "" + when: + def createdTestConfig = new TestConfig(originalConfig) + then: + createdTestConfig.loadConfig + createdTestConfig.tbcPath == "" + createdTestConfig.tcfPath == "" + } + + def "Expand environment variables"() { + given: + def config = new TestConfig() + config.tbcPath = '${TBC_PATH}.tbc' + config.tcfPath = '${TCF_PATH}.tcf' + config.constants = [new Constant("test", '${TEST_VALUE}')] + and: + def envVars = new EnvVars() + envVars.put("TBC_PATH", "test") + envVars.put("TCF_PATH", "test") + envVars.put("TEST_VALUE", "value") + when: + def expandedTestConfig = config.expand(envVars) + then: + expandedTestConfig.tbcPath == 'test.tbc' + expandedTestConfig.tcfPath == 'test.tcf' + expandedTestConfig.constants[0].value == 'value' + } + + def "Remove empty constants"() { + given: + def config = new TestConfig() + config.constants = [ + new Constant("test", "value"), + new Constant("", "value1"), + new Constant(" ", "value3") + ] + expect: + config.constants.size() == 1 + config.constants[0].label == "test" + config.constants[0].value == "value" + } + + def "processFormData with loadConfig=#loadConfig"() { + given: + def formData = new JSONObject() + if (loadConfig != null) { + formData.put("loadConfig", loadConfig) + } + formData.put("tbcPath", "test.tbc") + formData.put("tcfPath", "test.tcf") + when: + def result = TestConfig.DescriptorImpl.processFormData(formData) + then: + result.containsKey("tbcPath") == shouldContainPaths + result.containsKey("tcfPath") == shouldContainPaths + where: + loadConfig || shouldContainPaths + true || true + false || false + null || true + } + + def "processFormData empty data"() { + given: + def formData = new JSONObject() + when: + def result = TestConfig.DescriptorImpl.processFormData(formData) + then: + !result.containsKey("tbcPath") + !result.containsKey("tcfPath") + } + + def "processFormData not modify other properties"() { + given: + def formData = new JSONObject() + formData.put("loadConfig", false) + formData.put("tbcPath", "test.tbc") + formData.put("tcfPath", "test.tcf") + formData.put("forceConfigurationReload", false) + formData.put("constants", []) + when: + def result = TestConfig.DescriptorImpl.processFormData(formData) + then: + !result.containsKey("tbcPath") + !result.containsKey("tcfPath") + !result["forceConfigurationReload"] + result["constants"].isEmpty() + } + + def "processFormData passing paths data"() { + given: + def formData = new JSONObject() + formData.put("loadConfig", true) + formData.put("tbcPath", tbcPath) + formData.put("tcfPath", tcfPath) + when: + def result = TestConfig.DescriptorImpl.processFormData(formData) + then: + result.getString("tbcPath") == tbcPath + result.getString("tcfPath") == tcfPath + where: + tbcPath | tcfPath + "test.tbc" | "test.tcf" + "" | "test.tcf" + "test.tbc" | "" + "" | "" + } + + def "Validate file tbc extensions"() { + given: + def descriptor = new TestConfig.DescriptorImpl() + expect: + descriptor.doCheckTbcPath(path).kind == expectedKind + where: + path | expectedKind + 'test.tbc' | FormValidation.Kind.OK + 'test.prj' | FormValidation.Kind.ERROR + '' | FormValidation.Kind.OK + null | FormValidation.Kind.OK + } + + def "Validate file tcf extensions"() { + given: + def descriptor = new TestConfig.DescriptorImpl() + expect: + descriptor.doCheckTcfPath(path).kind == expectedKind + where: + path | expectedKind + 'test.tcf' | FormValidation.Kind.OK + 'test.prj' | FormValidation.Kind.ERROR + '' | FormValidation.Kind.OK + null | FormValidation.Kind.OK + } + + def "Test descriptorImpl name"() { + given: + def descriptor = new TestConfig.DescriptorImpl() + expect: + descriptor.getDisplayName() == 'TestConfig' + } +} diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy index dea81ed2..6c760e0a 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunPackageStepIT.groovy @@ -45,8 +45,19 @@ class RunPackageStepIT extends IntegrationTestBase { def 'Default config round trip'() { given: RunPackageStep before = new RunPackageStep('test.pkg') + when: + RunPackageStep after = new StepConfigTester(jenkins).configRoundTrip(before) + then: + jenkins.assertEqualDataBoundBeans(before, after) + } + + def 'Config round trip unload test config'() { + given: + RunPackageStep before = new RunPackageStep('test.prj') + and: TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') + testConfig.setTbcPath('') + testConfig.setTcfPath('') before.setTestConfig(testConfig) when: RunPackageStep after = new StepConfigTester(jenkins).configRoundTrip(before) @@ -57,18 +68,18 @@ class RunPackageStepIT extends IntegrationTestBase { def 'Config round trip'() { given: RunPackageStep before = new RunPackageStep('test.pkg') - + and: TestConfig testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) before.setTestConfig(testConfig) - + and: PackageConfig packageConfig = new PackageConfig(Arrays.asList( new PackageParameter('paramLabel', 'paramValue'))) before.setPackageConfig(packageConfig) - + and: AnalysisConfig analysisConfig = new AnalysisConfig() analysisConfig.setMapping('mappingName') analysisConfig.setAnalysisName('analysisName') @@ -79,7 +90,7 @@ class RunPackageStepIT extends IntegrationTestBase { // recording.setMappingNames(['mapping1', 'mapping2']) analysisConfig.setRecordings(Arrays.asList(recording)) before.setAnalysisConfig(analysisConfig) - + and: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) executionConfig.setTimeout(60) @@ -97,15 +108,19 @@ class RunPackageStepIT extends IntegrationTestBase { SnippetizerTester st = new SnippetizerTester(jenkins) when: RunPackageStep step = new RunPackageStep('test.pkg') + TestConfig testConfig = new TestConfig() + testConfig.setTbcPath('') + testConfig.setTcfPath('') + step.setTestConfig(testConfig) then: - st.assertRoundTrip(step, "ttRunPackage 'test.pkg'") + st.assertRoundTrip(step, "ttRunPackage testCasePath: 'test.pkg', " + + "testConfig: [tbcPath: '', tcfPath: '']") when: - TestConfig testConfig = new TestConfig() + testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) - testConfig.setConfigOption('loadConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunPackage testCasePath: 'test.pkg', " + @@ -162,9 +177,6 @@ class RunPackageStepIT extends IntegrationTestBase { SnippetizerTester st = new SnippetizerTester(jenkins) when: RunPackageStep step = new RunPackageStep('test.pkg') - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') - step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunPackage 'test.pkg'") when: @@ -209,55 +221,51 @@ class RunPackageStepIT extends IntegrationTestBase { "testCasePath: 'test.pkg'") } - def 'Run pipeline'() { + def 'Run pipeline default'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunPackage 'test.pkg' }", true)) - + and: // assume RestApiClient is available GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() expect: WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) jenkins.assertLogContains("Executing package 'test.pkg'", run) + jenkins.assertLogNotContains("-> With", run) } - def 'Run pipeline with keepConfig as TestConfig'() { + def 'Run pipeline with default TestConfig'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg'}", true)) - + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', " + + "testConfig: [tbcPath: '', tcfPath: ''] }", true)) + and: GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() - - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') - expect: - WorkflowRun run = job.scheduleBuild2(0).get() + WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) jenkins.assertLogContains("Executing package 'test.pkg'...", run) - jenkins.assertLogContains("-> With TestConfig=keepConfig", run) + jenkins.assertLogContains("-> With TBC=''", run) + jenkins.assertLogContains("-> With TCF=''", run) } - def 'Run pipeline with loadConfig as TestConfig'() { + def 'Run pipeline with TestConfig setup'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', " + - "testConfig: [forceConfigurationReload: true, " + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) - + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) + and: GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() - - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('loadConfig') - expect: - WorkflowRun run = job.scheduleBuild2(0).get() + WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) jenkins.assertLogContains("Executing package 'test.pkg'...", run) - jenkins.assertLogContains("-> With TestConfig=loadConfig", run) - jenkins.assertLogContains("-> With TBC=test.tbc", run) - jenkins.assertLogContains("-> With TCF=test.tcf", run) + jenkins.assertLogContains("-> With TBC='test.tbc'", run) + jenkins.assertLogContains("-> With TCF='test.tcf'", run) + jenkins.assertLogContains("-> With global constants=[[constLabel=constValue]]", run) + jenkins.assertLogContains("-> With ForceConfigurationReload=true", run) } def 'Run pipeline with package check'(){ @@ -280,18 +288,15 @@ class RunPackageStepIT extends IntegrationTestBase { GroovyMock(RestApiClientFactory, global: true) def restApiClient = new RestApiClientV2('','') RestApiClientFactory.getRestApiClient(*_) >> restApiClient - + and: def mockCall = Mock(Call) mockCall.clone() >> mockCall mockCall.execute() >> MockApiResponse.getResponseBusy() >> MockApiResponse.getResponseUnauthorized() - + and: GroovySpy(ExecutionApi, global: true){ createExecution(*_) >> {restApiClient.apiClient.execute(mockCall, null)} } - - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') - + and: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunPackage 'test.pkg' }", true)) when: @@ -308,11 +313,11 @@ class RunPackageStepIT extends IntegrationTestBase { GroovyMock(RestApiClientFactory, global: true) def restApiClient = new RestApiClientV2('','') RestApiClientFactory.getRestApiClient(*_) >> restApiClient - + and: def mockCall = Mock(Call) mockCall.clone() >> mockCall mockCall.execute() >> MockApiResponse.getResponseBusy() >> MockApiResponse.getResponseUnauthorized() - + and: def manageConfigCalled = 0 GroovySpy(ConfigurationApi, global: true) { manageConfiguration(*_) >> { @@ -320,12 +325,10 @@ class RunPackageStepIT extends IntegrationTestBase { restApiClient.apiClient.execute(mockCall, new TypeToken(){}.getType()) } } - - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('loadConfig') - + and: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', testConfig: [tbcPath: 'test.tbc'] }", true)) + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: 'test.pkg', " + + "testConfig: [tbcPath: '', tcfPath: ''] }", true)) when: WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) then: @@ -342,21 +345,19 @@ class RunPackageStepIT extends IntegrationTestBase { GroovyMock(RestApiClientFactory, global: true) def restApiClient = new RestApiClientV2('','') RestApiClientFactory.getRestApiClient(*_) >> restApiClient - + and: def mockCall = Mock(Call) mockCall.clone() >> mockCall mockCall.execute() >> MockApiResponse.getResponseBusy() - + and: GroovySpy(ExecutionApi, global: true){ createExecution(*_) >> {restApiClient.apiClient.execute(mockCall, null)} getCurrentExecution() >> new Execution() } - - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') - + and: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath:'test.pkg', executionConfig:[timeout: 2]}", true)) + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath:'test.pkg', " + + "executionConfig:[timeout: 2]}", true)) expect: WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) jenkins.assertLogContains("Executing package 'test.pkg'", run) @@ -370,7 +371,8 @@ class RunPackageStepIT extends IntegrationTestBase { tempDir.deleteOnExit() String tempDirString = tempDir.getPath().replace('\\', '/') WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: '${tempDirString}/foo/test.pkg' }", true)) + job.setDefinition(new CpsFlowDefinition("node { ttRunPackage testCasePath: '" + + "${tempDirString}/foo/test.pkg' }", true)) expect: WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) jenkins.assertLogContains("ecu.test package at ${tempDirString}/foo/test.pkg does not exist!" + diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy index d72b0e7d..42e7e156 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunProjectStepIT.groovy @@ -6,6 +6,7 @@ package de.tracetronic.jenkins.plugins.ecutestexecution.steps import com.google.gson.reflect.TypeToken +import de.tracetronic.cxs.generated.et.client.model.v2.Execution import de.tracetronic.cxs.generated.et.client.model.v2.SimpleMessage import de.tracetronic.jenkins.plugins.ecutestexecution.client.MockRestApiClient import de.tracetronic.jenkins.plugins.ecutestexecution.client.MockApiResponse @@ -40,8 +41,19 @@ class RunProjectStepIT extends IntegrationTestBase { def 'Default config round trip'() { given: RunProjectStep before = new RunProjectStep('test.prj') + when: + RunProjectStep after = new StepConfigTester(jenkins).configRoundTrip(before) + then: + jenkins.assertEqualDataBoundBeans(before, after) + } + + def 'Config round trip unload test config'() { + given: + RunProjectStep before = new RunProjectStep('test.prj') + and: TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') + testConfig.setTbcPath('') + testConfig.setTcfPath('') before.setTestConfig(testConfig) when: RunProjectStep after = new StepConfigTester(jenkins).configRoundTrip(before) @@ -52,14 +64,14 @@ class RunProjectStepIT extends IntegrationTestBase { def 'Config round trip'() { given: RunProjectStep before = new RunProjectStep('test.prj') - + and: TestConfig testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) before.setTestConfig(testConfig) - + and: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) executionConfig.setStopUndefinedTools(false) @@ -77,15 +89,19 @@ class RunProjectStepIT extends IntegrationTestBase { SnippetizerTester st = new SnippetizerTester(jenkins) when: RunProjectStep step = new RunProjectStep('test.prj') + TestConfig testConfig = new TestConfig() + testConfig.setTbcPath('') + testConfig.setTcfPath('') + step.setTestConfig(testConfig) then: - st.assertRoundTrip(step, "ttRunProject 'test.prj'") + st.assertRoundTrip(step, "ttRunProject testCasePath: 'test.prj', " + + "testConfig: [tbcPath: '', tcfPath: '']") when: - TestConfig testConfig = new TestConfig() + testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) - testConfig.setConfigOption('loadConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunProject testCasePath: 'test.prj', " + @@ -111,9 +127,6 @@ class RunProjectStepIT extends IntegrationTestBase { SnippetizerTester st = new SnippetizerTester(jenkins) when: RunProjectStep step = new RunProjectStep('test.prj') - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') - step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunProject 'test.prj'") when: @@ -134,49 +147,47 @@ class RunProjectStepIT extends IntegrationTestBase { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunProject 'test.prj' }", true)) - + and: // assume RestApiClient is available GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() expect: WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) - jenkins.assertLogContains("Executing project 'test.prj'", run) + jenkins.assertLogContains("Executing project 'test.prj'", run) + jenkins.assertLogNotContains("-> With", run) } - def 'Run pipeline with loadConfig as TestConfig'() { + def 'Run pipeline with default TestConfig'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', " + - "testConfig: [forceConfigurationReload: true," + - "tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) - + "testConfig: [tbcPath: '', tcfPath: ''] }", true)) + and: GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() - - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('loadConfig') expect: - WorkflowRun run = job.scheduleBuild2(0).get() + WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) jenkins.assertLogContains("Executing project 'test.prj'...", run) - jenkins.assertLogContains("-> With TestConfig=loadConfig", run) - jenkins.assertLogContains("-> With TBC=test.tbc", run) - jenkins.assertLogContains("-> With TCF=test.tcf", run) + jenkins.assertLogContains("-> With TBC=''", run) + jenkins.assertLogContains("-> With TCF=''", run) } - def 'Run pipeline with keepConfig as TestConfig'() { + def 'Run pipeline with TestConfig setup'() { given: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj'}", true)) - + job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', " + + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) + and: GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() - - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') expect: - WorkflowRun run = job.scheduleBuild2(0).get() + WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) jenkins.assertLogContains("Executing project 'test.prj'...", run) - jenkins.assertLogContains("-> With TestConfig=keepConfig", run) + jenkins.assertLogContains("-> With TBC='test.tbc'", run) + jenkins.assertLogContains("-> With TCF='test.tcf'", run) + jenkins.assertLogContains("-> With global constants=[[constLabel=constValue]]", run) + jenkins.assertLogContains("-> With ForceConfigurationReload=true", run) } def 'Run pipeline with package check'() { @@ -199,15 +210,15 @@ class RunProjectStepIT extends IntegrationTestBase { GroovyMock(RestApiClientFactory, global: true) def restApiClient = new RestApiClientV2('','') RestApiClientFactory.getRestApiClient(*_) >> restApiClient - + and: def mockCall = Mock(Call) mockCall.clone() >> mockCall mockCall.execute() >> MockApiResponse.getResponseBusy() >> MockApiResponse.getResponseUnauthorized() - + and: GroovySpy(ExecutionApi, global: true){ createExecution(*_) >> {restApiClient.apiClient.execute(mockCall, null)} } - + and: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition("node { ttRunProject 'test.prj' }", true)) expect: @@ -223,11 +234,11 @@ class RunProjectStepIT extends IntegrationTestBase { GroovyMock(RestApiClientFactory, global: true) def restApiClient = new RestApiClientV2('','') RestApiClientFactory.getRestApiClient(*_) >> restApiClient - + and: def mockCall = Mock(Call) mockCall.clone() >> mockCall mockCall.execute() >> MockApiResponse.getResponseBusy() >> MockApiResponse.getResponseUnauthorized() - + and: def manageConfigCalled = 0 GroovySpy(ConfigurationApi, global: true) { manageConfiguration(*_) >> { @@ -235,12 +246,10 @@ class RunProjectStepIT extends IntegrationTestBase { restApiClient.apiClient.execute(mockCall, new TypeToken(){}.getType()) } } - + and: WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') - job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', testConfig: [tbcPath: 'test.tbc'] }", true)) - - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('loadConfig') + job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath: 'test.prj', " + + "testConfig: [tbcPath: '', tcfPath: ''] }", true)) when: WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) then: @@ -252,6 +261,31 @@ class RunProjectStepIT extends IntegrationTestBase { assert manageConfigCalled == 1 } + def 'Run pipeline: timeout by busy ecu.test'() { + given: + GroovyMock(RestApiClientFactory, global: true) + def restApiClient = new RestApiClientV2('','') + RestApiClientFactory.getRestApiClient(*_) >> restApiClient + and: + def mockCall = Mock(Call) + mockCall.clone() >> mockCall + mockCall.execute() >> MockApiResponse.getResponseBusy() + and: + GroovySpy(ExecutionApi, global: true){ + createExecution(*_) >> {restApiClient.apiClient.execute(mockCall, null)} + getCurrentExecution() >> new Execution() + } + and: + WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + job.setDefinition(new CpsFlowDefinition("node { ttRunProject testCasePath:'test.prj', " + + "executionConfig:[timeout: 2]}", true)) + expect: + WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()) + jenkins.assertLogContains("Executing project 'test.prj'", run) + jenkins.assertLogNotContains('ecu.test is busy', run) + jenkins.assertLogContains("Execution has exceeded the configured timeout of 2 seconds", run) + } + def 'Run pipeline: ecu.test folder at path does not exist'() { given: File tempDir = File.createTempDir() diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy index 54b69ea0..a273707d 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/steps/RunTestFolderStepIT.groovy @@ -46,8 +46,19 @@ class RunTestFolderStepIT extends IntegrationTestBase { def 'Default config round trip'() { given: RunTestFolderStep before = new RunTestFolderStep(folder.newFolder().getAbsolutePath()) + when: + RunTestFolderStep after = new StepConfigTester(jenkins).configRoundTrip(before) + then: + jenkins.assertEqualDataBoundBeans(before, after) + } + + def 'Config round trip unload test config'() { + given: + RunTestFolderStep before = new RunTestFolderStep(folder.newFolder().getAbsolutePath()) + and: TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') + testConfig.setTbcPath('') + testConfig.setTcfPath('') before.setTestConfig(testConfig) when: RunTestFolderStep after = new StepConfigTester(jenkins).configRoundTrip(before) @@ -61,18 +72,18 @@ class RunTestFolderStepIT extends IntegrationTestBase { before.setScanMode(RunTestFolderStep.ScanMode.PACKAGES_ONLY) before.setRecursiveScan(true) before.setFailFast(false) - + and: TestConfig testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) before.setTestConfig(testConfig) - + and: PackageConfig packageConfig = new PackageConfig(Arrays.asList( new PackageParameter('paramLabel', 'paramValue'))) before.setPackageConfig(packageConfig) - + and: AnalysisConfig analysisConfig = new AnalysisConfig() analysisConfig.setMapping('mappingName') analysisConfig.setAnalysisName('analysisName') @@ -82,7 +93,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { recording.setRecordingGroup('recordingGroup') analysisConfig.setRecordings(Arrays.asList(recording)) before.setAnalysisConfig(analysisConfig) - + and: ExecutionConfig executionConfig = new ExecutionConfig() executionConfig.setStopOnError(false) executionConfig.setStopUndefinedTools(false) @@ -100,9 +111,6 @@ class RunTestFolderStepIT extends IntegrationTestBase { SnippetizerTester st = new SnippetizerTester(jenkins) when: RunTestFolderStep step = new RunTestFolderStep('/TestFolder') - then: - st.assertRoundTrip(step, "ttRunTestFolder '/TestFolder'") - when: step.setRecursiveScan(true) step.setFailFast(false) step.setScanMode(RunTestFolderStep.ScanMode.PROJECTS_ONLY) @@ -111,11 +119,19 @@ class RunTestFolderStepIT extends IntegrationTestBase { "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder'") when: TestConfig testConfig = new TestConfig() + testConfig.setTbcPath('') + testConfig.setTcfPath('') + step.setTestConfig(testConfig) + then: + st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + + "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder', " + + "testConfig: [tbcPath: '', tcfPath: '']") + when: + testConfig = new TestConfig() testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) - testConfig.setConfigOption('loadConfig') step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + @@ -183,9 +199,6 @@ class RunTestFolderStepIT extends IntegrationTestBase { step.setRecursiveScan(true) step.setFailFast(false) step.setScanMode(RunTestFolderStep.ScanMode.PROJECTS_ONLY) - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') - step.setTestConfig(testConfig) then: st.assertRoundTrip(step, "ttRunTestFolder failFast: false, recursiveScan: true, " + "scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder'") @@ -233,15 +246,14 @@ class RunTestFolderStepIT extends IntegrationTestBase { "recursiveScan: true, scanMode: 'PROJECTS_ONLY', testCasePath: '/TestFolder'") } - def 'Run default pipeline'() { + def 'Run pipeline default'() { given: setupTestFolder() WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') + String folderPath = folder.getRoot().getAbsolutePath().replace('\\', '\\\\') job.setDefinition( - new CpsFlowDefinition( - "node { ttRunTestFolder '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}' }", - true)) - + new CpsFlowDefinition("node { ttRunTestFolder '${folderPath}' }", true)) + and: // assume RestApiClient is available GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() @@ -251,53 +263,50 @@ class RunTestFolderStepIT extends IntegrationTestBase { jenkins.assertLogContains('Found 1 project(s)', run) // packages will be execute first jenkins.assertLogContains("Executing package '${testPackage.getAbsolutePath()}'", run) + jenkins.assertLogNotContains("-> With", run) } - def 'Run pipeline with loadConfig as TestConfig'() { + def 'Run pipeline with default TestConfig'() { given: setupTestFolder() WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition( "node { ttRunTestFolder recursiveScan: true, " + - "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'" + - ", testConfig: [forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", - true)) - + "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}', " + + "testConfig: [forceConfigurationReload: true, tbcPath: '', tcfPath: ''] }", true)) + and: GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() - - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('loadConfig') expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains('Found 3 package(s)', run) jenkins.assertLogContains('Found 3 project(s)', run) jenkins.assertLogContains("Executing package '${subPackage.getAbsolutePath()}'", run) - jenkins.assertLogContains("-> With TBC=test.tbc", run) - jenkins.assertLogContains("-> With TCF=test.tcf", run) - jenkins.assertLogContains("-> With TestConfig=loadConfig", run) + jenkins.assertLogContains("-> With TBC=''", run) + jenkins.assertLogContains("-> With TCF=''", run) } - def 'Run pipeline with keepConfig as TestConfig'() { + def 'Run pipeline with TestConfig setup'() { given: setupTestFolder() WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline') job.setDefinition(new CpsFlowDefinition( "node { ttRunTestFolder recursiveScan: true, " + - "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}'}", - true)) - + "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}', " + + "testConfig: [constants: [[label: 'constLabel', value: 'constValue']], " + + "forceConfigurationReload: true, tbcPath: 'test.tbc', tcfPath: 'test.tcf'] }", true)) + and: GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() - - TestConfig testConfig = new TestConfig() - testConfig.setConfigOption('keepConfig') expect: WorkflowRun run = job.scheduleBuild2(0).get() jenkins.assertLogContains('Found 3 package(s)', run) jenkins.assertLogContains('Found 3 project(s)', run) jenkins.assertLogContains("Executing package '${subPackage.getAbsolutePath()}'", run) - jenkins.assertLogContains("-> With TestConfig=keepConfig", run) + jenkins.assertLogContains("-> With TBC='test.tbc'", run) + jenkins.assertLogContains("-> With TCF='test.tcf'", run) + jenkins.assertLogContains("-> With global constants=[[constLabel=constValue]]", run) + jenkins.assertLogContains("-> With ForceConfigurationReload=true", run) } def 'Run recursive scan pipeline'() { @@ -308,7 +317,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { "node { ttRunTestFolder recursiveScan: true, " + "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}' }", true)) - + and: // assume RestApiClient is available GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() @@ -328,7 +337,7 @@ class RunTestFolderStepIT extends IntegrationTestBase { "node { ttRunTestFolder scanMode: 'PROJECTS_ONLY', " + "testCasePath: '${folder.getRoot().getAbsolutePath().replace('\\', '\\\\')}' }", true)) - + and: // assume RestApiClient is available GroovyMock(RestApiClientFactory, global: true) RestApiClientFactory.getRestApiClient() >> new MockRestApiClient() diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtilTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtilTest.groovy index a5a14c13..e1466926 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtilTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/ValidationUtilTest.groovy @@ -66,7 +66,7 @@ class ValidationUtilTest extends Specification { def 'Validate config files'(String configFilePath, String fileExtension, FormValidation.Kind expectedKind) { given: - FormValidation validation = ValidationUtil.validateConfigFile(configFilePath, fileExtension) + FormValidation validation = ValidationUtil.validateFileExtension(configFilePath, fileExtension) expect: validation.kind == expectedKind where: From e8bb586c611f4549b943e5b74f55045f6f2b51aa Mon Sep 17 00:00:00 2001 From: Martin Grosche Date: Fri, 15 Nov 2024 10:01:07 +0100 Subject: [PATCH 14/18] Update for changed loadConfig handling (#164) --- .../util/LogConfigUtilTest.groovy | 65 ++++++++++++------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy index 036f04b5..d8759945 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/util/LogConfigUtilTest.groovy @@ -17,12 +17,13 @@ import spock.lang.Specification class LogConfigUtilTest extends Specification { private TaskListener listener private PrintStream logger - private String expectedKeepConfigPrint - private String expectedLoadConfigPrint private String expectedTbcPrint private String expectedTcfPrint private String expectedConstPrint private String expectedParamPrint + private String expectedEmptyTbcPrint + private String expectedEmptyTcfPrint + private String expectedForceReload private String expectedAnalysisNamePrint private String expectedMappingPrint private String expectedRecordingPrint @@ -32,13 +33,15 @@ class LogConfigUtilTest extends Specification { logger = Mock() listener = Mock(TaskListener) listener.getLogger() >> logger - expectedKeepConfigPrint = '-> With TestConfig=keepConfig' - expectedLoadConfigPrint = '-> With TestConfig=loadConfig' - expectedTbcPrint = '-> With TBC=test.tbc' - expectedTcfPrint = '-> With TCF=test.tcf' + expectedTbcPrint = '-> With TBC=\'test.tbc\'' + expectedTcfPrint = '-> With TCF=\'test.tcf\'' + expectedEmptyTbcPrint = '-> With TBC=\'\'' + expectedEmptyTcfPrint = '-> With TCF=\'\'' + expectedForceReload = '-> With ForceConfigurationReload=true' expectedConstPrint = '-> With global constants=[[constLabel=constValue]]' expectedParamPrint = '-> With package parameters=[[paramLabel=paramValue]]' expectedAnalysisNamePrint = '-> With analysis=analysisName' + expectedMappingPrint = '-> With mapping=mappingName' expectedRecordingPrint = '-> With analysis recordings=' + '[[-> path: recording.csv\n-> recordingGroup: recordingGroup\n-> ' + @@ -48,56 +51,71 @@ class LogConfigUtilTest extends Specification { def 'Log Empty Config'() { given: TestConfig testConfig = new TestConfig() - testConfig.setConfigOption("keepConfig") LogConfigUtil logConfigUtil = new LogConfigUtil(listener, testConfig) when: logConfigUtil.log() - then: - 1* logger.println(expectedKeepConfigPrint) - 0* logger.println(_) + 0* logger.println(expectedForceReload) + 0* logger.println(expectedTbcPrint) + 0* logger.println(expectedTcfPrint) } def 'Log Test Config'() { given: TestConfig testConfig = new TestConfig() - testConfig.setConfigOption("loadConfig") testConfig.setTbcPath('test.tbc') testConfig.setTcfPath('test.tcf') + testConfig.setForceConfigurationReload(true) testConfig.setConstants(Arrays.asList(new Constant('constLabel', 'constValue'))) - LogConfigUtil logConfigUtil = new LogConfigUtil(listener, testConfig) + TestConfig tcWithLoad = new TestConfig(testConfig) + and: + LogConfigUtil logConfigUtil = new LogConfigUtil(listener, tcWithLoad) when: logConfigUtil.log() - then: - 1* logger.println(expectedLoadConfigPrint) 1* logger.println(expectedTbcPrint) 1* logger.println(expectedTcfPrint) 1* logger.println(expectedConstPrint) - 0* logger.println(_) + 1* logger.println(expectedForceReload) + } + + def 'Log Test Config empty config path'() { + given: + TestConfig testConfig = new TestConfig() + testConfig.setTbcPath('') + testConfig.setTcfPath('') + TestConfig tcWithLoad = new TestConfig(testConfig) + and: + LogConfigUtil logConfigUtil = new LogConfigUtil(listener, tcWithLoad) + when: + logConfigUtil.log() + then: + 1* logger.println(expectedEmptyTcfPrint) + 1* logger.println(expectedEmptyTbcPrint) + 0* logger.println(expectedConstPrint) + 0* logger.println(expectedForceReload) } def 'Log Package Config'() { given: TestConfig testConfig = new TestConfig() - testConfig.setConfigOption("keepConfig") PackageConfig packageConfig = new PackageConfig(Arrays.asList( new PackageParameter('paramLabel', 'paramValue'))) - + and: LogConfigUtil logConfigUtil = new LogConfigUtil(listener, testConfig, packageConfig, new AnalysisConfig()) when: logConfigUtil.log() - then: - 1* logger.println(expectedKeepConfigPrint) + 0* logger.println(expectedTbcPrint) + 0* logger.println(expectedTcfPrint) + 0* logger.println(expectedConstPrint) + 0* logger.println(expectedForceReload) 1* logger.println(expectedParamPrint) - 0* logger.println(_) } def 'Log Analysis Config'() { given: TestConfig testConfig = new TestConfig() - testConfig.setConfigOption("keepConfig") AnalysisConfig analysisConfig = new AnalysisConfig() analysisConfig.setMapping('mappingName') analysisConfig.setAnalysisName('analysisName') @@ -106,18 +124,15 @@ class LogConfigUtilTest extends Specification { recording.setFormatDetails('formatDetails') recording.setRecordingGroup('recordingGroup') analysisConfig.setRecordings(Arrays.asList(recording)) - + and: LogConfigUtil logConfigUtil = new LogConfigUtil(listener, testConfig, new PackageConfig(new ArrayList()), analysisConfig) - when: logConfigUtil.log() then: - 1* logger.println(expectedKeepConfigPrint) 1* logger.println(expectedAnalysisNamePrint) 1* logger.println(expectedMappingPrint) 1* logger.println(expectedRecordingPrint) - 0* logger.println(_) } } From 00946727e7e9397b827db171084080f8e1e69ce3 Mon Sep 17 00:00:00 2001 From: Martin Grosche Date: Fri, 15 Nov 2024 10:35:55 +0100 Subject: [PATCH 15/18] Fix escaping (#164) --- .../jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy index 1cef03d3..10c1bdf2 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy @@ -219,7 +219,7 @@ def "Run pipeline with forceReload test configuration"() { httpRequest( ignoreSslErrors: true, responseHandle: 'NONE', - url: "http://\\${ET_API_HOSTNAME}:\\${ET_API_PORT}/api/v2/configuration", + url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration", wrapAsMultipart: false, customHeaders: [[name: 'Content-Type', value: 'application/json']], httpMode: 'PUT', From 04cd208a36a2e49c8d71eea7e1d60528fa1bb2a8 Mon Sep 17 00:00:00 2001 From: Martin Grosche Date: Fri, 15 Nov 2024 11:13:38 +0100 Subject: [PATCH 16/18] Delete unnecessary test (#164) --- .../ecutestexecution/ETV2ContainerTest.groovy | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy index 10c1bdf2..f53995df 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy @@ -211,48 +211,6 @@ class ETV2ContainerTest extends ETContainerTest { containerLogs.contains("Start TBC") } -def "Run pipeline with forceReload test configuration"() { - given: "a pipeline with predefined testConfig paths" - String script = """ - node { - withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) { - httpRequest( - ignoreSslErrors: true, - responseHandle: 'NONE', - url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration", - wrapAsMultipart: false, - customHeaders: [[name: 'Content-Type', value: 'application/json']], - httpMode: 'PUT', - requestBody: '''{ - "action": "Start", - "tbc": { "tbcPath": "test.tbc" }, - "tcf": { "tcfPath": "test.tcf" } - }''' - ) - - ttRunPackage testCasePath: 'test.pkg', testConfig: [tbcPath: '', tcfPath: ''] - - def response = httpRequest( - ignoreSslErrors: true, - url: "http://\${ET_API_HOSTNAME}:\${ET_API_PORT}/api/v2/configuration" - ) - echo response.content - } - } - """.stripIndent() - - WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline") - job.setDefinition(new CpsFlowDefinition(script, true)) - - when: "scheduling a new build" - WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job) - - then: "expect log information about predefined paths being empty" - jenkins.assertLogContains("Response Code: HTTP/1.1 200 OK", run) - jenkins.assertLogContains("Executing package 'test.pkg'...", run) - jenkins.assertLogContains("\"tbc\": {\"tbcPath\": \"test.tbc\"}, \"tcf\": {\"tcfPath\": \"test.tcf\"}", run) - } - def "Perform provide logs step with logs"() { given: "a pipeline with test packages and log provider" String script = """ From ea3d5b9bc4bde67448c19e24623cb5c759f3bb5c Mon Sep 17 00:00:00 2001 From: Martin Grosche Date: Fri, 15 Nov 2024 11:25:40 +0100 Subject: [PATCH 17/18] Rename test (#164) --- .../jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy index f53995df..dff9448f 100644 --- a/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy +++ b/src/test/groovy/de/tracetronic/jenkins/plugins/ecutestexecution/ETV2ContainerTest.groovy @@ -16,7 +16,6 @@ import org.testcontainers.containers.GenericContainer import org.testcontainers.containers.output.Slf4jLogConsumer import org.testcontainers.containers.wait.strategy.Wait import org.testcontainers.spock.Testcontainers -import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval @Testcontainers class ETV2ContainerTest extends ETContainerTest { @@ -168,7 +167,7 @@ class ETV2ContainerTest extends ETContainerTest { jenkins.assertLogContains("\"tbc\": {\"tbcPath\": \"\"}, \"tcf\": {\"tcfPath\": \"\"}", run) } - def "Run package execution with test config started."() { + def "Run package execution with test config force reload"() { given: "a pipeline with predefined testConfig paths" String script = """ node { From 12c76729b60f4a9d5f266fa603c952f8f1425e97 Mon Sep 17 00:00:00 2001 From: Martin Grosche Date: Fri, 15 Nov 2024 11:45:29 +0100 Subject: [PATCH 18/18] Fix Typos (#164) --- docs/AdvancedUsage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/AdvancedUsage.md b/docs/AdvancedUsage.md index fd0139bc..5ff013de 100644 --- a/docs/AdvancedUsage.md +++ b/docs/AdvancedUsage.md @@ -101,7 +101,7 @@ node { ### Configuration Change Options - **Load Configuration**: The TestConfiguration and/or the TestBenchConfiguration files must be explicitly set whenever a new configuration is needed. If both are empty, Test Configuration will be unloaded. Setting `forceConfigurationReload` to `true` forces a configuration reload, even if the same configuration is still active. -- **Keep Configuration**: Enable this option by not specify the testConfig property for example `ttRunTestPackage '.pkg'` this option retains the existing configuration for continued use throughout the execution. +- **Keep Configuration**: Enable this option by not specifying the testConfig property, for example `ttRunTestPackage '.pkg'` this option retains the existing configuration for continued use throughout the execution. ## PublishConfig