Created
October 9, 2020 15:22
-
-
Save neox5/0149ab4ede7dd79acec7b330b53482c3 to your computer and use it in GitHub Desktop.
Azure DevOps pipeline for an automated performance test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger: | |
- none | |
pool: | |
vmImage: 'ubuntu-20.04' | |
parameters: | |
- name: runLoadTest | |
type: boolean | |
default: true | |
- name: updateNeoloadProject | |
type: boolean | |
default: true | |
- name: keptnEvaluation | |
type: boolean | |
default: true | |
- name: nlwebApiUrl | |
type: string | |
default: 'http://api.<NLWEB-HOST-IP>.nip.io/' | |
- name: nlwebApiToken | |
type: string | |
default: '<NLWEB-API-TOKEN>' | |
- name: nlwebWorkspace | |
type: string | |
default: 'Default Workspace' | |
values: | |
- 'Default Workspace' | |
- name: nlwebTest | |
type: string | |
default: 'ttt-register' | |
values: | |
- 'ttt-register' | |
- name: nlwebResultName | |
type: string | |
default: 'ttt-register' | |
- name: nlwebZoneId | |
type: string | |
default: 'ftFDo' | |
values: | |
- 'defaultzone' | |
- 'ftFDo' | |
- name: nlwebLoadGenerators | |
type: number | |
default: 1 | |
- name: nlwebScenario | |
type: string | |
default: 'ConstantMax10_90s' | |
values: | |
- 'ConstantMax10_90s' | |
- 'ConstantMax10_3min' | |
- 'ConstantMax10_10min' | |
- 'ConstantMax10_30min' | |
- 'ConstantMax10_1h' | |
- 'RampUpMax10_3min' | |
- 'Stepload20_20min' | |
jobs: | |
- job: RunNeoloadWebTest | |
displayName: Run Neoload Test | |
condition: eq('${{ parameters.runLoadTest }}', true) | |
steps: | |
- task: UsePythonVersion@0 | |
inputs: | |
versionSpec: '3.8' | |
addToPath: true | |
architecture: 'x64' | |
- task: Bash@3 | |
displayName: Install NeoLoad CLI | |
continueOnError: false | |
inputs: | |
targetType: 'inline' | |
script: | | |
pip install neoload | |
neoload --version | |
- task: Bash@3 | |
displayName: Neoload Web Login | |
continueOnError: false | |
inputs: | |
targetType: 'inline' | |
script: 'neoload login --url "${{parameters.nlwebApiUrl}}" --workspace "${{parameters.nlwebWorkspace}}" "${{parameters.nlwebApiToken}}"' | |
- task: Bash@3 | |
displayName: Neoload Project Upload | |
condition: eq('${{ parameters.updateNeoloadProject }}', true) | |
continueOnError: false | |
inputs: | |
targetType: 'inline' | |
script: | | |
echo "Adds all files to archive" | |
/usr/bin/zip -rq ttt-keptn.zip * | |
echo "Remove pipeline.yml file from archive, otherwise neoload will complain :P" | |
/usr/bin/zip -d ttt-keptn.zip ttt-pipeline.yml | |
neoload project --path ttt-keptn.zip upload "${{parameters.nlwebTest}}" | |
- task: Bash@3 | |
displayName: Neoload Test Configuration | |
continueOnError: false | |
inputs: | |
targetType: 'inline' | |
script: 'neoload test-settings --zone "${{parameters.nlwebZoneId}}" --lgs ${{parameters.nlwebLoadGenerators}} --scenario "${{parameters.nlwebScenario}}" patch "${{parameters.nlwebTest}}"' | |
- task: Bash@3 | |
displayName: SetStartDate | |
condition: eq('${{ parameters.keptnEvaluation }}', true) | |
continueOnError: true | |
inputs: | |
targetType: 'inline' | |
script: | | |
STARTDATE=$(date +%Y-%m-%dT%H:%M:%S%:z) | |
echo "##vso[task.setvariable variable=startDate;]$STARTDATE" | |
- task: Bash@3 | |
displayName: Run Neoload Test | |
continueOnError: true | |
inputs: | |
targetType: 'inline' | |
script: 'neoload run --name "${{parameters.nlwebResultName}}"' | |
- task: Bash@3 | |
displayName: SetEndDate | |
condition: eq('${{ parameters.keptnEvaluation }}', true) | |
continueOnError: true | |
inputs: | |
targetType: 'inline' | |
script: | | |
ENDDATE=$(date +%Y-%m-%dT%H:%M:%S%:z) | |
echo "##vso[task.setvariable variable=endDate;]$ENDDATE" | |
- task: PrepareKeptnEnvTask@1 | |
condition: eq('${{ parameters.keptnEvaluation }}', true) | |
inputs: | |
keptnApiEndpoint: 'Keptn on ubuntu-1804' | |
project: 'ttt' | |
service: 'ttt-app-pac' | |
stage: 'dev' | |
autoCreate: false | |
monitoring: 'dynatrace' | |
- task: SendKeptnEventTask@2 | |
condition: eq('${{ parameters.keptnEvaluation }}', true) | |
inputs: | |
keptnApiEndpoint: 'Keptn on ubuntu-1804' | |
project: 'ttt' | |
service: 'ttt-app-pac' | |
stage: 'dev' | |
eventType: 'startEvaluation' | |
start: '$(startDate)' | |
end: '$(endDate)' | |
keptnContextVar: 'keptnContext' | |
- task: WaitForKeptnEventTask@1 | |
condition: eq('${{ parameters.keptnEvaluation }}', true) | |
inputs: | |
keptnApiEndpoint: 'Keptn on ubuntu-1804' | |
bridgeURL: 'http://keptn.<KEPTN-HOST-IP>.nip.io/bridge' | |
waitForEventType: 'evaluationDone' | |
timeout: '3' | |
keptnContextVar: 'keptnContext' | |
markBuildOnError: 'FAILED' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment