httpperf 1.0rc5__tar.gz → 1.0rc6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {httpperf-1.0rc5/httpperf.egg-info → httpperf-1.0rc6}/PKG-INFO +2 -2
  2. {httpperf-1.0rc5 → httpperf-1.0rc6}/README.md +1 -1
  3. {httpperf-1.0rc5 → httpperf-1.0rc6}/httpperf/__init__.py +1 -1
  4. {httpperf-1.0rc5 → httpperf-1.0rc6}/httpperf/_cli.py +4 -1
  5. httpperf-1.0rc6/httpperf/version.py +1 -0
  6. {httpperf-1.0rc5 → httpperf-1.0rc6/httpperf.egg-info}/PKG-INFO +2 -2
  7. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/httpperf.c +1 -3
  8. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_cli.py +9 -0
  9. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_http_versions.py +12 -9
  10. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_tls.py +11 -5
  11. httpperf-1.0rc5/httpperf/version.py +0 -1
  12. {httpperf-1.0rc5 → httpperf-1.0rc6}/LICENSE +0 -0
  13. {httpperf-1.0rc5 → httpperf-1.0rc6}/MANIFEST.in +0 -0
  14. {httpperf-1.0rc5 → httpperf-1.0rc6}/NOTICE +0 -0
  15. {httpperf-1.0rc5 → httpperf-1.0rc6}/httpperf/__main__.py +0 -0
  16. {httpperf-1.0rc5 → httpperf-1.0rc6}/httpperf.egg-info/SOURCES.txt +0 -0
  17. {httpperf-1.0rc5 → httpperf-1.0rc6}/httpperf.egg-info/dependency_links.txt +0 -0
  18. {httpperf-1.0rc5 → httpperf-1.0rc6}/httpperf.egg-info/entry_points.txt +0 -0
  19. {httpperf-1.0rc5 → httpperf-1.0rc6}/httpperf.egg-info/top_level.txt +0 -0
  20. {httpperf-1.0rc5 → httpperf-1.0rc6}/pyproject.toml +0 -0
  21. {httpperf-1.0rc5 → httpperf-1.0rc6}/setup.cfg +0 -0
  22. {httpperf-1.0rc5 → httpperf-1.0rc6}/setup.py +0 -0
  23. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/ae/.clang-format +0 -0
  24. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/ae/ae.c +0 -0
  25. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/ae/ae.h +0 -0
  26. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/ae/ae_epoll.c +0 -0
  27. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/ae/ae_evport.c +0 -0
  28. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/ae/ae_kqueue.c +0 -0
  29. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/ae/ae_select.c +0 -0
  30. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/ae/atomicvar.h +0 -0
  31. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/ae/config.h +0 -0
  32. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/ae/zmalloc.c +0 -0
  33. {httpperf-1.0rc5 → httpperf-1.0rc6}/src/ae/zmalloc.h +0 -0
  34. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_api.py +0 -0
  35. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_cancel.py +0 -0
  36. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_connections.py +0 -0
  37. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_cookie.py +0 -0
  38. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_discard_body.py +0 -0
  39. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_engine.py +0 -0
  40. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_host_stats.py +0 -0
  41. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_httpbin.py +0 -0
  42. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_leaks.py +0 -0
  43. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_limiter.py +0 -0
  44. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_response.py +0 -0
  45. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_stats.py +0 -0
  46. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_stream.py +0 -0
  47. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_threads.py +0 -0
  48. {httpperf-1.0rc5 → httpperf-1.0rc6}/tests/test_upload.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: httpperf
3
- Version: 1.0rc5
3
+ Version: 1.0rc6
4
4
  Summary: An asyncio HTTP client for load testing, built on libcurl.
5
5
  Author-email: Tony Simpson <agjasimpson@gmail.com>
6
6
  Project-URL: Source, https://github.com/tonysimpson/httpperf
@@ -121,7 +121,7 @@ All arguments are keyword-only. A session can be created anywhere, even outside
121
121
  | `cert` | `None` | `(certfile, keyfile)` paths for a client certificate, used by every request unless the request overrides it. |
