grafana / k6

A modern load testing tool, using Go and JavaScript - https://k6.io
GNU Affero General Public License v3.0
26.02k stars 1.27k forks source link

Use K6 as a Go Module #3591

Closed nilskch closed 9 months ago

nilskch commented 9 months ago

Feature Description

First of all, thank you very much for this awesome tool! I have used it heavily in the last six months and love it!

I recently wrote my bachelor's thesis, which involved writing a tool for performance testing and modeling. I incremented the number of VUsers over time and logged different performance metrics to see how they changed (to model different backend performances). To do so, I wrote a program in Go that runs in the K6 Docker container and uses the K6 CLI to start a load test. I did that in a loop and incremented the VUsers via a parameter. This is obviously not ideal.

It would be very nice to start a load test directly from a Go program by using a Go module instead of making a CLI call from a Go program.

Is this already possible, and I just didn't see how?

If not, would it be hard to enable this? I guess you could provide a new go module as an interface to start and configure performance tests. In reality, things are often much more complicated, so what do you think?

Suggested Solution (optional)

No response

Already existing or connected issues / PRs (optional)

No response

codebien commented 9 months ago

It would be very nice to start a load test directly from a Go program by using a Go module instead of making a CLI call from a Go program. Is this already possible, and I just didn't see how?

No, you're correct here. It is out of the scope of the project. k6 is intended to be used as a tool and not directly as a Go library. However, it doesn't mean that it wouldn't be possible, k6 is open source, and its Go module is available so potentially with a lot of effort it would be possible. But it is relevant to mention that, as k6 is not intended to be a Go library, the project doesn't have any stability guarantee around it. It means we can break the Go API at any moment, the unique exceptions are around the JavaScript modules and Outputs that are used for creating extensions.

Also, important to mention, that k6 uses AGPL license that should be permissive enough for most of the usage in open source and research cases, but it has some limitations so make sure you are aware of them.

If not, would it be hard to enable this?

Yes, it is. Unfortunately, software is not only writing the code. For the scale of k6 then it would mean we need to guarantee a stability policy and relative maintenance that would require an important effort in a non-core area.

Regarding the solution space: I don't know if it would be enough for your case, it has a bunch of limitations, but maybe you can take a look into the externally-controlled executor.

nilskch commented 9 months ago

Thanks for the quick response! I personally do not have a use case anymore since I finished the thesis. I just wanted to pitch an idea for a feature that could be useful for others and to offer help implementing it.

I understand that this is out of scope and appreciate your work and effort!

I will close this issue.

codebien commented 9 months ago

@nilskch thanks for reporting. It's important to hear the community's voice and, in any case, we will keep it in mind. :bow: Good luck with your thesis! :rocket: