github.com/xgoffin/jenkins-library@v1.154.0/vars/piperPipelineStagePerformance.groovy (about)

     1  import com.sap.piper.ConfigurationHelper
     2  import com.sap.piper.GenerateStageDocumentation
     3  import com.sap.piper.StageNameProvider
     4  import com.sap.piper.Utils
     5  import groovy.transform.Field
     6  
     7  import static com.sap.piper.Prerequisites.checkScript
     8  
     9  @Field String STEP_NAME = getClass().getName()
    10  @Field String TECHNICAL_STAGE_NAME = 'performanceTests'
    11  
    12  @Field Set GENERAL_CONFIG_KEYS = []
    13  @Field STAGE_STEP_KEYS = [
    14      /** Executes Gatling performance tests */
    15      'gatlingExecuteTests',
    16      /** Can perform both to cloud foundry and neo targets. Preferred over cloudFoundryDeploy and neoDeploy, if configured. */
    17      'multicloudDeploy',
    18  ]
    19  @Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
    20  @Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
    21  
    22  /**
    23   * In this stage important performance-relevant checks will be conducted.<br />
    24   *
    25   * The stage will execute a Gatling test, if the step `gatlingExecuteTests` is configured.
    26   */
    27  @GenerateStageDocumentation(defaultStageName = 'Performance')
    28  void call(Map parameters = [:]) {
    29  
    30      def script = checkScript(this, parameters) ?: this
    31      def utils = parameters.juStabUtils ?: new Utils()
    32      def stageName = StageNameProvider.instance.getStageName(script, parameters, this)
    33  
    34      Map config = ConfigurationHelper.newInstance(this)
    35          .loadStepDefaults()
    36          .mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
    37          .mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS)
    38          .mixin(parameters, PARAMETER_KEYS)
    39          .addIfEmpty('multicloudDeploy', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.multicloudDeploy)
    40          .addIfEmpty('gatlingExecuteTests', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.gatlingExecuteTests)
    41          .use()
    42  
    43      piperStageWrapper (script: script, stageName: stageName) {
    44  
    45          // telemetry reporting
    46          utils.pushToSWA([step: STEP_NAME], config)
    47  
    48          if (config.multicloudDeploy) {
    49              durationMeasure(script: script, measurementName: 'deploy_performance_multicloud_duration') {
    50                  multicloudDeploy(script: script, stage: stageName)
    51              }
    52          }
    53  
    54          if (config.gatlingExecuteTests) {
    55              durationMeasure(script: script, measurementName: 'gatling_duration') {
    56                  gatlingExecuteTests script: script
    57              }
    58          }
    59      }
    60  }