Skip to content

Commit 39437ea

Browse files
notrojclaude
andauthored
Merge test_h2_008_04 server-status race fix from trunk (#720)
* test/modules/http2/test_008_ranges.py (TestRanges.test_h2_008_04): Poll server-status until the access count settles, allowing for the polls themselves in the expected totals. (TestRanges.get_server_status): Record the response body length. (cherry picked from commit 15c6e22) Submitted by: jorton Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> GitHub: #720
1 parent 9e512be commit 39437ea

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

‎test/modules/http2/test_008_ranges.py‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import os
55
import re
6+
import time
67
import pytest
78

89
from pyhttpd.backport import not_backported
@@ -157,19 +158,33 @@ def test_h2_008_04(self, env, repeat):
157158
url = env.mkurl("https", "test1", f'/data-100m?[0-{count-1}]')
158159
r = env.curl_get(url, 5, options=['--http2', '-H', f'Range: bytes=0-{4096}'])
159160
assert r.exit_code == 0, f'{r}'
160-
stats = self.get_server_status(env)
161-
# amount reported is larger than (count *4k), the net payload
162-
# but does not exceed an additional 4k
163-
assert (4*count)+1 <= int(stats['Total kBytes'])
164-
assert (4*(count+1))+1 > int(stats['Total kBytes'])
161+
# The scoreboard is updated as each stream is cleaned up, which can lag
162+
# the client finishing; poll server-status until the counts settle.
165163
# total requests is now at 1 from the start, plus the stat check,
166164
# plus the count transfers we did.
167-
assert (2+count) == int(stats['Total Accesses'])
165+
expected = 2 + count
166+
# Every extra status request is itself counted, adding one access
167+
# and the size of its response body.
168+
polled_kb = 0
169+
for _ in range(10):
170+
stats = self.get_server_status(env)
171+
accesses = int(stats['Total Accesses'])
172+
if accesses >= expected:
173+
break
174+
expected += 1
175+
polled_kb += (self.status_len + 1023) // 1024
176+
time.sleep(0.1)
177+
assert expected == accesses, f'{stats}'
178+
# amount reported is larger than (count *4k), the net payload
179+
# but does not exceed an additional 4k
180+
assert (4*count)+1 <= int(stats['Total kBytes']), f'{stats}'
181+
assert (4*(count+1))+1 + polled_kb > int(stats['Total kBytes']), f'{stats}'
168182

169183
def get_server_status(self, env):
170184
status_url = env.mkurl("https", "test1", '/status?auto')
171185
r = env.curl_get(status_url, 5)
172186
assert r.exit_code == 0, f'{r}'
187+
self.status_len = len(r.stdout)
173188
stats = {}
174189
for line in r.stdout.splitlines():
175190
m = re.match(r'([^:]+): (.*)', line)

0 commit comments

Comments
 (0)