Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions test/modules/http2/test_008_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import os
import re
import time
import pytest

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

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