122
122
  | `timeout` | `None` | Seconds allowed for each request, from the start of the transfer to the last byte (each redirect hop separately). `None` or 0 means no limit. Cancelling the task (or `asyncio.wait_for`) also stops the transfer and frees its connection slot; on HTTP/1.1 that closes the connection, on HTTP/2 and HTTP/3 it resets only that stream. |
123
123
  | `connect_timeout` | `None` | Seconds allowed to connect, TLS included. `None` means curl's default of 300 s. |
124
- | `verify` | `False` | Server certificate checking. `False`: none, as most load tests want. `True`: check against the system CAs, from the first of: `SSL_CERT_FILE` and `SSL_CERT_DIR`, if set and present; libcurl's own default bundle, if present; Python's default bundle (`ssl.get_default_verify_paths()`); the usual system locations. A path: check against that CA bundle. Requests can override it. |
124
+ | `verify` | `True` | Server certificate checking. `False`: none, for test servers with self-signed certificates. `True`: check against the system CAs, from the first of: `SSL_CERT_FILE` and `SSL_CERT_DIR`, if set and present; libcurl's own default bundle, if present; Python's default bundle (`ssl.get_default_verify_paths()`); the usual system locations. A path: check against that CA bundle. Requests can override it. |
125
125
  | `json_dumps` | `None` | Function that turns a `json=` argument into the request body (`str` or `bytes`). `None` means the engine's. |
126
126
  | `json_loads` | `None` | Function that turns the response body (`bytes`) into the result of `json()`. `None` means the engine's. |
127
127
 
@@ -95,7 +95,7 @@ All arguments are keyword-only. A session can be created anywhere, even outside
95
95
  | `cert` | `None` | `(certfile, keyfile)` paths for a client certificate, used by every request unless the request overrides it. |
96
96
  | `timeout` | `None` | Seconds allowed for each request, from the start of the transfer to the last byte (each redirect hop separately). `None` or 0 means no limit. Cancelling the task (or `asyncio.wait_for`) also stops the transfer and frees its connection slot; on HTTP/1.1 that closes the connection, on HTTP/2 and HTTP/3 it resets only that stream. |
97
97
  | `connect_timeout` | `None` | Seconds allowed to connect, TLS included. `None` means curl's default of 300 s. |
98
- | `verify` | `False` | Server certificate checking. `False`: none, as most load tests want. `True`: check against the system CAs, from the first of: `SSL_CERT_FILE` and `SSL_CERT_DIR`, if set and present; libcurl's own default bundle, if present; Python's default bundle (`ssl.get_default_verify_paths()`); the usual system locations. A path: check against that CA bundle. Requests can override it. |
98
+ | `verify` | `True` | Server certificate checking. `False`: none, for test servers with self-signed certificates. `True`: check against the system CAs, from the first of: `SSL_CERT_FILE` and `SSL_CERT_DIR`, if set and present; libcurl's own default bundle, if present; Python's default bundle (`ssl.get_default_verify_paths()`); the usual system locations. A path: check against that CA bundle. Requests can override it. |
99
99
  | `json_dumps` | `None` | Function that turns a `json=` argument into the request body (`str` or `bytes`). `None` means the engine's. |
100
100
  | `json_loads` | `None` | Function that turns the response body (`bytes`) into the result of `json()`. `None` means the engine's. |
101
101
 
@@ -760,7 +760,7 @@ class Session:
760
760
  max_host_connections=0,
761
761
  max_connections=0,
762
762
  cert=None,
763
- verify=False,
763
+ verify=True,
764
764
  timeout=None,
765
765
  connect_timeout=None,
766
766
  json_dumps=None,
@@ -189,7 +189,9 @@ class Worker:
189
189
  asyncio.set_event_loop(self.loop)
190
190
  cap = share(args.connections[0], args.workers, index) if args.rate else 0
191
191
  self.engine = httpperf.Engine(max_total_connections=cap)
192
- self.session = httpperf.Session(engine=self.engine, http_version=HTTP_VERSIONS[args.http], timeout=args.timeout)
192
+ self.session = httpperf.Session(
193
+ engine=self.engine, http_version=HTTP_VERSIONS[args.http], timeout=args.timeout, verify=not args.insecure
194
+ )
193
195
  self.session.set_response_callback(self.on_response)
