Push Python, k6 extensions with the Python script to a Docker image

Hello,

Actual solution:
I have created a volume claim in a Kubernetes cluster where my entire performance test project is stored. I have prepared a TestRun YAML file in which I’m pushing my Docker image created according to these docs. This solution works well.

Proper solution:
I want to run my performance test in a Kubernetes cluster as mentioned in the actual solution. After my performance test is finished, it will generate an HTML report file with results in the handleSummary function. The HTML report will be generated, for example, in the /tmp/ folder in the running Kubernetes pod. Then, I want to run a Python script that will retrieve the HTML reports, parse them, and generate results in a reporting tool.

I would like to receive advice from you if there is a way to push Python, k6 extensions with the Python script to a Docker image and then somehow run the test via the TestRun YAML file. After the test is finished, run a Python script to push the results to the reporting tool.

Thank you in advance :slight_smile:

Hi @matomajzlik,

Isn’t it suitable for you to use an output extension instead of the test-end-summary to stream the metrics into a service e.g.: prometheus?

There are a lot of services you could use:

Hi @bandorko,

thank you for your answer. I have prepared solution for pushing real time metrics into InfluxDb.
I want to push aggregated results (obtained from HTML) to ReportPortal.

@matomajzlik

I see. Then my suggestion would be using xk6-exec like this:

script.js:

import exec from 'k6/x/exec';

export default function(){
  console.log("Iteration")
}

export function handleSummary(data){
  console.log(exec.command("python",["script.py",JSON.stringify(data)]));
}

script.py:

import sys
print("this is the summary in python:",sys.argv[1])

To use something like that in kubernetes, you have to build a custom k6 docker image with all the needed dependencies, like: python, xk6-exec, xk6-output-influxdb …
More info on using extensions with k6-operator is here: GitHub - grafana/k6-operator: An operator for running distributed k6 tests.

Hi @bandorko ,

thank you for your suggestion. I will check it and provide a response to confirm if it’s working or not