From 647e1ef0bd2a6366a3dd3dc81ec497c50d98ff5d Mon Sep 17 00:00:00 2001 From: Florian Wilhelm Date: Fri, 13 Nov 2020 16:31:45 +0100 Subject: [PATCH] Add deployment to performance tests stage and enable stage (#2370) Co-authored-by: Kevin Hudemann --- .../com.sap.piper/pipeline/stageDefaults.yml | 11 ++++++++++- .../com.sap.piper/pipeline/stashSettings.yml | 6 ++++++ .../PiperPipelineStagePerformanceTest.groovy | 17 ++++++++++++++++- vars/piperPipelineStagePerformance.groovy | 9 +++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/resources/com.sap.piper/pipeline/stageDefaults.yml b/resources/com.sap.piper/pipeline/stageDefaults.yml index 14103acfd..9aeee653b 100644 --- a/resources/com.sap.piper/pipeline/stageDefaults.yml +++ b/resources/com.sap.piper/pipeline/stageDefaults.yml @@ -70,7 +70,16 @@ stages: - 'userTokenCredentialsId' - 'whitesource/userTokenCredentialsId' - 'whitesourceUserTokenCredentialsId' - Performance: {} + Performance: + stepConditions: + multicloudDeploy: + configKeys: + - 'cfTargets' + - 'neoTargets' + gatlingExecuteTests: + filePatternFromConfig: 'pomPath' + configKeys: + - 'appUrls' Compliance: {} Promote: stepConditions: diff --git a/resources/com.sap.piper/pipeline/stashSettings.yml b/resources/com.sap.piper/pipeline/stashSettings.yml index 3491e648f..7d8d97eae 100644 --- a/resources/com.sap.piper/pipeline/stashSettings.yml +++ b/resources/com.sap.piper/pipeline/stashSettings.yml @@ -27,6 +27,12 @@ Acceptance: - deployDescriptor stashes: [] +Performance: + unstash: + - source + - buildResult + stashes: [] + Release: unstash: - buildResult diff --git a/test/groovy/templates/PiperPipelineStagePerformanceTest.groovy b/test/groovy/templates/PiperPipelineStagePerformanceTest.groovy index 333b517ba..6cb6ed44b 100644 --- a/test/groovy/templates/PiperPipelineStagePerformanceTest.groovy +++ b/test/groovy/templates/PiperPipelineStagePerformanceTest.groovy @@ -37,6 +37,10 @@ class PiperPipelineStagePerformanceTest extends BasePiperTest { stepsCalled.add('gatlingExecuteTests') stepParameters.gatlingExecuteTests = m }) + helper.registerAllowedMethod('multicloudDeploy', [Map.class], {m -> + stepsCalled.add('multicloudDeploy') + stepParameters.multicloudDeploy = m + }) } @Test @@ -45,7 +49,7 @@ class PiperPipelineStagePerformanceTest extends BasePiperTest { script: nullScript, juStabUtils: utils, ) - assertThat(stepsCalled, not(anyOf(hasItems('gatlingExecuteTests')))) + assertThat(stepsCalled, not(anyOf(hasItems('gatlingExecuteTests', 'multicloudDeploy')))) } @Test @@ -58,4 +62,15 @@ class PiperPipelineStagePerformanceTest extends BasePiperTest { assertThat(stepsCalled, hasItems('gatlingExecuteTests')) assertNotNull(stepParameters.gatlingExecuteTests) } + + @Test + void testMulticloudDeployTests() { + jsr.step.piperPipelineStagePerformance( + script: nullScript, + juStabUtils: utils, + multicloudDeploy: true + ) + assertThat(stepsCalled, hasItems('multicloudDeploy')) + assertNotNull(stepParameters.multicloudDeploy) + } } diff --git a/vars/piperPipelineStagePerformance.groovy b/vars/piperPipelineStagePerformance.groovy index a4ed13ec1..09fa36851 100644 --- a/vars/piperPipelineStagePerformance.groovy +++ b/vars/piperPipelineStagePerformance.groovy @@ -13,6 +13,8 @@ import static com.sap.piper.Prerequisites.checkScript @Field STAGE_STEP_KEYS = [ /** Executes Gatling performance tests */ 'gatlingExecuteTests', + /** Can perform both to cloud foundry and neo targets. Preferred over cloudFoundryDeploy and neoDeploy, if configured. */ + 'multicloudDeploy', ] @Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS) @Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS @@ -34,6 +36,7 @@ void call(Map parameters = [:]) { .mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS) .mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS) .mixin(parameters, PARAMETER_KEYS) + .addIfEmpty('multicloudDeploy', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.multicloudDeploy) .addIfEmpty('gatlingExecuteTests', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.gatlingExecuteTests) .use() @@ -42,6 +45,12 @@ void call(Map parameters = [:]) { // telemetry reporting utils.pushToSWA([step: STEP_NAME], config) + if (config.multicloudDeploy) { + durationMeasure(script: script, measurementName: 'deploy_performance_multicloud_duration') { + multicloudDeploy(script: script, stage: stageName) + } + } + if (config.gatlingExecuteTests) { durationMeasure(script: script, measurementName: 'gatling_duration') { gatlingExecuteTests script: script