-
Notifications
You must be signed in to change notification settings - Fork 13
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
[WIP] An option to generate HTTP Client from swagger instead of a taskset #14
Open
DataGreed
wants to merge
10
commits into
lieldulev:master
Choose a base branch
from
DataGreed:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sync with original repo
…efaults i didn't check if the query params are working normally though and didn't add default params as I usually do not require them. But it's doable if needed.
Example of generated file with from locust import HttpLocust, TaskSet, task
from locust.clients import HttpSession
class MyHttpClient(HttpSession):
def put_books_book_id(self, book_id, **kwargs):
return self.put("/books/{0}/".format(book_id), name="/books/{book_id}/", **kwargs)
def patch_books_book_id(self, book_id, **kwargs):
return self.patch("/books/{0}/".format(book_id), name="/books/{book_id}/", **kwargs)
def delete_books_book_id(self, book_id, **kwargs):
return self.delete("/books/{0}/".format(book_id), name="/books/{book_id}/", **kwargs)
def get_books(self, **kwargs):
return self.get("/books/", name="/books/", **kwargs)
def get_books_id(self, object_id, **kwargs):
return self.get("/books/{0}/".format(object_id), name="/books/{id}/", **kwargs)
class MyTaskSet(TaskSet):
pass
class MyLocust(HttpLocust):
task_set = MyTaskSet
def __init__(self):
super().__init__()
self.client = MyHttpClient(self.host)
min_wait = 1000
max_wait = 3000 |
Hey @DataGreed - this has been [wip] forever, i'm in no rush (been a while since I touched this repo) - just wondering if we ever going to merge this awesome new feature? :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New option (
-c
or--client
). If specified, generates a new HttpSession client based on the supplied swagger/openapi and connects it to the generated Locust. All URI paramters are passed as method arguments, kwargs are also passed, so you can pass additional headers or body.The TaskSet is generated empty in this case for the user to create.
This is basically how I use locust framework all the time for HTTP APIs - I create an API client and then I use it in my tasksets where all the actual user behaviour, decision-making and logic exists.
TODO:
-c
option is not supplied)