test_connection_pools.py
This file
Path
tests/dispatch/test_connection_pools.py
179 lines · 6.2 KiB · Python
Last changed by
Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
History of this fileTake it
The walk stopped after 200 commits: lines older than 5f8000f point at it.
Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 1why, one step back1import httpxUpdating docstringsTom Christiebefore adoption5f8000f
lines 2–3why, one step back23Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 4why, one step back4async def test_keepalive_connections(server, backend):Updating docstringsTom Christiebefore adoption5f8000f
lines 5–7why, one step back5 """6 Connections should default to staying in a keep-alive state.7 """Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 8why, one step back8 async with httpx.ConnectionPool(backend=backend) as http:Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 9why, one step back9 response = await http.request("GET", server.url)Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 10why, one step back10 await response.read()Updating docstringsTom Christiebefore adoption5f8000f
lines 11–13why, one step back11 assert len(http.active_connections) == 012 assert len(http.keepalive_connections) == 113Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 14why, one step back14 response = await http.request("GET", server.url)Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 15why, one step back15 await response.read()Updating docstringsTom Christiebefore adoption5f8000f
lines 16–19why, one step back16 assert len(http.active_connections) == 017 assert len(http.keepalive_connections) == 11819Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 20why, one step back20async def test_differing_connection_keys(server, backend):Updating docstringsTom Christiebefore adoption5f8000f
line 21why, one step back21 """Fix typos in docstringsSaugat Pachhaibefore adoption3451028
line 22why, one step back22 Connections to differing connection keys should result in multiple connections.Updating docstringsTom Christiebefore adoption5f8000f
line 23why, one step back23 """Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 24why, one step back24 async with httpx.ConnectionPool(backend=backend) as http:Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 25why, one step back25 response = await http.request("GET", server.url)Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 26why, one step back26 await response.read()Updating docstringsTom Christiebefore adoption5f8000f
lines 27–30why, one step back27 assert len(http.active_connections) == 028 assert len(http.keepalive_connections) == 12930 response = await http.request("GET", "http://localhost:8000/")Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 31why, one step back31 await response.read()Updating docstringsTom Christiebefore adoption5f8000f
lines 32–35why, one step back32 assert len(http.active_connections) == 033 assert len(http.keepalive_connections) == 23435Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 36why, one step back36async def test_soft_limit(server, backend):Updating docstringsTom Christiebefore adoption5f8000f
lines 37–39why, one step back37 """38 The soft_limit config should limit the maximum number of keep-alive connections.39 """Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 40why, one step back40 pool_limits = httpx.PoolLimits(soft_limit=1)Updating docstringsTom Christiebefore adoption5f8000f
line 41why, one step back41Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 42why, one step back42 async with httpx.ConnectionPool(pool_limits=pool_limits, backend=backend) as http:Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 43why, one step back43 response = await http.request("GET", server.url)Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 44why, one step back44 await response.read()Updating docstringsTom Christiebefore adoption5f8000f
lines 45–48why, one step back45 assert len(http.active_connections) == 046 assert len(http.keepalive_connections) == 14748 response = await http.request("GET", "http://localhost:8000/")Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 49why, one step back49 await response.read()Updating docstringsTom Christiebefore adoption5f8000f
lines 50–53why, one step back50 assert len(http.active_connections) == 051 assert len(http.keepalive_connections) == 15253Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 54why, one step back54async def test_streaming_response_holds_connection(server, backend):Updating docstringsTom Christiebefore adoption5f8000f
lines 55–57why, one step back55 """56 A streaming request should hold the connection open until the response is read.57 """Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 58why, one step back58 async with httpx.ConnectionPool(backend=backend) as http:Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 59why, one step back59 response = await http.request("GET", server.url)Updating docstringsTom Christiebefore adoption5f8000f
lines 60–68why, one step back60 assert len(http.active_connections) == 161 assert len(http.keepalive_connections) == 06263 await response.read()6465 assert len(http.active_connections) == 066 assert len(http.keepalive_connections) == 16768Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 69why, one step back69async def test_multiple_concurrent_connections(server, backend):Updating docstringsTom Christiebefore adoption5f8000f
lines 70–72why, one step back70 """71 Multiple conncurrent requests should open multiple conncurrent connections.72 """Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 73why, one step back73 async with httpx.ConnectionPool(backend=backend) as http:Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 74why, one step back74 response_a = await http.request("GET", server.url)Updating docstringsTom Christiebefore adoption5f8000f
lines 75–77why, one step back75 assert len(http.active_connections) == 176 assert len(http.keepalive_connections) == 077Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 78why, one step back78 response_b = await http.request("GET", server.url)Updating docstringsTom Christiebefore adoption5f8000f
lines 79–90why, one step back79 assert len(http.active_connections) == 280 assert len(http.keepalive_connections) == 08182 await response_b.read()83 assert len(http.active_connections) == 184 assert len(http.keepalive_connections) == 18586 await response_a.read()87 assert len(http.active_connections) == 088 assert len(http.keepalive_connections) == 28990Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 91why, one step back91async def test_close_connections(server, backend):Updating docstringsTom Christiebefore adoption5f8000f
lines 92–95why, one step back92 """93 Using a `Connection: close` header should close the connection.94 """95 headers = [(b"connection", b"close")]Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 96why, one step back96 async with httpx.ConnectionPool(backend=backend) as http:Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 97why, one step back97 response = await http.request("GET", server.url, headers=headers)Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7
line 98why, one step back98 await response.read()Updating docstringsTom Christiebefore adoption5f8000f
lines 99–102why, one step back99 assert len(http.active_connections) == 0100 assert len(http.keepalive_connections) == 0101102Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 103why, one step back103async def test_standard_response_close(server, backend):Updating docstringsTom Christiebefore adoption5f8000f
lines 104–106why, one step back104 """105 A standard close should keep the connection open.106 """Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 107why, one step back107 async with httpx.ConnectionPool(backend=backend) as http:Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 108why, one step back108 response = await http.request("GET", server.url)Updating docstringsTom Christiebefore adoption5f8000f
lines 109–114why, one step back109 await response.read()110 await response.close()111 assert len(http.active_connections) == 0112 assert len(http.keepalive_connections) == 1113114Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 115why, one step back115async def test_premature_response_close(server, backend):Updating docstringsTom Christiebefore adoption5f8000f
lines 116–118why, one step back116 """117 A premature close should close the connection.118 """Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 119why, one step back119 async with httpx.ConnectionPool(backend=backend) as http:Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 120why, one step back120 response = await http.request("GET", server.url)Updating docstringsTom Christiebefore adoption5f8000f
lines 121–123why, one step back121 await response.close()122 assert len(http.active_connections) == 0123 assert len(http.keepalive_connections) == 0Check disconnections on connection reacquiry (#145)Tom Christiebefore adoptionec365c0
lines 124–125why, one step back124125Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
lines 126–128why, one step back126async def test_keepalive_connection_closed_by_server_is_reestablished(127 server, restart, backend128):Check disconnections on connection reacquiry (#145)Tom Christiebefore adoptionec365c0
line 129why, one step back129 """Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b
lines 130–131why, one step back130 Upon keep-alive connection closed by remote a new connection131 should be reestablished.Check disconnections on connection reacquiry (#145)Tom Christiebefore adoptionec365c0
line 132why, one step back132 """Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 133why, one step back133 async with httpx.ConnectionPool(backend=backend) as http:Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 134why, one step back134 response = await http.request("GET", server.url)Check disconnections on connection reacquiry (#145)Tom Christiebefore adoptionec365c0
lines 135–136why, one step back135 await response.read()136Serve test server in thread (#292)Florimond Mancabefore adoption994403b
line 137why, one step back137 # Shutdown the server to close the keep-alive connectionParametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 138why, one step back138 await restart(server)Check disconnections on connection reacquiry (#145)Tom Christiebefore adoptionec365c0
line 139why, one step back139Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 140why, one step back140 response = await http.request("GET", server.url)Check disconnections on connection reacquiry (#145)Tom Christiebefore adoptionec365c0
lines 141–145why, one step back141 await response.read()142 assert len(http.active_connections) == 0143 assert len(http.keepalive_connections) == 1144145Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
lines 146–148why, one step back146async def test_keepalive_http2_connection_closed_by_server_is_reestablished(147 server, restart, backend148):Check disconnections on connection reacquiry (#145)Tom Christiebefore adoptionec365c0
line 149why, one step back149 """Add additional flake8 plugins (#157)Can Sarıgölbefore adoption7e9110b
lines 150–151why, one step back150 Upon keep-alive connection closed by remote a new connection151 should be reestablished.Check disconnections on connection reacquiry (#145)Tom Christiebefore adoptionec365c0
line 152why, one step back152 """Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 153why, one step back153 async with httpx.ConnectionPool(backend=backend) as http:Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 154why, one step back154 response = await http.request("GET", server.url)Check disconnections on connection reacquiry (#145)Tom Christiebefore adoptionec365c0
lines 155–156why, one step back155 await response.read()156Serve test server in thread (#292)Florimond Mancabefore adoption994403b
line 157why, one step back157 # Shutdown the server to close the keep-alive connectionParametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 158why, one step back158 await restart(server)Check disconnections on connection reacquiry (#145)Tom Christiebefore adoptionec365c0
line 159why, one step back159Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 160why, one step back160 response = await http.request("GET", server.url)Check disconnections on connection reacquiry (#145)Tom Christiebefore adoptionec365c0
lines 161–163why, one step back161 await response.read()162 assert len(http.active_connections) == 0163 assert len(http.keepalive_connections) == 1Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a
lines 164–165why, one step back164165Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 166why, one step back166async def test_connection_closed_free_semaphore_on_acquire(server, restart, backend):Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a
lines 167–171why, one step back167 """168 Verify that max_connections semaphore is released169 properly on a disconnected connection.170 """171 async with httpx.ConnectionPool(pool_limits=httpx.PoolLimits(hard_limit=1)) as http:Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 172why, one step back172 response = await http.request("GET", server.url)Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a
lines 173–175why, one step back173 await response.read()174175 # Close the connection so we're forced to recycle itParametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
line 176why, one step back176 await restart(server)Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a
line 177why, one step back177Add server.url property in tests (#300)Bakhtiyor Ruzievbefore adoptione34d280
line 178why, one step back178 response = await http.request("GET", server.url)Release semaphore if connection is dropped (#230)Ordanis Sanchezbefore adoptiona960a2a
line 179why, one step back179 assert response.status_code == 200