194
196
 
195
197
  def close(self):
@@ -674,6 +676,7 @@ def parser():
674
676
  p.add_argument("-X", "--method", default="GET")
675
677
  p.add_argument("--body", metavar="DATA", help="request body, or @file")
676
678
  p.add_argument("--http", choices=sorted(HTTP_VERSIONS), default="1.1", help="HTTP version to ask for (default 1.1)")
679
+ p.add_argument("-k", "--insecure", action="store_true", help="don't check the server's certificate")
677
680
  p.add_argument("--timeout", type=duration, metavar="T", default=2.0, help="request timeout (default 2s)")
678
681
  p.add_argument("-s", "--script", metavar="FILE", help="Python file defining async def request(session, url)")
679
682
  p.add_argument("--json", action="store_true", help="print the results as JSON")
@@ -0,0 +1 @@
1
+ __version__ = "1.0rc6"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: httpperf
3
- Version: 1.0rc5
3
+ Version: 1.0rc6
4
4
  Summary: An asyncio HTTP client for load testing, built on libcurl.
5
5
  Author-email: Tony Simpson <agjasimpson@gmail.com>
6
6
  Project-URL: Source, https://github.com/tonysimpson/httpperf
@@ -121,7 +121,7 @@ All arguments are keyword-only. A session can be created anywhere, even outside
121
121
  | `cert` | `None` | `(certfile, keyfile)` paths for a client certificate, used by every request unless the request overrides it. |
122
122
  | `timeout` | `None` | Seconds allowed for each request, from the start of the transfer to the last byte (each redirect hop separately). `None` or 0 means no limit. Cancelling the task (or `asyncio.wait_for`) also stops the transfer and frees its connection slot; on HTTP/1.1 that closes the connection, on HTTP/2 and HTTP/3 it resets only that stream. |
123
123
  | `connect_timeout` | `None` | Seconds allowed to connect, TLS included. `None` means curl's default of 300 s. |
124
- | `verify` | `False` | Server certificate checking. `False`: none, as most load tests want. `True`: check against the system CAs, from the first of: `SSL_CERT_FILE` and `SSL_CERT_DIR`, if set and present; libcurl's own default bundle, if present; Python's default bundle (`ssl.get_default_verify_paths()`); the usual system locations. A path: check against that CA bundle. Requests can override it. |
124
+ | `verify` | `True` | Server certificate checking. `False`: none, for test servers with self-signed certificates. `True`: check against the system CAs, from the first of: `SSL_CERT_FILE` and `SSL_CERT_DIR`, if set and present; libcurl's own default bundle, if present; Python's default bundle (`ssl.get_default_verify_paths()`); the usual system locations. A path: check against that CA bundle. Requests can override it. |
125
125
  | `json_dumps` | `None` | Function that turns a `json=` argument into the request body (`str` or `bytes`). `None` means the engine's. |
126
126
  | `json_loads` | `None` | Function that turns the response body (`bytes`) into the result of `json()`. `None` means the engine's. |
127
127
 
@@ -1769,9 +1769,7 @@ void start_request(struct aeEventLoop *eventLoop, int fd, void *clientData, int
1769
1769
  if (rd->ca_file != NULL) {
1770
1770
  curl_easy_setopt(rd->curl, CURLOPT_CAINFO, rd->ca_file);
1771
1771
  }
1772
- if (rd->ca_path != NULL) {
1773
- curl_easy_setopt(rd->curl, CURLOPT_CAPATH, rd->ca_path);
1774
- }
1772
+ curl_easy_setopt(rd->curl, CURLOPT_CAPATH, rd->ca_path);
1775
1773
  } else {
1776
1774
  curl_easy_setopt(rd->curl, CURLOPT_SSL_VERIFYPEER, 0L);
1777
1775
  curl_easy_setopt(rd->curl, CURLOPT_SSL_VERIFYHOST, 0L);
@@ -61,6 +61,15 @@ def test_an_error_status_is_an_error(capsys, httpbin):
61
61
  assert {e["error"] for e in steps[0]["error_kinds"]} == {"HTTP 503"}
62
62
 
63
63
 
64
+ def test_an_unverified_certificate_is_an_error(capsys, httpbin_secure):
65
+ assert main([*QUICK, httpbin_secure.url + "/get"]) == 1
66
+
67
+
68
+ def test_insecure_skips_the_certificate_check(capsys, httpbin_secure):
69
+ _, steps = run(capsys, "-k", httpbin_secure.url + "/get")
70
+ assert steps[0]["errors"] == 0
71
+
72
+
64
73
  def test_errors_set_the_exit_status(capsys, httpbin):
65
74
  assert run(capsys, httpbin.url + "/status/503")[0] == 1
66
75
 
@@ -22,6 +22,9 @@ async def app(scope, receive, send):
22
22
  await send({"type": "http.response.body", "body": scope["http_version"].encode()})
23
23
 
24
24
 
25
+ CA = pytest_httpbin.certs.where()
26
+
27
+
25
28
  @pytest.fixture(scope="module")
26
29
  def h2_url():
27
30
  certs = os.path.dirname(pytest_httpbin.certs.where())
@@ -63,7 +66,7 @@ def h2_url():
63
66
 
64
67
  def libcurl_has_http3():
65
68
  try:
66
- httpperf.Session(http_version="HTTP/3")
69
+ httpperf.Session(verify=CA, http_version="HTTP/3")
67
70
  except ValueError:
68
71
  return False
69
72
  return True
@@ -78,7 +81,7 @@ MULTIPLEXED = [pytest.param("HTTP/3", marks=needs_http3), "HTTP/2"]
78
81
 
79
82
 
80
83
  async def get_with(url, version):
81
- async with httpperf.Session(http_version=version) as s:
84
+ async with httpperf.Session(verify=CA, http_version=version) as s:
82
85
  return await s.get(url)
83
86
 
84
87
 
@@ -115,13 +118,13 @@ async def test_headers_arrive_over_every_version(h2_url, version):
115
118
  "version, new_connections", [pytest.param("HTTP/3", 1, marks=needs_http3), ("HTTP/2", 1), ("HTTP/1.1", 5)]
116
119
  )
117
120
  async def test_concurrent_requests_share_a_connection(h2_url, version, new_connections):
118
- async with httpperf.Session(connections="session", http_version=version) as s:
121
+ async with httpperf.Session(verify=CA, connections="session", http_version=version) as s:
119
122
  responses = await get_together(s, h2_url, 5)
120
123
  assert sum(r.connect_time > 0 for r in responses) == new_connections
121
124
 
122
125
 
123
126
  async def two_batches_under_a_host_limit_of_2(url):
124
- async with httpperf.Session(connections="session", max_host_connections=2) as s:
127
+ async with httpperf.Session(verify=CA, connections="session", max_host_connections=2) as s:
125
128
  return await get_together(s, url, 6), await get_together(s, url, 6)
126
129
 
127
130
 
@@ -142,7 +145,7 @@ async def test_requests_to_a_multiplexed_host_do_not_queue(h2_url):
142
145
 
143
146
  @pytest.mark.parametrize("version", MULTIPLEXED)
144
147
  async def test_cancelling_one_stream_keeps_the_connection(h2_url, version):
145
- async with httpperf.Session(connections="session", http_version=version) as s:
148
+ async with httpperf.Session(verify=CA, connections="session", http_version=version) as s:
146
149
  tasks = [asyncio.create_task(s.get(h2_url + "slow")) for _ in range(6)]
147
150
  await asyncio.sleep(0.3)
148
151
  for task in tasks[::2]:
@@ -153,7 +156,7 @@ async def test_cancelling_one_stream_keeps_the_connection(h2_url, version):
153
156
 
154
157
  @pytest.mark.parametrize("version", MULTIPLEXED)
155
158
  async def test_a_multiplexed_host_takes_one_limiter_slot(h2_url, version):
156
- async with httpperf.Session(connections="session", http_version=version, max_host_connections=2) as s:
159
+ async with httpperf.Session(verify=CA, connections="session", http_version=version, max_host_connections=2) as s:
157
160
  await s.get(h2_url)
158
161
  tasks = [asyncio.create_task(s.get(h2_url + "slow")) for _ in range(6)]
159
162
  assert await until(lambda: limiter_host(s) == {"active": 6, "waiting": 0, "multiplexed": True})
@@ -161,7 +164,7 @@ async def test_a_multiplexed_host_takes_one_limiter_slot(h2_url, version):
161
164
 
162
165
 
163
166
  async def test_a_failed_request_does_not_stop_multiplexing(h2_url):
164
- async with httpperf.Session(connections="session", max_host_connections=2) as s:
167
+ async with httpperf.Session(verify=CA, connections="session", max_host_connections=2) as s:
165
168
  await s.get(h2_url)
166
169
  with pytest.raises(httpperf.Timeout):
167
170
  await s.get(h2_url + "slow", timeout=0.1)
@@ -170,6 +173,6 @@ async def test_a_failed_request_does_not_stop_multiplexing(h2_url):
170
173
 
171
174
  async def test_the_limiter_follows_a_host_back_to_http1(h2_url):
172
175
  async with httpperf.Engine(max_host_connections=4) as engine:
173
- await httpperf.Session(engine=engine).get(h2_url)
174
- await httpperf.Session(engine=engine, http_version="HTTP/1.1").get(h2_url)
176
+ await httpperf.Session(verify=CA, engine=engine).get(h2_url)
177
+ await httpperf.Session(verify=CA, engine=engine, http_version="HTTP/1.1").get(h2_url)
175
178
  assert limiter_host(engine)["multiplexed"] is False
@@ -41,8 +41,8 @@ def tls_url():
41
41
 
42
42
  async def resumed(url, tls):
43
43
  async with httpperf.Engine() as engine:
44
- await httpperf.Session(engine=engine, connections="session", tls=tls).get(url)
45
- r = await httpperf.Session(engine=engine, connections="session", tls=tls).get(url)
44
+ await httpperf.Session(engine=engine, connections="session", tls=tls, verify=CA).get(url)
45
+ r = await httpperf.Session(engine=engine, connections="session", tls=tls, verify=CA).get(url)
46
46
  return r.text == "True"
47
47
 
48
48
 
@@ -109,14 +109,14 @@ async def who(session, url, **options):
109
109
 
110
110
  async def test_each_session_presents_its_own_certificate(mtls_url, client_certs):
111
111
  async with httpperf.Engine() as engine:
112
- user1 = httpperf.Session(engine=engine, cert=client_certs["user1"])
113
- user2 = httpperf.Session(engine=engine, cert=client_certs["user2"])
112
+ user1 = httpperf.Session(engine=engine, cert=client_certs["user1"], verify=CA)
113
+ user2 = httpperf.Session(engine=engine, cert=client_certs["user2"], verify=CA)
114
114
  names = [await who(s, mtls_url) for s in (user1, user2, user1, user2)]
115
115
  assert names == ["user1", "user2", "user1", "user2"]
116
116
 
117
117
 
118
118
  async def test_a_request_certificate_overrides_the_sessions(mtls_url, client_certs):
119
- async with httpperf.Session(cert=client_certs["user1"]) as s:
119
+ async with httpperf.Session(cert=client_certs["user1"], verify=CA) as s:
120
120
  assert await who(s, mtls_url, cert=client_certs["user2"]) == "user2"
121
121
 
122
122
 
@@ -141,6 +141,12 @@ async def verified(url, session_verify, **options):
141
141
  return True
142
142
 
143
143
 
144
+ async def test_verify_is_the_default(tls_url):
145
+ async with httpperf.Session() as s:
146
+ with pytest.raises(httpperf.RequestError):
147
+ await s.get(tls_url)
148
+
149
+
144
150
  @pytest.mark.parametrize(
145
151
  "session_verify, options, succeeds",
146
152
  [
@@ -1 +0,0 @@
1
- __version__ = "1.0rc5"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes