Skip to content
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

locust support testing against HTTP/2 servers ? #264

Closed
centminmod opened this issue Mar 21, 2015 · 8 comments
Closed

locust support testing against HTTP/2 servers ? #264

centminmod opened this issue Mar 21, 2015 · 8 comments

Comments

@centminmod
Copy link

Any plans for Locust to support testing against HTTP/2 servers like h2o https://github.com/h2o/h2o and OpenLiteSpeed http://open.litespeedtech.com/mediawiki/ ?

cheers

George

@Kenith
Copy link

Kenith commented Apr 6, 2016

We found that the Hyper could support the HTTP/2.
https://github.com/Lukasa/hyper
http://hyper.readthedocs.org/en/development/quickstart.html#requests-integration

Now we are trying to integrate the HTTP/2 into Locust, we were wondering that any kinds of suggestions about how to integrate the Hyper into Locust?

Look forward to you reply.

Thank you,
Ken

@cgoldberg
Copy link
Member

read this to get started:
http://docs.locust.io/en/latest/testing-other-systems.html

@huangjunque
Copy link

Locust support http2?

@cgoldberg
Copy link
Member

yes, if you use an http2 client within your locust scripts

@Tobils
Copy link

Tobils commented Jun 9, 2020

is there any example to implement hyper for http/2 client on locust ?

Thanks

@gawel
Copy link

gawel commented Dec 22, 2020

Hi!

I managed to make it work with httpx (which use hyper under the hood). It's mostly compatible with requests https://www.python-httpx.org/compatibility/

Check my gist. You just have to use the HttpxUser in your locustfile https://gist.github.com/gawel/f48e577425f872e1a81028f3f53353cf#file-clientx-py-L216

Let me know if you're interested in a PR to add this in contrib/httpx (of course I'll add some tests). If not I'll probably create a dedicated package

@gawel
Copy link

gawel commented Dec 22, 2020

I've also found a way using @Kenith sugestion:

from locust import TaskSet, between, HttpUser
from hyper.contrib import HTTP20Adapter

class Http2User(HttpUser):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.client.mount(self.host, HTTP20Adapter())

Don't know which one is the more efficient but this second option is easy to use

@Apteryks
Copy link

@gawel note that httpx relies on hyper-h2 (the HTTP/2 protocol stack) rather than hyper, the client (which I myself got confused about, see: encode/httpx#1476). The later is deprecated in favor of httpx. That means the HTTP20Adapter (which came with the client) shouldn't be used in new code, but FWIU, httpx aims to be very compatible with requests, so that might not be a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants