1- # h2spec compliance tests https://github.com/summerwind/h2spec/tree/master/http2
1+ # h2spec compliance tests https://github.com/summerwind/h2spec
22#
3- # Names mirror h2spec spec IDs: http2 /<section>/<case>.
4- # Section maps to a source file, e.g. http2/6_7_ping.go -> RFC 7540 §6.7 (PING) .
5- # Case is the 1-based index of AddTestCase in that file; run via `h2spec http2/6.7/2` .
3+ # Names mirror h2spec spec IDs: <spec> /<section>/<case>.
4+ # Section maps to a source file, e.g. http2/6_7_ping.go or generic/3_8_goaway.go .
5+ # Case is the 1-based index of AddTestCase in that file.
66import asyncio
77
88import pytest
@@ -21,3 +21,21 @@ async def test_h2spec_6_7_2_ping_ack_ignored(create_connection, service_client):
2121
2222 with pytest .raises (asyncio .TimeoutError ):
2323 await sock .recv (utils .RECEIVE_SIZE , timeout = 0.5 )
24+
25+
26+ async def test_h2spec_generic_3_8_1_client_goaway (create_connection , monitor_client , service_client ):
27+ # generic/3_8_goaway.go, case 1 ("Sends a GOAWAY frame"):
28+ # after client GOAWAY the server must close the connection or answer a follow-up PING.
29+ await service_client .update_server_state ()
30+
31+ async with monitor_client .metrics_diff (prefix = 'server.requests.http2' ) as differ :
32+ async with create_connection () as (sock , conn ):
33+ conn .close_connection (error_code = 0 )
34+ ping_data = b'h2spec\x00 \x00 '
35+ ping = utils .create_frame (utils .PING_FRAME , utils .EMPTY_FLAGS , 0 , ping_data )
36+ await sock .sendall (conn .data_to_send () + ping )
37+
38+ receive = await sock .recv (utils .RECEIVE_SIZE , timeout = 2.0 )
39+ assert receive == b''
40+
41+ assert differ .value_at ('goaway' ) == 1
0 commit comments