-
Notifications
You must be signed in to change notification settings - Fork 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
Geventhttpclientmergeconflicts #838
Geventhttpclientmergeconflicts #838
Conversation
…ests work without adding a dependency on having a working C compiler environment set up when installing Locust (since geventhttpclient package doesn't have wheels).
…. The text property function tries to decode the text in the same way as python-requests. This makes the API more similar to HttpSession. Added more tests.
… a trailing slash
… requests with FastHttpSession, in order to manually control if a request should result in a success or failure
Improved documentation of arguments for FastHttpSession.request() method.
… reported as failures
# Conflicts: # docs/writing-a-locustfile.rst
Codecov Report
@@ Coverage Diff @@
## master #838 +/- ##
========================================
Coverage ? 69.2%
========================================
Files ? 15
Lines ? 1604
Branches ? 245
========================================
Hits ? 1110
Misses ? 437
Partials ? 57
Continue to review full report at Codecov.
|
…the response was very quick (not a failure) and that 0.0 was a valid response time for a local server. Because of this i changes it to assertGreaterEqual.
The test failure was because of this change, btw - https://github.com/locustio/locust/pull/830/files#diff-cfaa22649621e474e8ebc0b0cac90d64R117 |
@heyman - thoughts on merging this? |
if stream: | ||
request_meta["content_size"] = int(response.headers.get("content-length") or 0) | ||
else: | ||
request_meta["content_size"] = len(response.content or "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my testing of this, I ran into an issue with a response's content not being saved properly.
When using FastHttpSession
and making a request, if stream=False
the response always returns with .content
being bytearray(b'')
. If stream=True
, the content is as expected. I'm not sure, but from what I can see the problem seems to stem from here where the content is read into the len()
call which then causes the urllib response to release content
.
I'm currently working around this by adding request_meta["content"] = response.content
before this if stream
check, but I'm sure there's a better way to retain content.
class FastHttpSession(object): | ||
auth_header = None | ||
|
||
def __init__(self, base_url): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def __init__(self, base_url): | |
def __init__(self, base_url, **kwargs): |
Allow configuration of UserAgent and HTTPClient by accepting and forwarding on **kwargs.
def __init__(self, base_url): | ||
self.base_url = base_url | ||
self.cookiejar = CookieJar() | ||
self.client = LocustUserAgent(max_retries=1, cookiejar=self.cookiejar) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.client = LocustUserAgent(max_retries=1, cookiejar=self.cookiejar) | |
self.client = LocustUserAgent(max_retries=1, cookiejar=self.cookiejar, **kwargs) |
Allow configuration of UserAgent and HTTPClient by accepting and forwarding on **kwargs.
@solowalker27 Below is sample locust file: from locust import task, TaskSet, HttpLocust class BenchLocust(FastHttpLocust): # or HttpLocust class task_set(TaskSet): Issues:
When catch_response is not passed, then we are able to easily execute the statement Can this be looked into ? |
@SpencerPinegar can you take a look at the failed test and merge conflict?
|
The reason for this is that requests is a very well-maintained python package, that | ||
provides a really nice API, that many python developers are familiar with. Therefore, | ||
in many cases, we recommend that you use the default :py:class:`HttpLocust <locust.core.HttpLocust>` | ||
which uses requests. However, if you're planning to run really large scale scale tests, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which uses requests. However, if you're planning to run really large scale scale tests, | |
which uses requests. However, if you're planning to run really large scale tests, |
response = locust.client.get("/", timeout=0.1) | ||
self.assertEqual(response.status_code, 0) | ||
self.assertEqual(1, global_stats.get("/", "GET").num_failures) | ||
self.assertEqual(0, global_stats.get("/", "GET").num_requests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since 0.10.0 (see #939), both successful and failed requests are counted in total number of requests.
self.assertEqual(0, global_stats.get("/", "GET").num_requests) | |
self.assertEqual(1, global_stats.get("/", "GET").num_requests) |
I really don't mean to be rude, but can we get this merged any time soon? Are there any more issues that need to be solved, I'd be happy to take a look in that case.
Cheers!
there are merge conflicts.. have at them |
|
Forked geventhttpclient #713 , created a new branch, merged master, fixed all merge conflicts (only 1 existed in docs).
Want to get this integrated to master so FastHttpClient can be easily used in master -- PR #713 has been checked and approved by 2 people and this small merge conflict was the final issue in getting this feature merged to master.