-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[REQ] K6 generator - Use openapi examples values as query parameters & body values #8378
Comments
Hey @thim81, thanks for filing the issue. I'd be happy to see any contribution from you or any member of the community. Currently I am busy doing other things and this is not one of the priorities, but I might look at it in the future. Also, I can help with the code review if you create a PR. |
Hi @mostafa, Fully understood. Do you find it a valuable addition? Since I'm not at home of the code base, can you perhaps me towards the piece in the code where you would want to see this extension being implemented? |
@thim81 Of course! This is the file that generates the k6 script. And this is the template I used to generate the script. In this case, all those |
Hey @thim81, have you been able to add the feature/enhancement? Do you need any help? |
Hi, As part of recent automation work done on a commercial project, where I utilized the K6 OpenAPI generator, I hit this issue where examples defined for path/query parameters were not taken into account. Therefore, the script produced was not really usable, only a skeleton. I needed to generate script which was fully ready to run, out-of-the box, so smoke tests (https://k6.io/docs/test-types/smoke-testing/) could be run as part of CI/CD pipeline. I went ahead and added what was needed, and now, Data In Motion (https://www.datainmotion.de/), client for whom this work was done, generously agreed to share this with the community. So that’s the background on the PR which I just opened: #9750 This addresses extracting examples defined for path/query parameters; as you know, there are also examples defined at |
Hi, More goodies: #10614 With this latest MR, this feature request (i.e. #8378) is now feature complete. Please see #10614 for more info. New code is documented. Entire solution will be showcased as part of the upcoming EclipseCon 2021 session: "Automated testing of OpenAPI-described RESTful microservices utilizing open source tools" https://www.eclipsecon.org/2021/sessions/automated-testing-openapi-described-restful-microservices-utilizing-open-source-tools Hopefully formatting is now OK, in case of any problems please let me know. |
Is your feature request related to a problem? Please describe.
The K6 generator, generates an almost ready to use K6 script.
Example
In the above there are 2 parts of the generated script, that require some manual modifications.
Query parameter:
let domainClusterId = "TODO_EDIT_THE_DOMAINCLUSTERID";
Request Body
body = {"name": "string", "servers": "list"};
The goal is to use the generated script in an Continuous integration flow.
The flow would be:
-- generated documentation
-- generate postman collection
-- generate a K6 script via the openapi-generator
-- trigger a load test via K6
Describe the solution you'd like
In the OpenApi you can define "example" values
A handy solution would be to use the examples, like os
Query parameter:
let domainClusterId = "TODO_EDIT_THE_DOMAINCLUSTERID";
Take the example values from OpenApi
params > servers > schema > example: f0c01c3a-6880-46c3-abb3-7a45828d1c45
which would result in:
let domainClusterId = "f0c01c3a-6880-46c3-abb3-7a45828d1c45";
Request Body
body = {"name": "string", "servers": "list"};
Take the example values from OpenApi
requestBody > content > properties > name > example: CLUSTER-1
requestBody > content > properties > servers > example: - S1 - S2
Describe alternatives you've considered
creating a PR, but I'm not sure how to get started with the excellent K6 generator from @mostafa , due to no experience in JAVA development and if the mentioned example data is available in the OpenApi class.
The text was updated successfully, but these errors were encountered: