GitLab Docker Image and BlazeMeter-related Functions
The Docker image for GitLab facilitates the execution of various functions that you can use for testing with BlazeMeter. This topic outlines each of these functions, accompanied by the corresponding syntax to use in the .gitlab-ci.yml file.
Create a New Test
To create and execute a new test in BlazeMeter, configure .gitlab-ci.yml as follows:
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" createTest: "true" inputStartFile: "xxxx" testName: "xxxx" projectId: "xxxx" continuePipeline: "false" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -createTest $createTest -testName $testName -projectId $projectId - inputStartFile $inputStartFile -continuePipeline $continuePipeline"
Run an Existing Test
To run an existing BlazeMeter test, configure .gitlab-ci.yml as follows:
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" continuePipeline: "false" testIdInput: "xxxx" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -testIdInput $testIdInput -continuePipeline $continuePipeline"
Add or Replace Existing Test Files
Before running a test, replace or add the dependency files.
If an existing BlazeMeter test requires dependent files, to upload those files to an existing test and run it, configure .gitlab-ci.yml as follows.
If your test requires multiple files to be uploaded, you must put all those files under a folder and reference the folder path inside the inputAllFiles variable.
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" testIdInput: "xxxx" inputAllFiles: "xxxx" uploadFileCheck: "true" continuePipeline: "false" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -testIdInput $testIdInput -uploadFileCheck $uploadFileCheck - inputAllFiles $inputAllFiles -continuePipeline $continuePipeline"
Replace or Add the Configuration Files (main test file) Before Running a Test
To update the main test file of an existing test and run it, configure .gitlab-ci.yml as follows:
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" testIdInput: "xxxx" uploadFileCheck: "true" inputStartFile: "xxxx" continuePipeline: "false" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -testIdInput $testIdInput -uploadFileCheck $uploadFileCheck - inputStartFile $inputStartFile -continuePipeline $continuePipeline"
Update Variables in Taurus Files
If your test is defined as a Taurus .yaml file and it contains variables that you would like to be updated at run time, use the envVariable feature.
Let’s assume you have a variable called username in your Taurus YAML file and you want the value of that variable to be set to jdoe. You can do so by passing the key-value pair as username:jdoe, which then replaces the variable username in your .yml file with the value jdoe.
This function works only in combination with the inputStartFile variable, which means that the file gets updated locally on the runner and the updated file gets uploaded to your BlazeMeter test before execution.
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" createTest: "true" inputStartFile: "xxxx" testName: "xxxx" projectId: "xxxx" envVariable: '{"key":"value"}' continuePipeline: "false" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -createTest $createTest -testName $testName -projectId $projectId - inputStartFile $inputStartFile -envVariable $envVariable - continuePipeline $continuePipeline"
Run Existing Test and Download Artifacts Log File
To run an existing test and then download the artifacts to the CI Project directory, configure .gitlab-ci.yml as follows:
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" testIdInput: "xxxx" continuePipeline: "false" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -testIdInput $testIdInput -continuePipeline $continuePipeline" - ls -a ./tmp/artifacts artifacts: paths: - $CI_PROJECT_DIR/tmp/artifacts
Add JMeter Properties
If your test is JMeter-based and you want to add or update a JMeter property, you can do so by using the jmeterProperties variable as shown in the example below.
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" testIdInput: "xxxx" continuePipeline: "false" jmeterProperties: "key=value" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -testIdInput $testIdInput -continuePipeline $continuePipeline - jmeterProperties $jmeterProperties" - ls -a ./tmp/artifacts artifacts: paths: - $CI_PROJECT_DIR/tmp/artifacts
Customize a Report Name
Use the reportName parameter to give a name to your test report.
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" testIdInput: "xxxx" reportName: "xxxx" continuePipeline: "false" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -testIdInput $testIdInput -reportName $reportName -continuePipeline $continuePipeline"
Add Notes to your Test Report
To add notes to your test report, use the notes parameter.
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" testIdInput: "xxxx" note: "xxxx" continuePipeline: "false" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -testIdInput $testIdInput -note $note -continuePipeline $continuePipeline"
Override the Iterations Configuration in Existing JMeter Tests
If your JMeter test is iteration-based and not duration-based, you can override the iterations value in the JMX through the use of the variables iterationsConfig and iterations as shown in the example below.
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" testIdInput: "xxxx" iterationsConfig: "true" iterations: "xxxx" continuePipeline: "false" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -testIdInput $testIdInput -iterationsConfig $iterationsConfig - iterations $iterations -continuePipeline $continuePipeline"
Override the Iterations Configuration in JMX and Create a New Test
This function is similar to the previous one except that it also creates a new test on the fly.
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" createTest: "true" inputStartFile: "xxxx" testName: "xxxx" projectId: "xxxx" iterationsConfig: "true" iterations: "xxxx" continuePipeline: "false" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -createTest $createTest -inputStartFile $inputStartFile -testName $testName -projectId $projectId -iterationsConfig $iterationsConfig - iterations $iterations -continuePipeline $continuePipeline"
Override the Load Configuration Parameters - Concurrency, Ramp Up and Duration
To override the load configuration parameters, configure .gitlab-ci.yml as follows:
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" createTest: "true" inputStartFile: "xxxx" testName: "xxxx" projectId: "xxxx" totalUsers: "xxxx" duration: "xxxx" rampUp: "xxxx" continuePipeline: "false" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -createTest $createTest -inputStartFile $inputStartFile -testName $testName -projectId $projectId -totalUsers $totalUsers -duration $duration -rampUp $rampUp -continuePipeline $continuePipeline"
Update Test Data
This function is specific to Scriptless Functional Tests that leverage the Test Data feature. When you use the Test Data module in your tests, you are basically referencing variables in your test that are managed by the Test Data module. These variable values can be overridden from your pipeline by use of the modelData parameter. It requires the use of key-value pairs as shown below.
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" testIdInput: "xxxx" modelData: '{"key":"value"}' continuePipeline: "false" job 0: stage: deploy script: - "pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret -testIdInput $testIdInput -modelData $modelData -continuePipeline $continuePipeline"
Run an Existing Test by Passing the Test Name instead of Test ID
You can execute tests by passing the Test Name as opposed to a Test ID as shown below. If the Test Name passed does not exist on the BlazeMeter side, the job fails with an error message.
image: blazerunner/blazemeter:gitlab variables: apiKey: "xxxx" apiSecret: "xxxx" continuePipeline: "false" showTailLog: "false" testName: "xxxx" projectId: "xxxx" testRunByTestName: "true" job 0: stage: deploy script: - pwsh /Blazemeter-run.ps1 -apiKey $apiKey -apiSecret $apiSecret - continuePipeline $continuePipeline -showTailLog $showTailLog -testName $testName -projectId $projectId -testRunByTestName $testRunByTestName - ls -a ./tmp/artifacts artifacts: paths: - $CI_PROJECT_DIR/tmp/artifacts