subp
May 28, 2024, 11:32am
1
Hi,
My question is how to generate an output html report using k6 docker image within Azure pipeline
JSON files are generated but not html reports:
I tried using
"import { htmlReport } from “K6 Load Test: <%= title %> ” - Working fine in local
Ref: GitHub - benc-uk/k6-reporter: Output K6 test run results as formatted & easy to read HTML reports
but while in azure - not sure
A. where this file is getting stored
B. how to export back the result file;
My code:
Thanks for any help
Regards
subp
May 29, 2024, 8:38am
2
Able to generate in the following ways
A. using " GitHub - benc-uk/k6-reporter: Output K6 test run results as formatted & easy to read HTML reports "
B. Converting JSON to html
Test Code - Script file:
import http from ‘k6/http’;
import { check, sleep } from ‘k6’;
// I have downloaded the files in my local directory and then committed all to Azure repo
import { htmlReport } from ‘./K6HTMLReportExporter_v2.js’;
import { textSummary } from ‘./indexReport.js’;
export let options = {
vus: 1,
iterations: 1,
duration: ‘3s’
};
export default function () {
let res = http.get(‘https://abcdef-upstream.mmcl-nrmp2-syst.aws.nmopqrst.net/jwt-service/getJwtToken ’);
check(res, { ‘status was 200’: (r) => r.status == 200 });
sleep(1);
}
export function handleSummary(data) {
return {
“/k6Report/result.html”: htmlReport(data)
};
}
Yml File:
stages:
stage: E2E_Perf_TEST
jobs:
job: K6
displayName: Testing K6 Azure Devops
pool:
name: default-containers
steps:
- script: |
echo $PWD
ls -ltr
- script: docker run -i --rm
-v $PWD:/home/k6/
-v $PWD/k6Report:/k6Report
–workdir “/home/k6/”
joined-docker.artifactory.abcdefgh.net/grafana/k6:0.50.0
run
./Basic_feeXpart_GET.js
–summary-export=/k6Report/result.json
- task: PublishBuildArtifacts@1
condition: succeededOrFailed()
inputs:
PathtoPublish: 'k6Report/'
ArtifactName: 'k6Report'
- task: PublishTestResults@1
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '/k6Report/result.html'
testRunTitle: 'Trial Report'
This will result 2 files
A. result.html
B. result.json. Then used “k6-web-dashboard” to generate the output