-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test suites / execute multiple scripts with k6 #1342
Comments
I'll give an example why I think points 1 and 2 above cover 80-90% of the use cases. Here's how, if we add the import test01 from "./test01.js";
import test02 from "./test02.js";
import test03 from "./test03.js";
export let options = {
execution: {
"test1": {
type: "composite",
exec: "test01.default",
options: test01.options,
},
"test2": {
type: "composite",
exec: "test01.default",
options: test02.options,
startAfter: "test1",
},
"test3": {
type: "composite",
exec: "test02.default",
options: test02.options,
startAfter: "test2",
},
}
} You can execute any of the individual scripts like And you'd be able to do something similar even without the |
I like this proposal, especially passing multiple scripts to The idea for the One improvement might be to pass actual functions to import * as test1 from "./test1.js";
import * as test2 from "./test2.js";
import * as test3 from "./test3.js";
export let options = {
execution: {
"test1": {
type: "composite",
exec: test1.default,
options: test1.options,
},
... This seems intuitive and would avoid the parsing/matching unpleasantries if it were a string. |
I may be wrong, but I think this refactoring will actually reduce the complexity somewhat, at least when it comes to the script execution. We'll see when we come to it.
Unfortunately, this probably wouldn't be possible. In the init context, k6 has to get the exported script |
While that is true I wonder if it is worth the trouble and (somewhat) inconsistency of having the go code figure out that In the same vein, I would like to point out that I am not certain we can just call |
Thinking about an unrelated issue, I realized that my initial plan above has a major problem - Most executors have a specified duration that they can't deviate from. For But iteration-based executors, currently only There are solutions to this, like reserving the max potentially required VUs for the overlapping periods, but they add significant complexity that probably isn't worth it at this point. Instead, I propose that we either initially implement |
Thinking some more, VU requirement calculations for a Essentially, the VU requirements for a So, while I now have a good idea how to solve the |
Hi, I'm wondering how can I run
but it's not works as expected, could you please help me? Or can you give an example about how to run test1 & test2 & test3 together in |
@Nicole1991, this is an open issue that discusses ways to implement test suites. Neither The only way you can currently implement something like a test suite in k6 is if you manually calculate and specify the |
Got it. |
I'm also facing this issue, I want to run multiple tests sequentially after each other so that testing one API does not influence the results of the other API. |
are there currently any working methods for this? Additionally there is a proposed solution on this blog post using Is that a viable solution? The merge of the options seems sketchy to me |
As far as I can see, the blog post merges only the thresholds and just sequentially executes the different function as a part of the In general, k6 can run many different scenarios in parallel without any problems. It can also run them sequentially, the only problem with that is that you have to manually calculate the I can't answer if something is a "viable solution" to your use case without knowing the use case... 😉 And the community forum is a better place for that discussion. |
Hello! I am chiming in here to provide a quick +1 on the requirement to be able to point to a directory and execute multiple scripts at a time. That would be a great help for my organization! At the moment I can only serially execute the scripts and that's kind of a bummer. If I had my pick between the suite directory execution vs composite configuration I would much much much more prefer the suite directory approach where you call Thank you for the fantastic library! |
+1 |
@kkriegkxs, can you explain what you think should be in the |
@na-- gladly. basically, If I was building it, I would add an external sidecar / playlist containing a combination of scripts and option (global and overrides for an individual test) and a mechanism to kick them off accordingly in parallel. PM me if youd like we could chat on the phone ;) |
Thanks for the explanation! I was asking because we have had some recent internal discussions on this topic and it turns out that we might prioritize this issue and start working on it soon. I have some ideas on how to implement it without any dependency on So yeah, no promises or anything, but we are actively thinking about this issue and we might have something in the works soon(-ish) that will address it 🤞 I'll leave it at this for now, and will probably wait until I have a working PoC before I write up my alternative proposal for how this problem might also be solved. |
I've refactored my very basic PoC implementation of test suites and somewhat explained my ideas how it works and how a more robust version of it can be implemented into this design document. That was all a part of my specific proposal (#3218) on how to deliver native distributed execution to k6, parts of which will unlock test suites for both local and distributed tests 🤞 Though, to be clear, test suites do not explicitly depend on distributed execution, they just depend on some of the underlying APIs in the proposed |
Any update for this feature ? @na-- |
Any update for this feature guys? |
Roll your own, I guess. I do. |
any update on this feature or something similar |
Hey folks 👋🏻 We have a rough design for the feature in mind, but no concrete implementation plans yet. Stay tuned for updates. |
I'm creating this issue as a place to discuss possible ways for k6 to execute multiple distinct scripts in a single run. This is prompted by https://community.k6.io/t/running-10-test-cases-out-of-100/448, and other similar previous user inquiries.
Something like this can currently be achieved by a simple shell script that sequentially calls
k6 run "$script_path"
for all files in a folder, but that workaround is not very convenient without an external output like InfluxDB. It also doesn't work well withk6 cloud
, and isn't efficient in general (each separatek6 run
has to re-initialize its VUs). GitLab’s performance testing tool is probably also worth investigating...I also have a vague idea how we can implement something like "test suites" natively in k6 after #1007 is done, and do it relatively easily (:tm: :sweat_smile: ). To get 80% of the way there, we just need to implement one minor (sort-of-already-planned) improvement on the currently planned #1007 feature set 🎉. Instead of specifying
startTime: "30s"
for an executor, users should be able to specifystartAfter: "someOtherExecutorName"
. This will be very easy to implement (minor changes in the config validation, here and here).This will add a lot of convenience in general, so it's probably worth doing just for that. But it will also, when used with the
exec
option for each executor (to run some non-default
function), probably satisfy the "test suite" requirements of the majority of our users, albeit with some manual configuration work (which we can ameliorate with some JS helper functions).At a later point, to satisfy the remaining minority of more complex use cases, and to achieve something similar to
k6 run test1.js test2.js test3.js
(and, crucially,k6 cloud test1.js test2.js test3.js
), we can make another (somewhat more tricky) change to k6. We need to transform the currentlocal.ExecutionScheduler
into just another executor. That is, we will add a newcomposite
executor type that will be able to contain other executors. I may be wrong, but because of the new executor architecture in k6, and because we already have 95% of the required code inlocal.ExecutionScheduler
, I think this will actually be very straightforward to do 🎉 😄 At least on theexecution
side, there will be some complexity elsewhere.To illustrate, for example, if
test1.js
hasvus: 20, duration: "30s"
in its exportedoptions
,test2.js
hasiterations: 1000, vus: 20
, andtest3.js
has something like this:then, when you run
k6 run test1.js test2.js test3.js
, it should be relatively easy to produce something like this as the final derivedoptions.execution
value:Notice how, with a few minor changes, we have a whole new layer of flexibility - test suites, for lack of a better term. All the wile, we're preserving the nice new properties of being able to tell precisely how many VUs our test suite will use at most (
20
in this case) and what the max test suite duration will be, giving us predictability and easy billing.And, as I mention in the code comment above, the tricky bit isn't actually the execution. It would actually be things like figuring out how to reference the different default functions in the config. I don't think it's a huge issue, but we should be careful how we structure the archive bundles and the related things.
Also, because of the super-global k6 configuration (the curse of #883 strikes again 🤦♂️ ), I'm not sure how we should handle non-execution
options
that are different between scripts. We can probably refactor that at a later point though. And things like the planned new HTTP API (issue TBD 😊 ) would greatly reduce the issue... Still, some refactoring is likely required, even for a MVP version of the "full test suites 100% version"...So, yeah, this seems reasonable, after we release #1007:
startAfter
, cover (hopefully) 80% of use casescomposite
executor. No support fork6 run script1.js script2.js
at this point, users have to manually configure the hierarchical config). Hopefully that covers 90% of use cases.k6 run script1.js script2.js
. This will give us great UX and hopefully 100% coverage of use cases. We can do this step much, much later than steps 1 and 2. Probably smart to do it after we have the new HTTP API.The text was updated successfully, but these errors were encountered: